Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r76907 - sandbox/SOC/2011/checks/boost/checks
From: pierre.talbot.6114_at_[hidden]
Date: 2012-02-06 09:31:31


Author: trademark
Date: 2012-02-06 09:31:29 EST (Mon, 06 Feb 2012)
New Revision: 76907
URL: http://svn.boost.org/trac/boost/changeset/76907

Log:
commit for revert
Text files modified:
   sandbox/SOC/2011/checks/boost/checks/amex.hpp | 21 ++++++++++++++++
   sandbox/SOC/2011/checks/boost/checks/basic_checks.hpp | 31 +++++++++++++++++++++++++
   sandbox/SOC/2011/checks/boost/checks/lexical_filter.hpp | 49 ++++-----------------------------------
   sandbox/SOC/2011/checks/boost/checks/visa.hpp | 2
   sandbox/SOC/2011/checks/boost/checks/weight.hpp | 6 ++--
   5 files changed, 61 insertions(+), 48 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-06 09:31:29 EST (Mon, 06 Feb 2012)
@@ -1,5 +1,5 @@
 // Boost checks/amex.hpp header file
-// (C) Copyright Pierre Talbot 2011
+// (C) Copyright Pierre Talbot 2011 - 2012
 // Distributed under the Boost Software License, Version 1.0. (See
 // accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt
@@ -63,6 +63,25 @@
   }
 };
 
+template <std::size_t checkdigit_size>
+struct amex_filter
+{
+ std::size_t value_pos;
+
+ amex_filter() : value_pos(0){}
+
+ template <typename value_type>
+ bool operator()(const value_type &x)
+ {
+ const unsigned int real_pos_from_left = AMEX_SIZE - value_pos - checkdigit_size;
+
+ if(real_pos_from_left == 1 && x != 3)
+ throw std::invalid_argument("The Major Industry Identifier of an American Express should be 3!");
+ else if(real_pos_from_left == 2 && x != 4 && x != 7)
+ throw std::invalid_argument("The Issuer Identification Number of an American Express should be 34 or 37!");
+ }
+};
+
 /*!
   \brief This is the type of the Amex algorithm for validating a check digit.
 */

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 09:31:29 EST (Mon, 06 Feb 2012)
@@ -23,6 +23,37 @@
 namespace boost {
   namespace checks{
 
+template <typename binary_function, typename counter_type>
+struct counter_increaser
+{
+ binary_function &f;
+ counter_type &c;
+
+ counter_increaser(binary_function &f, counter_type &c) : f(f), c(c) {}
+
+ std::size_t operator()(std::size_t value, std::size_t checksum)
+ {
+ checksum = f(value, checksum);
+ ++c;
+ return checksum;
+ }
+};
+
+template <typename binary_function,
+ typename seq_iterator>
+std::size_t checksum(seq_iterator begin, seq_iterator end, binary_function &checksum_operation)
+{
+ return std::accumulate(seq_begin, seq_end, std::size_t(), checksum_operation);
+}
+
+template <typename binary_function,
+ typename counter_type,
+ typename seq_iterator>
+std::size_t checksum(seq_iterator begin, seq_iterator end, binary_function &checksum_operation, counter_type &counter)
+{
+
+}
+
 
 namespace detail
 {

Modified: sandbox/SOC/2011/checks/boost/checks/lexical_filter.hpp
==============================================================================
--- sandbox/SOC/2011/checks/boost/checks/lexical_filter.hpp (original)
+++ sandbox/SOC/2011/checks/boost/checks/lexical_filter.hpp 2012-02-06 09:31:29 EST (Mon, 06 Feb 2012)
@@ -6,7 +6,8 @@
 // See http://www.boost.org for updates, documentation, and revision history.
 
 /*! \file
- \brief Provides type encapsulated cctype functions and more for checking sequence.
+ \brief Provides functions specific for checking sequences.
+std::ptr_fun to use all the cctype header functions.
 */
 
 #ifndef BOOST_CHECKS_LEXICAL_FILTER_HPP
@@ -21,54 +22,16 @@
 
 namespace boost{
   namespace checks{
-
-/* Check if character is alphanumeric.
-*/
-template <typename value_type>
-struct isalnum : public std::unary_function<value_type, bool>
-{
- bool operator()(const value_type &x)
- {
- return std::isalnum(x);
- }
-};
+
 
 /* Check if character is decimal digit plus the special character 'X' (often occurs
 as check digit instead of 10).
 */
 template <typename value_type>
-struct isdigitx : public std::unary_function<value_type, bool>
-{
- bool operator()(const value_type &x)
- {
- return isdigit(x) || x == 'x' || x == 'X';
- }
-};
-
-/*
-Check if character is alphabetic.
-*/
-template <typename value_type>
-struct isalpha : public std::unary_function<value_type, bool>
-{
- bool operator()(const value_type &x)
- {
- return isalpha(x);
- }
-};
-
-/*
-Check if character is decimal digit.
-*/
-template <typename value_type>
-struct isdigit : public std::unary_function<value_type, bool>
+bool isdigitx(const value_type &x)
 {
- bool operator()(const value_type &x)
- {
- return isdigit(x);
- }
-};
-
+ return isdigit(x) || x == 'x' || x == 'X';
+}
 
   
 }} // namespace boost namespace checks

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-06 09:31:29 EST (Mon, 06 Feb 2012)
@@ -101,7 +101,7 @@
     \throws std::invalid_argument if the first digit(from the leftmost)doESn't match the Visa pattern.
     \throws boost::checks::translation_exception if the check digit cannot be translated into the checkdigit type.
 
- \returns The check digit. The check digit is in the range [0..9].
+ \returns The check digit. The check digit its in the range [0..9].
 */
 template <typename check_range>
 typename boost::range_value<check_range>::type compute_visa(const check_range& check_seq)

Modified: sandbox/SOC/2011/checks/boost/checks/weight.hpp
==============================================================================
--- sandbox/SOC/2011/checks/boost/checks/weight.hpp (original)
+++ sandbox/SOC/2011/checks/boost/checks/weight.hpp 2012-02-06 09:31:29 EST (Mon, 06 Feb 2012)
@@ -52,10 +52,10 @@
   template<BOOST_PP_ENUM_PARAMS(weight_size , int weight_value)> \
   struct weight<BOOST_PP_ENUM_PARAMS(weight_size, weight_value)> \
   { \
- static int weight_associated_with_pos(const unsigned int value_pos) \
+ static int at(const unsigned int value_pos) \
     { \
- static const int weights[weight_size] = { BOOST_PP_ENUM_PARAMS(weight_size, weight_value) } ; \
- return weights[value_pos % weight_size] ; \
+ static const int weights[weight_size] = { BOOST_PP_ENUM_PARAMS(weight_size, weight_value) }; \
+ return weights[value_pos % weight_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