Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r73809 - sandbox/SOC/2011/checks/boost/checks
From: pierre.talbot.6114_at_[hidden]
Date: 2011-08-16 05:40:10


Author: trademark
Date: 2011-08-16 05:40:09 EDT (Tue, 16 Aug 2011)
New Revision: 73809
URL: http://svn.boost.org/trac/boost/changeset/73809

Log:
Factoring the code and using a general check algorithm structure, currently inherited by weighted_sum_algorithm and verhoeff.
Added:
   sandbox/SOC/2011/checks/boost/checks/basic_check_algorithm.hpp (contents, props changed)

Added: sandbox/SOC/2011/checks/boost/checks/basic_check_algorithm.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2011/checks/boost/checks/basic_check_algorithm.hpp 2011-08-16 05:40:09 EDT (Tue, 16 Aug 2011)
@@ -0,0 +1,44 @@
+// Boost checks/weighted_sum.hpp header file ------------------------------------//
+// (C) Copyright Pierre Talbot 2011
+// 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
+// See http://www.boost.org for updates, documentation, and revision history.
+
+#ifndef BOOST_CHECKS_BASIC_CHECK_ALGO_HPP
+#define BOOST_CHECKS_BASIC_CHECK_ALGO_HPP
+
+#include <boost/lexical_cast.hpp>
+#include <boost/checks/traduction_exception.hpp>
+#include <boost/checks/iteration_sense.hpp>
+
+namespace boost{
+ namespace checks{
+
+template <typename iteration_sense, unsigned int number_of_virtual_value_skipped = 0>
+struct basic_check_algorithm
+{
+ typedef iteration_sense iteration_sense ;
+
+ template <typename value>
+ static int traduce_to_valid_value(const value &current_value, const unsigned int valid_value_counter )
+ {
+ int valid_value = 0;
+ try{
+ valid_value = boost::lexical_cast<int>( current_value ) ;
+ }catch( boost::bad_lexical_cast ){
+ throw boost::checks::traduction_exception() ;
+ }
+ return valid_value ;
+ }
+
+ template <typename check_range>
+ struct checkdigit
+ {
+ typedef typename boost::range_value<check_range>::type type;
+ };
+};
+
+
+}}
+#endif //BOOST_CHECKS_BASIC_CHECK_ALGO_HPP
\ No newline at end of file


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