Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r73335 - sandbox/SOC/2011/checks/boost/checks
From: pierre.talbot.6114_at_[hidden]
Date: 2011-07-24 14:19:39


Author: trademark
Date: 2011-07-24 14:19:38 EDT (Sun, 24 Jul 2011)
New Revision: 73335
URL: http://svn.boost.org/trac/boost/changeset/73335

Log:
modulus.hpp and basic_check.hpp forward declaration...
Text files modified:
   sandbox/SOC/2011/checks/boost/checks/checks_fwd.hpp | 84 ++++++++++++++++++++++++++++++++++++---
   1 files changed, 76 insertions(+), 8 deletions(-)

Modified: sandbox/SOC/2011/checks/boost/checks/checks_fwd.hpp
==============================================================================
--- sandbox/SOC/2011/checks/boost/checks/checks_fwd.hpp (original)
+++ sandbox/SOC/2011/checks/boost/checks/checks_fwd.hpp 2011-07-24 14:19:38 EDT (Sun, 24 Jul 2011)
@@ -58,11 +58,84 @@
     #pragma once
 #endif // _MSC_VER
 
-#include <boost/array.hpp>
+// MPL and PP includes
+#include <boost/mpl/vector_c.hpp>
+#include <boost/mpl/size.hpp>
+#include <boost/mpl/for_each.hpp>
+#include <boost/preprocessor/repetition.hpp>
+// Range include
+#include <boost/range/numeric.hpp>
+// Lexical include
+#include <boost/lexical_cast.hpp>
+
+#define BOOST_CHECK_LIMIT_WEIGHTS 10 // The maximum number of weights. (non-type template parameters)
+
 
 namespace boost{
   namespace checks{
 
+
+ /* check mod 10 function */
+
+// DEFAULT prototype. If any non-type template argument are passed to the function, we consider a weight of 1.
+template<typename mod10_range>
+bool check_mod10(const mod10_range& mod10_number) ;
+
+// Prototypes for the different size of non-type template argument (weight).
+#define _CHECK_mod10(z,n,unused) \
+ template<BOOST_PP_ENUM_PARAMS(n, int weight) BOOST_PP_COMMA_IF(n) typename mod10_range> \
+ bool check_mod10(const mod10_range& mod10_number) ; \
+
+// Develop the macro _CHECK_mod10 BOOST_CHECK_LIMIT_WEIGHTS times.
+BOOST_PP_REPEAT_FROM_TO(1,BOOST_CHECK_LIMIT_WEIGHTS,_CHECK_mod10,~)
+#undef _CHECK_mod10
+
+ /* compute mod 10 function */
+
+ // DEFAULT prototype. If any non-type template argument are passed to the function, we consider a weight of 1.
+template<typename mod10_range>
+typename boost::range_value<mod10_range>::type compute_mod10(const mod10_range& mod10_number) ;
+
+// Prototypes for the different size of non-type template argument (weight).
+#define _COMPUTE_mod10(z,n,unused) \
+ template<BOOST_PP_ENUM_PARAMS(n, int weight) BOOST_PP_COMMA_IF(n) typename mod10_range> \
+ typename boost::range_value<mod10_range>::type compute_mod10(const mod10_range& mod10_number) ; \
+
+// Develop the macro _COMPUTE_mod10 BOOST_CHECK_LIMIT_WEIGHTS times.
+BOOST_PP_REPEAT_FROM_TO(1, BOOST_CHECK_LIMIT_WEIGHTS, _COMPUTE_mod10, ~)
+#undef _COMPUTE_mod10
+
+ /* Check mod 11 function */
+
+// DEFAULT prototype. If any non-type template argument are passed to the function, we consider a weight of 1.
+template<typename mod11_range>
+bool check_mod11(const mod11_range& mod11_number) ;
+
+// Prototypes for the different size of non-type template argument (weight).
+#define _CHECK_mod11(z,n,unused) \
+ template<BOOST_PP_ENUM_PARAMS(n, int weight) BOOST_PP_COMMA_IF(n) typename mod11_range> \
+ bool check_mod11(const mod11_range& mod11_number) ; \
+
+// Develop the macro _CHECK_mod11 BOOST_CHECK_LIMIT_WEIGHTS times.
+BOOST_PP_REPEAT_FROM_TO(1,BOOST_CHECK_LIMIT_WEIGHTS,_CHECK_mod11,~)
+#undef _CHECK_mod11
+
+
+ /* Compute mod 11 function */
+
+// DEFAULT prototype. If any non-type template argument are passed to the function, we consider a weight of 1.
+template<typename mod11_range>
+typename boost::range_value<mod11_range>::type compute_mod11(const mod11_range& mod11_number) ;
+
+// Prototypes for the different size of non-type template argument (weight).
+#define _COMPUTE_mod11(z,n,unused) \
+ template<BOOST_PP_ENUM_PARAMS(n, int weight) BOOST_PP_COMMA_IF(n) typename mod11_range> \
+ typename boost::range_value<mod11_range>::type compute_mod11(const mod11_range& mod11_number) ; \
+
+// Develop the macro _COMPUTE_mod11 BOOST_CHECK_LIMIT_WEIGHTS times.
+BOOST_PP_REPEAT_FROM_TO(1, BOOST_CHECK_LIMIT_WEIGHTS, _COMPUTE_mod11, ~)
+#undef _COMPUTE_mod11
+
 // Provides forward declaration of all Boost.Checks functions:
 
 /** Validate the check digit of the number provided with the Luhn algorithm.
@@ -116,6 +189,8 @@
     template <typename mod10_iter, typename weight_t >
     bool check_mod10(mod10_iter &begin, const mod10_iter &end, const weight_t &weight, std::size_t nbr_digits=0);
 
+
+
 /** Compute the check digit of the number provided with the modulus 10 algorithm.
  * \tparam mod10_iter with at least the caracteristics of an input iterator. It The beginning or the ending of a sequence of character.
  * \tparam weight_t Contains numeric values (should be unsigned) assigned to the weight of the digits.
@@ -184,13 +259,6 @@
     template <typename mod11_checkdigit, typename mod11_iter>
     mod11_checkdigit compute_mod11(mod11_iter &begin, const mod11_iter &end, std::size_t nbr_digits=0);
 
-
-
-
- /*!!!
-The modulus 97 algorithm wait for a sequence of numbers only ! and will not do anything else that sum the digits and calculate the modulus of this sum.
-If you need to check an IBAN use the algorithms in iban.hpp */
-
 /** Compute the check digit of the number provided with the modulus 97 algorithm.
  * \tparam mod97_iter Iterator with at least the caracteristics of an input iterator. It represents the beginning or the ending of a sequence of character.
  * \param[in,out] begin The beginning of the sequence to check.


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