Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r76910 - sandbox/SOC/2011/checks/boost/checks
From: pierre.talbot.6114_at_[hidden]
Date: 2012-02-06 11:53:05


Author: trademark
Date: 2012-02-06 11:53:04 EST (Mon, 06 Feb 2012)
New Revision: 76910
URL: http://svn.boost.org/trac/boost/changeset/76910

Log:
Change the prototype of operate_on_valid_value become std::size_t process(std::size_t checksum, std::size_t value, std::size_t value_pos);
Text files modified:
   sandbox/SOC/2011/checks/boost/checks/basic_check_algorithm.hpp | 5 +++--
   sandbox/SOC/2011/checks/boost/checks/basic_checks.hpp | 2 +-
   sandbox/SOC/2011/checks/boost/checks/luhn.hpp | 4 ++--
   sandbox/SOC/2011/checks/boost/checks/verhoeff.hpp | 4 ++--
   sandbox/SOC/2011/checks/boost/checks/weighted_sum.hpp | 5 ++---
   5 files changed, 10 insertions(+), 10 deletions(-)

Modified: sandbox/SOC/2011/checks/boost/checks/basic_check_algorithm.hpp
==============================================================================
--- sandbox/SOC/2011/checks/boost/checks/basic_check_algorithm.hpp (original)
+++ sandbox/SOC/2011/checks/boost/checks/basic_check_algorithm.hpp 2012-02-06 11:53:04 EST (Mon, 06 Feb 2012)
@@ -114,8 +114,9 @@
 
     \remarks This function should be overloaded if you want to calculate the checksum of a sequence.
   */
- static void operate_on_valid_value(std::size_t current_valid_value, std::size_t valid_value_counter, std::size_t &checksum)
+ static std::size_t operate_on_valid_value(std::size_t, std::size_t, std::size_t)
   {
+ return std::size_t();
   }
 
   /*!
@@ -128,7 +129,7 @@
 
     \remarks This function should be overloaded if you want to filter the values with their positions.
   */
- static void filter_valid_value_with_pos(std::size_t current_valid_value, std::size_t current_value_position)
+ static void filter_valid_value_with_pos(std::size_t, std::size_t)
   {
   }
 };

Modified: sandbox/SOC/2011/checks/boost/checks/basic_checks.hpp
==============================================================================
--- sandbox/SOC/2011/checks/boost/checks/basic_checks.hpp (original)
+++ sandbox/SOC/2011/checks/boost/checks/basic_checks.hpp 2012-02-06 11:53:04 EST (Mon, 06 Feb 2012)
@@ -68,7 +68,7 @@
       std::size_t value = boost::checks::detail::lexical_cast(*seq_begin);
       value = algorithm::translate_to_valid_value(value);
       algorithm::filter_valid_value_with_pos(value, value_counter);
- algorithm::operate_on_valid_value(value, value_counter, checksum);
+ checksum = algorithm::process(checksum, value, value_counter);
       ++value_counter;
     }
     catch(boost::checks::translation_exception){

Modified: sandbox/SOC/2011/checks/boost/checks/luhn.hpp
==============================================================================
--- sandbox/SOC/2011/checks/boost/checks/luhn.hpp (original)
+++ sandbox/SOC/2011/checks/boost/checks/luhn.hpp 2012-02-06 11:53:04 EST (Mon, 06 Feb 2012)
@@ -49,11 +49,11 @@
 
     \remarks This function become obsolete if you don't use luhn_weight. It is using operator "<<" to make internal multiplication.
   */
- static void operate_on_valid_value(std::size_t current_valid_value, std::size_t valid_value_counter, std::size_t &checksum)
+ static std::size_t process(std::size_t checksum, std::size_t current_valid_value, std::size_t valid_value_counter)
   {
     std::size_t current_weight = luhn_weight::at(valid_value_counter + checkdigit_size);
     std::size_t weighted_value = current_valid_value << (current_weight-1);
- checksum += weighted_value % 10 + weighted_value / 10;
+ return checksum + weighted_value % 10 + weighted_value / 10;
   }
 };
 

Modified: sandbox/SOC/2011/checks/boost/checks/verhoeff.hpp
==============================================================================
--- sandbox/SOC/2011/checks/boost/checks/verhoeff.hpp (original)
+++ sandbox/SOC/2011/checks/boost/checks/verhoeff.hpp 2012-02-06 11:53:04 EST (Mon, 06 Feb 2012)
@@ -50,7 +50,7 @@
 
     \remarks This function use the classic table d and p of the Verhoeff algorithm.
   */
- static void operate_on_valid_value(std::size_t current_valid_value, std::size_t valid_value_counter, std::size_t &checksum)
+ static std::size_t process(std::size_t checksum, std::size_t value, std::size_t value_pos)
   {
     static const unsigned char d[10][10] =
     {
@@ -78,7 +78,7 @@
       { 7, 0, 4, 6, 9, 1, 3, 2, 5, 8 }
     };
 
- checksum = d[checksum][p[(valid_value_counter + checkdigit_size)% 8][current_valid_value]];
+ return d[checksum][p[(value_pos + checkdigit_size)% 8][value]];
   }
 
   /*!

Modified: sandbox/SOC/2011/checks/boost/checks/weighted_sum.hpp
==============================================================================
--- sandbox/SOC/2011/checks/boost/checks/weighted_sum.hpp (original)
+++ sandbox/SOC/2011/checks/boost/checks/weighted_sum.hpp 2012-02-06 11:53:04 EST (Mon, 06 Feb 2012)
@@ -42,10 +42,9 @@
     \param valid_value_counter is the number of valid values already counted (the current value is not included).\n This is also the position (above the valid values) of the current value analysed (0 <= valid_value_counter < n).
     \param checksum is the current checksum.
   */
- static void operate_on_valid_value(std::size_t current_valid_value, std::size_t valid_value_counter, std::size_t &checksum)
+ static std::size_t process(std::size_t checksum, std::size_t value, std::size_t value_pos)
   {
- int current_weight = weight::at(valid_value_counter + checkdigit_size);
- checksum += current_valid_value * current_weight;
+ return checksum + value * weight::at(value_pos + checkdigit_size);
   }
 };
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk