|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r76911 - sandbox/SOC/2011/checks/boost/checks
From: pierre.talbot.6114_at_[hidden]
Date: 2012-02-06 12:29:08
Author: trademark
Date: 2012-02-06 12:29:07 EST (Mon, 06 Feb 2012)
New Revision: 76911
URL: http://svn.boost.org/trac/boost/changeset/76911
Log:
Introduce the skipping predicate. bool skip(value_type value). We skip dash, space, and everything that not useful.
Text files modified:
sandbox/SOC/2011/checks/boost/checks/basic_check_algorithm.hpp | 6 ++++++
sandbox/SOC/2011/checks/boost/checks/basic_checks.hpp | 13 ++++++++-----
sandbox/SOC/2011/checks/boost/checks/modulus11.hpp | 6 ++++++
3 files changed, 20 insertions(+), 5 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 12:29:07 EST (Mon, 06 Feb 2012)
@@ -34,6 +34,12 @@
template <std::size_t checkdigit_size>
struct basic_check_algorithm
{
+ template <typename value_type>
+ static bool skip(const value_type &value)
+ {
+ return !isdigit(value);
+ }
+
/*!
\brief translate a value of the sequence into an integer valid value.
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 12:29:07 EST (Mon, 06 Feb 2012)
@@ -65,11 +65,14 @@
{
try
{
- 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);
- checksum = algorithm::process(checksum, value, value_counter);
- ++value_counter;
+ if(!algorithm::skip(*seq_begin))
+ {
+ 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);
+ checksum = algorithm::process(checksum, value, value_counter);
+ ++value_counter;
+ }
}
catch(boost::checks::translation_exception){
}
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-06 12:29:07 EST (Mon, 06 Feb 2012)
@@ -41,6 +41,12 @@
struct modulus11_algorithm : boost::checks::weighted_sum_algorithm<mod11_weight, checkdigit_size>
{
+ template <typename value_type>
+ static bool skip(const value_type &value)
+ {
+ return !isdigit(value) && value != 'x' && value != 'X';
+ }
+
/*!
\brief translate the current value into an integer valid value.
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