Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r77120 - sandbox/SOC/2011/checks/boost/checks
From: pierre.talbot.6114_at_[hidden]
Date: 2012-02-26 14:13:20


Author: trademark
Date: 2012-02-26 14:13:18 EST (Sun, 26 Feb 2012)
New Revision: 77120
URL: http://svn.boost.org/trac/boost/changeset/77120

Log:
Make a stand alone processor.
Text files modified:
   sandbox/SOC/2011/checks/boost/checks/amex.hpp | 11 ++++
   sandbox/SOC/2011/checks/boost/checks/basic_check_algorithm.hpp | 23 ----------
   sandbox/SOC/2011/checks/boost/checks/basic_checks.hpp | 53 ++++++++++++++++--------
   sandbox/SOC/2011/checks/boost/checks/ean.hpp | 27 ++++++++++--
   sandbox/SOC/2011/checks/boost/checks/isbn.hpp | 11 ----
   sandbox/SOC/2011/checks/boost/checks/luhn.hpp | 66 ++++++++++++++++---------------
   sandbox/SOC/2011/checks/boost/checks/mastercard.hpp | 11 ++++
   sandbox/SOC/2011/checks/boost/checks/modulus10.hpp | 3
   sandbox/SOC/2011/checks/boost/checks/modulus11.hpp | 30 ++++++++++---
   sandbox/SOC/2011/checks/boost/checks/modulus97.hpp | 45 +++++++++++++++++---
   sandbox/SOC/2011/checks/boost/checks/upc.hpp | 16 ++++++-
   sandbox/SOC/2011/checks/boost/checks/verhoeff.hpp | 84 +++++++++++++++++++++------------------
   sandbox/SOC/2011/checks/boost/checks/visa.hpp | 11 ++++
   sandbox/SOC/2011/checks/boost/checks/weighted_sum.hpp | 21 +++------
   14 files changed, 244 insertions(+), 168 deletions(-)

Modified: sandbox/SOC/2011/checks/boost/checks/amex.hpp
==============================================================================
--- sandbox/SOC/2011/checks/boost/checks/amex.hpp (original)
+++ sandbox/SOC/2011/checks/boost/checks/amex.hpp 2012-02-26 14:13:18 EST (Sun, 26 Feb 2012)
@@ -51,7 +51,10 @@
 template <typename check_range>
 bool check_amex (const check_range& check_seq)
 {
- return boost::checks::check_sequence<luhn_algorithm, digit_prechecksum, AMEX_SIZE>(boost::rbegin(check_seq), boost::rend(check_seq));
+ return boost::checks::check_sequence<luhn_algorithm,
+ luhn_processor,
+ digit_prechecksum,
+ AMEX_SIZE>(boost::rbegin(check_seq), boost::rend(check_seq));
 }
 
 /*!
@@ -71,7 +74,11 @@
 template <typename check_range>
 std::size_t compute_amex(const check_range& check_seq)
 {
- return boost::checks::compute_checkdigit<luhn_algorithm, digit_prechecksum, AMEX_SIZE, basic_checkdigit>(boost::rbegin(check_seq), boost::rend(check_seq));
+ return boost::checks::compute_checkdigit<luhn_algorithm,
+ luhn_processor,
+ digit_prechecksum,
+ AMEX_SIZE,
+ basic_checkdigit>(boost::rbegin(check_seq), boost::rend(check_seq));
 }
 
 

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-26 14:13:18 EST (Sun, 26 Feb 2012)
@@ -88,29 +88,6 @@
   {
     return std::pair<std::size_t, std::size_t>();
   }
-
- /*!
- \brief Compute an operation on the checksum with the current valid value.
- \post Do nothing. The checksum is unchanged.
-
- \param current_valid_value is the current valid value analysed.
- \param valid_value_counter is the number of valid value(s) 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.
-
- \remarks This function should be overloaded if you want to calculate the checksum of a sequence.
- */
- template <typename Function>
- struct processor
- {
- Function counter;
- processor(Function counter) : counter(counter) { }
-
- std::size_t operator()(std::size_t checksum, std::size_t value)
- {
- return 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-26 14:13:18 EST (Sun, 26 Feb 2012)
@@ -57,14 +57,15 @@
   }
 };
 
-template <typename algorithm,
+template <typename algorithm,
+ template <class> class processor,
           std::size_t size_expected,
           typename seq_iterator,
           typename counter_iter>
 std::size_t compute_checksum(seq_iterator seq_begin, seq_iterator seq_end, counter_iter &counter)
 {
- typedef typename algorithm::template processor<deref<counter_iter> > processor;
- processor process = processor(deref<counter_iter>(counter));
+ typedef typename processor<deref<counter_iter> > counter_processor;
+ counter_processor process = counter_processor(deref<counter_iter>(counter));
 
   std::size_t checksum = 0;
   for(; seq_begin != seq_end && *counter < size_expected; ++seq_begin, ++counter)
@@ -76,12 +77,13 @@
 }
 
 template <typename algorithm,
+ template <class> class processor,
           typename seq_iterator,
           typename counter_iter>
 std::size_t compute_checksum(seq_iterator seq_begin, seq_iterator seq_end, counter_iter &counter)
 {
- typedef typename algorithm::template processor<deref<counter_iter> > processor;
- processor process = processor(deref<counter_iter>(counter));
+ typedef typename processor<deref<counter_iter> > counter_processor;
+ counter_processor process = counter_processor(deref<counter_iter>(counter));
   
   std::size_t checksum = 0;
   for(; seq_begin != seq_end; ++seq_begin, ++counter)
@@ -103,6 +105,7 @@
     \returns @c true if the checkdigit is correct, @c false otherwise.
 */
 template <typename algorithm,
+ template <class> class processor,
           typename prechecksum_type,
           typename seq_iterator>
 bool check_sequence(seq_iterator seq_begin, seq_iterator seq_end)
@@ -110,7 +113,8 @@
   boost::checks::detail::simple_counter::type counter = boost::checks::detail::simple_counter()();
  
   prechecksum_type prechecksum;
- std::size_t checksum = compute_checksum<algorithm>(prechecksum(seq_begin, seq_end),
+ std::size_t checksum = compute_checksum<algorithm,
+ processor>(prechecksum(seq_begin, seq_end),
                                                      prechecksum(seq_end, seq_end),
                                                      counter);
   return algorithm::validate_checksum(checksum);
@@ -131,6 +135,7 @@
     \returns @c true if the checkdigit is correct, @c false otherwise.
 */
 template <typename algorithm,
+ template <class> class processor,
           typename prechecksum_type,
           std::size_t size_expected,
           typename seq_iterator>
@@ -139,9 +144,11 @@
   boost::checks::detail::simple_counter::type counter = boost::checks::detail::simple_counter()();
   
   prechecksum_type prechecksum;
- std::size_t checksum = compute_checksum<algorithm, size_expected>(prechecksum(seq_begin, seq_end),
- prechecksum(seq_end, seq_end),
- counter);
+ std::size_t checksum = compute_checksum<algorithm,
+ processor,
+ size_expected>(prechecksum(seq_begin, seq_end),
+ prechecksum(seq_end, seq_end),
+ counter);
   if(checksum != bad_sequence)
     return algorithm::validate_checksum(checksum);
   return false;
@@ -161,6 +168,7 @@
     \returns The check digit of the type of a value in check_seq.
 */
 template <typename algorithm,
+ template <class> class processor,
           typename prechecksum_type,
           typename checkdigit,
           typename seq_iterator>
@@ -169,7 +177,8 @@
   typedef typename boost::checks::detail::skip_counter<checkdigit::pos, checkdigit::size> counter_type;
   typename counter_type::type counter = counter_type()();
   prechecksum_type prechecksum;
- std::size_t checksum = compute_checksum<algorithm>(prechecksum(seq_begin, seq_end),
+ std::size_t checksum = compute_checksum<algorithm,
+ processor>(prechecksum(seq_begin, seq_end),
                                                      prechecksum(seq_end, seq_end),
                                                      counter);
   return algorithm::compute_checkdigit(checksum);
@@ -190,6 +199,7 @@
     \returns The check digit of the type of a value in check_seq.
 */
 template <typename algorithm,
+ template <class> class processor,
           typename prechecksum_type,
           std::size_t size_expected,
           typename checkdigit,
@@ -199,10 +209,12 @@
   typedef typename boost::checks::detail::skip_counter<checkdigit::pos, checkdigit::size> counter_type;
   typename counter_type::type counter = counter_type()();
   prechecksum_type prechecksum;
- std::size_t checksum = compute_checksum<algorithm, size_expected>(prechecksum(seq_begin, seq_end),
- prechecksum(seq_end, seq_end),
- counter);
- if(checksum != size_expected)
+ std::size_t checksum = compute_checksum<algorithm,
+ processor,
+ size_expected>(prechecksum(seq_begin, seq_end),
+ prechecksum(seq_end, seq_end),
+ counter);
+ if(checksum != bad_sequence)
     return algorithm::compute_checkdigit(checksum);
   return bad_sequence;
 }
@@ -224,6 +236,7 @@
     \returns An iterator initialized at one pass the end of checkdigits.
 */
 template <typename algorithm,
+ template <class> class processor,
           typename prechecksum_type,
           typename checkdigit,
           typename seq_iterator>
@@ -232,7 +245,8 @@
   typedef typename boost::checks::detail::skip_counter<checkdigit::pos, checkdigit::size> counter_type;
   typename counter_type::type counter = counter_type()();
   prechecksum_type prechecksum;
- std::size_t checksum = compute_checksum<algorithm>(prechecksum(seq_begin, seq_end),
+ std::size_t checksum = compute_checksum<algorithm,
+ processor>(prechecksum(seq_begin, seq_end),
                                                      prechecksum(seq_end, seq_end),
                                                      counter);
   return algorithm::compute_multicheckdigit(checksum);
@@ -255,6 +269,7 @@
     \returns An iterator initialized at one pass the end of checkdigits.
 */
 template <typename algorithm,
+ template <class> class processor,
           typename prechecksum_type,
           std::size_t size_expected,
           typename checkdigit,
@@ -264,9 +279,11 @@
   typedef typename boost::checks::detail::skip_counter<checkdigit::pos, checkdigit::size> counter_type;
   typename counter_type::type counter = counter_type()();
   prechecksum_type prechecksum;
- std::size_t checksum = compute_checksum<algorithm, size_expected>(prechecksum(seq_begin, seq_end),
- prechecksum(seq_end, seq_end),
- counter);
+ std::size_t checksum = compute_checksum<algorithm,
+ processor,
+ size_expected>(prechecksum(seq_begin, seq_end),
+ prechecksum(seq_end, seq_end),
+ counter);
   if(checksum != bad_sequence)
     return algorithm::compute_multicheckdigit(checksum);
   return std::pair<std::size_t, std::size_t>(bad_sequence, bad_sequence);

Modified: sandbox/SOC/2011/checks/boost/checks/ean.hpp
==============================================================================
--- sandbox/SOC/2011/checks/boost/checks/ean.hpp (original)
+++ sandbox/SOC/2011/checks/boost/checks/ean.hpp 2012-02-26 14:13:18 EST (Sun, 26 Feb 2012)
@@ -20,6 +20,7 @@
 #include <boost/checks/checkdigit.hpp>
 #include <boost/checks/basic_checks.hpp>
 #include <boost/checks/modulus10.hpp>
+#include <boost/checks/weighted_sum.hpp>
 
 #include <boost/range/rbegin.hpp>
 #include <boost/range/rend.hpp>
@@ -40,11 +41,11 @@
 /*!
   \brief This is the weight used by EAN system.
 */
-typedef boost::checks::weight<1,3> ean_weight;
+typedef weighted_sum<weight<1,3> > ean_processor;
 /*!
   \brief This is the type of the EAN algorithm.
 */
-typedef boost::checks::modulus10_algorithm<ean_weight> ean_algorithm;
+typedef modulus10_algorithm ean_algorithm;
 
 /*!
     \brief Validate a sequence according to the ean_check_algorithm type.
@@ -61,7 +62,10 @@
 template <typename check_range>
 bool check_ean13(const check_range& check_seq)
 {
- return boost::checks::check_sequence<ean_algorithm, digit_prechecksum, EAN13_SIZE> (boost::rbegin(check_seq), boost::rend(check_seq));
+ return boost::checks::check_sequence<ean_algorithm,
+ ean_processor::processor,
+ digit_prechecksum,
+ EAN13_SIZE> (boost::rbegin(check_seq), boost::rend(check_seq));
 }
 
 /*!
@@ -80,7 +84,11 @@
 template <typename check_range>
 std::size_t compute_ean13(const check_range& check_seq)
 {
- return boost::checks::compute_checkdigit<ean_algorithm, digit_prechecksum, EAN13_SIZE, basic_checkdigit>(boost::rbegin(check_seq), boost::rend(check_seq));
+ return boost::checks::compute_checkdigit<ean_algorithm,
+ ean_processor::processor,
+ digit_prechecksum,
+ EAN13_SIZE,
+ basic_checkdigit>(boost::rbegin(check_seq), boost::rend(check_seq));
 }
 
 /*!
@@ -98,7 +106,10 @@
 template <typename check_range>
 bool check_ean8 (const check_range& check_seq)
 {
- return boost::checks::check_sequence<ean_algorithm, digit_prechecksum, EAN8_SIZE>(boost::rbegin(check_seq), boost::rend(check_seq));
+ return boost::checks::check_sequence<ean_algorithm,
+ ean_processor::processor,
+ digit_prechecksum,
+ EAN8_SIZE>(boost::rbegin(check_seq), boost::rend(check_seq));
 }
 
 /*!
@@ -117,7 +128,11 @@
 template <typename check_range>
 std::size_t compute_ean8(const check_range& check_seq)
 {
- return boost::checks::compute_checkdigit<ean_algorithm, digit_prechecksum, EAN8_SIZE, boost::checks::basic_checkdigit>(boost::rbegin(check_seq), boost::rend(check_seq));
+ return boost::checks::compute_checkdigit<ean_algorithm,
+ ean_processor::processor,
+ digit_prechecksum,
+ EAN8_SIZE,
+ basic_checkdigit>(boost::rbegin(check_seq), boost::rend(check_seq));
 }
 
 

Modified: sandbox/SOC/2011/checks/boost/checks/isbn.hpp
==============================================================================
--- sandbox/SOC/2011/checks/boost/checks/isbn.hpp (original)
+++ sandbox/SOC/2011/checks/boost/checks/isbn.hpp 2012-02-26 14:13:18 EST (Sun, 26 Feb 2012)
@@ -34,13 +34,6 @@
 namespace boost {
     namespace checks{
 
-/*! \class isbn13_algorithm
- \brief This class can be used to compute or validate checksum with a basic modulus 10 but using a custom filter for the ISBN-13 prefix.
-
- \tparam checkdigit_size Help functions to provide same behavior on sequence with and without check digits. No "real" value in the sequence will be skipped.
-*/
-typedef boost::checks::modulus10_algorithm<boost::checks::ean_weight> isbn13_algorithm;
-
 /*!
     \brief Validate a sequence according to the isbn13_check_algorithm type.
 
@@ -56,7 +49,7 @@
 template <typename check_range>
 bool check_isbn13 (const check_range& check_seq)
 {
- return boost::checks::check_sequence<isbn13_algorithm, digit_prechecksum, EAN13_SIZE>(boost::rbegin(check_seq), boost::rend(check_seq));
+ return check_ean13(check_seq);
 }
 
 /*!
@@ -75,7 +68,7 @@
 template <typename check_range>
 std::size_t compute_isbn13 (const check_range& check_seq)
 {
- return boost::checks::compute_checkdigit<isbn13_algorithm, digit_prechecksum, EAN13_SIZE, boost::checks::basic_checkdigit>(boost::rbegin(check_seq), boost::rend(check_seq));
+ return compute_ean13(check_seq);
 }
 
 /*!

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-26 14:13:18 EST (Sun, 26 Feb 2012)
@@ -26,43 +26,33 @@
 namespace boost {
     namespace checks{
 
+typedef modulus10_algorithm luhn_algorithm;
+
 /*!
- \brief This is the weight used by the Luhn algorithm.
-*/
-typedef boost::checks::weight<1,2> luhn_weight;
+ \brief Compute the Luhn algorithm operation on the checksum.
+
+ \post checksum is equal to the new computed checksum.
 
-/*! \class luhn_algorithm
- \brief This class can be used to compute or validate checksum with the Luhn algorithm.
+ \param current_valid_value is the current valid value analysed.
+ \param valid_value_counter is the number of valid value 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.
 
- \tparam checkdigit_size Help functions to provide same behavior on sequence with and without check digits. No "real" value in the sequence will be skipped.
+ \remarks This function become obsolete if you don't use luhn_weight. It is using operator "<<" to make internal multiplication.
 */
-struct luhn_algorithm : boost::checks::modulus10_algorithm <luhn_weight>
+template <typename Function>
+struct luhn_processor
 {
- /*!
- \brief Compute the Luhn algorithm operation on the checksum.
+ int weight;
+ luhn_processor(Function counter) : weight((counter() & 1)^1) { }
 
- \post checksum is equal to the new computed checksum.
-
- \param current_valid_value is the current valid value analysed.
- \param valid_value_counter is the number of valid value 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.
-
- \remarks This function become obsolete if you don't use luhn_weight. It is using operator "<<" to make internal multiplication.
- */
- template <typename Function>
- struct processor
+ std::size_t operator()(std::size_t checksum, std::size_t value)
   {
- Function counter;
- processor(Function counter) : counter(counter) { }
-
- std::size_t operator()(std::size_t checksum, std::size_t value)
- {
- std::size_t weighted_value = value << (luhn_weight::at(counter()) -1);
- return checksum + weighted_value % 10 + weighted_value / 10;
- }
- };
+ std::size_t weighted_value = value << (weight ^= 1);
+ return checksum + weighted_value % 10 + weighted_value / 10;
+ }
 };
 
+
 /*!
     \brief Validate a sequence according to the luhn_check_algorithm type.
 
@@ -79,7 +69,10 @@
 template <size_t size_expected, typename check_range>
 bool check_luhn (const check_range& check_seq)
 {
- return boost::checks::check_sequence<luhn_algorithm, digit_prechecksum, size_expected>(boost::rbegin(check_seq), boost::rend(check_seq));
+ return boost::checks::check_sequence<luhn_algorithm,
+ luhn_processor,
+ digit_prechecksum,
+ size_expected>(boost::rbegin(check_seq), boost::rend(check_seq));
 }
 
 /*!
@@ -97,7 +90,9 @@
 template <typename check_range>
 bool check_luhn (const check_range& check_seq)
 {
- return boost::checks::check_sequence<luhn_algorithm, digit_prechecksum> (boost::rbegin(check_seq), boost::rend(check_seq));
+ return boost::checks::check_sequence<luhn_algorithm,
+ luhn_processor,
+ digit_prechecksum>(boost::rbegin(check_seq), boost::rend(check_seq));
 }
 
 /*!
@@ -117,7 +112,11 @@
 template <size_t size_expected, typename check_range>
 std::size_t compute_luhn(const check_range& check_seq)
 {
- return boost::checks::compute_checkdigit<luhn_algorithm, digit_prechecksum, size_expected, boost::checks::basic_checkdigit>(boost::rbegin(check_seq), boost::rend(check_seq));
+ return boost::checks::compute_checkdigit<luhn_algorithm,
+ luhn_processor,
+ digit_prechecksum,
+ size_expected,
+ basic_checkdigit>(boost::rbegin(check_seq), boost::rend(check_seq));
 }
 
 /*!
@@ -136,7 +135,10 @@
 template <typename check_range>
 std::size_t compute_luhn (const check_range& check_seq)
 {
- return boost::checks::compute_checkdigit<luhn_algorithm, digit_prechecksum, boost::checks::basic_checkdigit>(boost::rbegin(check_seq), boost::rend(check_seq));
+ return boost::checks::compute_checkdigit<luhn_algorithm,
+ luhn_processor,
+ digit_prechecksum,
+ basic_checkdigit>(boost::rbegin(check_seq), boost::rend(check_seq));
 }
 
 

Modified: sandbox/SOC/2011/checks/boost/checks/mastercard.hpp
==============================================================================
--- sandbox/SOC/2011/checks/boost/checks/mastercard.hpp (original)
+++ sandbox/SOC/2011/checks/boost/checks/mastercard.hpp 2012-02-26 14:13:18 EST (Sun, 26 Feb 2012)
@@ -47,7 +47,10 @@
 template <typename check_range>
 bool check_mastercard(const check_range& check_seq)
 {
- return boost::checks::check_sequence<luhn_algorithm, digit_prechecksum, MASTERCARD_SIZE>(boost::rbegin(check_seq), boost::rend(check_seq));
+ return check_sequence<luhn_algorithm,
+ luhn_processor,
+ digit_prechecksum,
+ MASTERCARD_SIZE>(boost::rbegin(check_seq), boost::rend(check_seq));
 }
 
 /*!
@@ -67,7 +70,11 @@
 template <typename check_range>
 std::size_t compute_mastercard(const check_range& check_seq)
 {
- return boost::checks::compute_checkdigit<luhn_algorithm, digit_prechecksum, MASTERCARD_SIZE, boost::checks::basic_checkdigit>(boost::rbegin(check_seq), boost::rend(check_seq));
+ return compute_checkdigit<luhn_algorithm,
+ luhn_processor,
+ digit_prechecksum,
+ MASTERCARD_SIZE,
+ basic_checkdigit>(boost::rbegin(check_seq), boost::rend(check_seq));
 }
 
 

Modified: sandbox/SOC/2011/checks/boost/checks/modulus10.hpp
==============================================================================
--- sandbox/SOC/2011/checks/boost/checks/modulus10.hpp (original)
+++ sandbox/SOC/2011/checks/boost/checks/modulus10.hpp 2012-02-26 14:13:18 EST (Sun, 26 Feb 2012)
@@ -29,8 +29,7 @@
     \tparam iteration_sense must meet the iteration_sense concept requirements.
     \tparam checkdigit_size Help functions to provide same behavior on sequence with and without check digits. No "real" value in the sequence will be skipped.
 */
-template <typename mod10_weight>
-struct modulus10_algorithm : boost::checks::weighted_sum_algorithm<mod10_weight>
+struct modulus10_algorithm
 {
   /*!
     \brief Validate a checksum with a simple modulus 10.

Modified: sandbox/SOC/2011/checks/boost/checks/modulus11.hpp
==============================================================================
--- sandbox/SOC/2011/checks/boost/checks/modulus11.hpp (original)
+++ sandbox/SOC/2011/checks/boost/checks/modulus11.hpp 2012-02-26 14:13:18 EST (Sun, 26 Feb 2012)
@@ -36,8 +36,8 @@
 
     \remarks The range of the check digit is [0..10], the tenth element is translated as the letter 'X'.
 */
-template <typename mod11_weight>
-struct modulus11_algorithm : boost::checks::weighted_sum_algorithm<mod11_weight>
+
+struct modulus11_algorithm
 {
   /*!
     \brief Validate a checksum with a simple modulus 11.
@@ -70,12 +70,14 @@
 /*!
   \brief The most common weight pattern used with a modulus 11 algorithm.
 */
-typedef boost::checks::weight<1,2,3,4,5,6,7,8,9,10> mod11_weight;
+typedef weight<1,2,3,4,5,6,7,8,9,10> mod11_weight;
 
 /*!
   \brief This is the type of the most common modulus 11 algorithm.
 */
-typedef modulus11_algorithm<mod11_weight> mod11_algorithm;
+typedef modulus11_algorithm mod11_algorithm;
+
+typedef weighted_sum<mod11_weight> mod11_processor;
 
 /*!
     \brief Validate a sequence according to the mod11_check_algorithm type.
@@ -93,7 +95,10 @@
 template <size_t size_expected, typename check_range>
 bool check_modulus11(const check_range& check_seq)
 {
- return boost::checks::check_sequence<mod11_algorithm, digitx_prechecksum, size_expected>(boost::rbegin(check_seq), boost::rend(check_seq));
+ return boost::checks::check_sequence<mod11_algorithm,
+ mod11_processor::processor,
+ digitx_prechecksum,
+ size_expected>(boost::rbegin(check_seq), boost::rend(check_seq));
 }
 
 /*!
@@ -111,7 +116,9 @@
 template <typename check_range>
 bool check_modulus11(const check_range& check_seq)
 {
- return boost::checks::check_sequence<mod11_algorithm, digitx_prechecksum>(boost::rbegin(check_seq), boost::rend(check_seq));
+ return boost::checks::check_sequence<mod11_algorithm,
+ mod11_processor::processor,
+ digitx_prechecksum>(boost::rbegin(check_seq), boost::rend(check_seq));
 }
 
 /*!
@@ -131,7 +138,11 @@
 template <std::size_t size_expected, typename check_range>
 std::size_t compute_modulus11(const check_range& check_seq)
 {
- return boost::checks::compute_checkdigit<mod11_algorithm, digitx_prechecksum, size_expected, boost::checks::basic_checkdigit>(boost::rbegin(check_seq), boost::rend(check_seq));
+ return compute_checkdigit<mod11_algorithm,
+ mod11_processor::processor,
+ digitx_prechecksum,
+ size_expected,
+ basic_checkdigit>(boost::rbegin(check_seq), boost::rend(check_seq));
 }
 
 /*!
@@ -150,7 +161,10 @@
 template <typename check_range>
 std::size_t compute_modulus11(const check_range& check_seq)
 {
- return boost::checks::compute_checkdigit<mod11_algorithm, digitx_prechecksum, boost::checks::basic_checkdigit>(boost::rbegin(check_seq), boost::rend(check_seq));
+ return compute_checkdigit<mod11_algorithm,
+ mod11_processor::processor,
+ digitx_prechecksum,
+ basic_checkdigit>(boost::rbegin(check_seq), boost::rend(check_seq));
 }
 
 }} // namespace boost namespace checks

Modified: sandbox/SOC/2011/checks/boost/checks/modulus97.hpp
==============================================================================
--- sandbox/SOC/2011/checks/boost/checks/modulus97.hpp (original)
+++ sandbox/SOC/2011/checks/boost/checks/modulus97.hpp 2012-02-26 14:13:18 EST (Sun, 26 Feb 2012)
@@ -35,8 +35,8 @@
 
     \remarks This algorithm use two check digits.
 */
-template <typename mod97_weight>
-struct modulus97_algorithm : boost::checks::weighted_sum_algorithm<mod97_weight>
+
+struct modulus97_algorithm
 {
   /*!
     \brief Validate a checksum with a simple modulus 97.
@@ -113,15 +113,32 @@
 /*!
   \brief This is weight of the mod97-10 algorithm.
 */
-typedef boost::checks::weight<BOOST_PP_ENUM(96, MOD97_weight_maker, ~)> mod97_10_weight;
+typedef weight<BOOST_PP_ENUM(96, MOD97_weight_maker, ~)> mod97_10_weight;
 
 /*!
   \brief This is the type of the modulus 97-10 algorithm.
 */
-typedef modulus97_algorithm<mod97_10_weight> mod97_10_algorithm;
+typedef modulus97_algorithm mod97_10_algorithm;
+
+// typedef weighted_sum<mod97_10_weight> mod97_10_processor;
 
 typedef checkdigit<0, 2> mod97_10_checkdigit;
 
+typedef weighted_sum<mod97_10_weight> mod97_10_processor;
+/*
+template <typename Function>
+struct mod97_10_processor
+{
+ unsigned char weight;
+ mod97_10_processor(Function counter) : weight(68) { }
+
+ std::size_t operator()(std::size_t checksum, std::size_t value)
+ {
+ weight = weight * 10 % 97;
+ return checksum + value * weight;
+ }
+};*/
+
 /*!
     \brief Validate a sequence according to the mod97_10_check_algorithm type.
 
@@ -138,7 +155,10 @@
 template <size_t size_expected, typename check_range>
 bool check_mod97_10 (const check_range& check_seq)
 {
- return boost::checks::check_sequence<mod97_10_algorithm, digit_prechecksum, size_expected> (boost::rbegin(check_seq), boost::rend(check_seq));
+ return boost::checks::check_sequence<mod97_10_algorithm,
+ mod97_10_processor::processor,
+ digit_prechecksum,
+ size_expected>(boost::rbegin(check_seq), boost::rend(check_seq));
 }
 
 /*!
@@ -156,7 +176,9 @@
 template <typename check_range>
 bool check_mod97_10(const check_range& check_seq)
 {
- return boost::checks::check_sequence<mod97_10_algorithm, digit_prechecksum >(boost::rbegin(check_seq), boost::rend(check_seq));
+ return boost::checks::check_sequence<mod97_10_algorithm,
+ mod97_10_processor::processor,
+ digit_prechecksum>(boost::rbegin(check_seq), boost::rend(check_seq));
 }
 
 /*!
@@ -178,7 +200,11 @@
 template <size_t size_expected, typename check_range>
 std::pair<std::size_t, std::size_t> compute_mod97_10(const check_range& check_seq)
 {
- return boost::checks::compute_multicheckdigit<mod97_10_algorithm, digit_prechecksum, mod97_10_checkdigit, size_expected>(boost::rbegin(check_seq), boost::rend(check_seq));
+ return boost::checks::compute_multicheckdigit<mod97_10_algorithm,
+ mod97_10_processor::processor,
+ digit_prechecksum,
+ mod97_10_checkdigit,
+ size_expected>(boost::rbegin(check_seq), boost::rend(check_seq));
 }
 
 /*!
@@ -199,7 +225,10 @@
 template <typename check_range>
 std::pair<std::size_t, std::size_t> compute_mod97_10(const check_range& check_seq)
 {
- return boost::checks::compute_multicheckdigit<mod97_10_algorithm, digit_prechecksum, mod97_10_checkdigit>(boost::rbegin(check_seq), boost::rend(check_seq));
+ return boost::checks::compute_multicheckdigit<mod97_10_algorithm,
+ mod97_10_processor::processor,
+ digit_prechecksum,
+ mod97_10_checkdigit>(boost::rbegin(check_seq), boost::rend(check_seq));
 }
 
 

Modified: sandbox/SOC/2011/checks/boost/checks/upc.hpp
==============================================================================
--- sandbox/SOC/2011/checks/boost/checks/upc.hpp (original)
+++ sandbox/SOC/2011/checks/boost/checks/upc.hpp 2012-02-26 14:13:18 EST (Sun, 26 Feb 2012)
@@ -23,6 +23,7 @@
 #include <boost/checks/weight.hpp>
 #include <boost/checks/basic_checks.hpp>
 #include <boost/checks/modulus10.hpp>
+#include <boost/checks/weighted_sum.hpp>
 
 /*!
   \brief This macro defines the size of an UPC-A.
@@ -40,7 +41,9 @@
 /*!
   \brief This is the type of the UPC algorithm.
 */
-typedef boost::checks::modulus10_algorithm<upc_weight> upc_algorithm;
+typedef modulus10_algorithm upc_algorithm;
+
+typedef weighted_sum<upc_weight> upc_processor;
 
 /*!
     \brief Validate a sequence according to the upc_check_algorithm type.
@@ -57,7 +60,10 @@
 template <typename check_range>
 bool check_upca (const check_range& check_seq)
 {
- return boost::checks::check_sequence<upc_algorithm, digit_prechecksum, UPCA_SIZE>(boost::rbegin(check_seq), boost::rend(check_seq));
+ return boost::checks::check_sequence<upc_algorithm,
+ upc_processor::processor,
+ digit_prechecksum,
+ UPCA_SIZE>(boost::rbegin(check_seq), boost::rend(check_seq));
 }
 
 /*!
@@ -76,7 +82,11 @@
 template <typename check_range>
 std::size_t compute_upca(const check_range& check_seq)
 {
- return boost::checks::compute_checkdigit<upc_algorithm, digit_prechecksum, UPCA_SIZE, boost::checks::basic_checkdigit>(boost::rbegin(check_seq), boost::rend(check_seq));
+ return boost::checks::compute_checkdigit<upc_algorithm,
+ upc_processor::processor,
+ digit_prechecksum,
+ UPCA_SIZE,
+ basic_checkdigit>(boost::rbegin(check_seq), boost::rend(check_seq));
 }
 
 }} // namespace boost namespace checks

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-26 14:13:18 EST (Sun, 26 Feb 2012)
@@ -36,34 +36,9 @@
 
     \tparam checkdigit_size Help functions to provide same behavior on sequence with and without check digits. No "real" value in the sequence will be skipped.
 */
-struct verhoeff_algorithm : boost::checks::basic_check_algorithm
+struct verhoeff_algorithm
 {
   /*!
- \brief Compute the Verhoeff scheme on the checksum with the current valid value.
-
- \post checksum is equal to the new computed checksum.
-
- \param current_valid_value is the current valid value analysed.
- \param valid_value_counter is the number of valid value 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.
-
- \remarks This function use the classic table d and p of the Verhoeff algorithm.
- */
- template <typename Function>
- struct processor
- {
- static const unsigned char d[10][10];
- static const unsigned char p[8][10];
-
- Function counter;
- processor(Function counter) : counter(counter) { }
-
- std::size_t operator()(std::size_t checksum, std::size_t value)
- {
- return d[checksum][p[counter() % 8][value]];
- }
- };
- /*!
     \brief Validate the Verhoeff checksum.
 
     \param checksum is the checksum to validate.
@@ -93,8 +68,34 @@
   }
 };
 
+/*!
+ \brief Compute the Verhoeff scheme on the checksum with the current valid value.
+
+ \post checksum is equal to the new computed checksum.
+
+ \param current_valid_value is the current valid value analysed.
+ \param valid_value_counter is the number of valid value 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.
+
+ \remarks This function use the classic table d and p of the Verhoeff algorithm.
+*/
+template <typename Function>
+struct verhoeff_processor
+{
+ static const unsigned char d[10][10];
+ static const unsigned char p[8][10];
+
+ Function counter;
+ verhoeff_processor(Function counter) : counter(counter) { }
+
+ std::size_t operator()(std::size_t checksum, std::size_t value)
+ {
+ return d[checksum][p[counter() % 8][value]];
+ }
+};
+
 template <typename Function>
-const unsigned char verhoeff_algorithm::processor<Function>::d[10][10] =
+const unsigned char verhoeff_processor<Function>::d[10][10] =
 {
   { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
   { 1, 2, 3, 4, 0, 6, 7, 8, 9, 5 },
@@ -109,7 +110,7 @@
 };
 
 template <typename Function>
-const unsigned char verhoeff_algorithm::processor<Function>::p[8][10] =
+const unsigned char verhoeff_processor<Function>::p[8][10] =
 {
   { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
   { 1, 5, 7, 6, 2, 8, 3, 0, 9, 4 },
@@ -137,7 +138,10 @@
 template <size_t size_expected, typename check_range>
 bool check_verhoeff(const check_range& check_seq)
 {
- return boost::checks::check_sequence<verhoeff_algorithm, digit_prechecksum, size_expected>(boost::rbegin(check_seq), boost::rend(check_seq));
+ return boost::checks::check_sequence<verhoeff_algorithm,
+ verhoeff_processor,
+ digit_prechecksum,
+ size_expected>(boost::rbegin(check_seq), boost::rend(check_seq));
 }
 
 /*!
@@ -155,7 +159,9 @@
 template <typename check_range>
 bool check_verhoeff(const check_range& check_seq)
 {
- return boost::checks::check_sequence<verhoeff_algorithm, digit_prechecksum >(boost::rbegin(check_seq), boost::rend(check_seq));
+ return boost::checks::check_sequence<verhoeff_algorithm,
+ verhoeff_processor,
+ digit_prechecksum >(boost::rbegin(check_seq), boost::rend(check_seq));
 }
 
 /*!
@@ -175,11 +181,11 @@
 template <size_t size_expected, typename check_range>
 std::size_t compute_verhoeff(const check_range& check_seq)
 {
- return boost::checks::compute_checkdigit<verhoeff_algorithm,
- digit_prechecksum,
- size_expected,
- basic_checkdigit>
- (boost::rbegin(check_seq), boost::rend(check_seq));
+ return compute_checkdigit<verhoeff_algorithm,
+ verhoeff_processor,
+ digit_prechecksum,
+ size_expected,
+ basic_checkdigit>(boost::rbegin(check_seq), boost::rend(check_seq));
 }
 
 /*!
@@ -198,10 +204,10 @@
 template <typename check_range>
 std::size_t compute_verhoeff(const check_range& check_seq)
 {
- return boost::checks::compute_checkdigit<verhoeff_algorithm,
- digit_prechecksum,
- basic_checkdigit>
- (boost::rbegin(check_seq), boost::rend(check_seq));
+ return compute_checkdigit<verhoeff_algorithm,
+ verhoeff_processor,
+ digit_prechecksum,
+ basic_checkdigit>(boost::rbegin(check_seq), boost::rend(check_seq));
 }
 
 }}

Modified: sandbox/SOC/2011/checks/boost/checks/visa.hpp
==============================================================================
--- sandbox/SOC/2011/checks/boost/checks/visa.hpp (original)
+++ sandbox/SOC/2011/checks/boost/checks/visa.hpp 2012-02-26 14:13:18 EST (Sun, 26 Feb 2012)
@@ -47,7 +47,10 @@
 template <typename check_range>
 bool check_visa(const check_range& check_seq)
 {
- return boost::checks::check_sequence<luhn_algorithm, digit_prechecksum, VISA_SIZE>(boost::rbegin(check_seq), boost::rend(check_seq));
+ return check_sequence<luhn_algorithm,
+ luhn_processor,
+ digit_prechecksum,
+ VISA_SIZE>(boost::rbegin(check_seq), boost::rend(check_seq));
 }
 
 /*!
@@ -67,7 +70,11 @@
 template <typename check_range>
 std::size_t compute_visa(const check_range& check_seq)
 {
- return boost::checks::compute_checkdigit<luhn_algorithm, digit_prechecksum, VISA_SIZE, boost::checks::basic_checkdigit>(boost::rbegin(check_seq), boost::rend(check_seq));
+ return compute_checkdigit<luhn_algorithm,
+ luhn_processor,
+ digit_prechecksum,
+ VISA_SIZE,
+ basic_checkdigit>(boost::rbegin(check_seq), boost::rend(check_seq));
 }
 
 

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-26 14:13:18 EST (Sun, 26 Feb 2012)
@@ -24,24 +24,17 @@
   namespace checks{
 
 /*!
- \brief This class permits to add to the current checksum the weight multiplied by the current value.
+ \brief Compute an operation on the checksum with the current valid value.
 
- \tparam weight must meet the weight concept requirements.
- \tparam iteration_sense must meet the iteration_sense concept requirements.
- \tparam checkdigit_size Helper function to provide same behavior on sequence with and without checkdigits. No "real" value in the sequence will be skipped.
+ \post The current weight multiplied by the current value is added to the checksum.
+
+ \param current_valid_value is the current valid value analysed.
+ \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.
 */
 template <typename weight>
-struct weighted_sum_algorithm : boost::checks::basic_check_algorithm
+struct weighted_sum
 {
- /*!
- \brief Compute an operation on the checksum with the current valid value.
-
- \post The current weight multiplied by the current value is added to the checksum.
-
- \param current_valid_value is the current valid value analysed.
- \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.
- */
   template <typename Function>
   struct processor
   {


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