|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r82458 - sandbox/SOC/2011/checks/libs/checks/example
From: pierre.talbot.6114_at_[hidden]
Date: 2013-01-12 04:28:35
Author: trademark
Date: 2013-01-12 04:28:33 EST (Sat, 12 Jan 2013)
New Revision: 82458
URL: http://svn.boost.org/trac/boost/changeset/82458
Log:
Update the RTN example.
Update the example of the RTN.
Text files modified:
sandbox/SOC/2011/checks/libs/checks/example/checks_tutorial.cpp | 23 ++++++++++++-----------
sandbox/SOC/2011/checks/libs/checks/example/jamfile.v2 | 2 +-
sandbox/SOC/2011/checks/libs/checks/example/rtn.hpp | 32 +++++++++++++++++++++++---------
3 files changed, 36 insertions(+), 21 deletions(-)
Modified: sandbox/SOC/2011/checks/libs/checks/example/checks_tutorial.cpp
==============================================================================
--- sandbox/SOC/2011/checks/libs/checks/example/checks_tutorial.cpp (original)
+++ sandbox/SOC/2011/checks/libs/checks/example/checks_tutorial.cpp 2013-01-12 04:28:33 EST (Sat, 12 Jan 2013)
@@ -29,25 +29,26 @@
// Files containing the 'new' checksum definitions.
#include "rtn.hpp"
-#include "vin.hpp"
+//#include "vin.hpp"
int main()
{
+ using namespace boost::checks;
//[rtn_example
- std::string rtn_number = "111000025" ;
- if ( check_rtn ( rtn_number ) )
- std::cout << "The Routing Transit Number: " << rtn_number << " is valid." << std::endl ;
- rtn_number = "11100002";
- std::cout << "The check digit of the number: " << rtn_number << " is " << compute_rtn (rtn_number ) << "." << std::endl ;
+ std::string rtn = "111000025";
+ if(check_rtn(rtn))
+ std::cout << "The Routing Transit Number (RTN) \"" << rtn << "\" is valid." << std::endl;
+ rtn = "11100002";
+ std::cout << "The check digit of \"" << rtn << "\" is " << compute_rtn(rtn) << "." << std::endl;
//]
//[vin_example
- std::string vin_number = "1M8GDM9AXKP042788";
- if ( check_vin ( vin_number ) )
- std::cout << "The Vehicle Identification Number: " << vin_number << " is correct." << std::endl ;
+ /*std::string vin = "1M8GDM9AXKP042788";
+ if(check_vin(vin))
+ std::cout << "The Vehicle Identification Number (VIN) \"" << vin << "\" is valid." << std::endl;
- vin_number = "1M8GDM9AKP042788" ;
- std::cout << "The check digit of " << vin_number << " is " << compute_vin ( vin_number) << std::endl ;
+ vin = "1M8GDM9AKP042788";
+ std::cout << "The check digit of \"" << vin << "\" is " << compute_vin(vin) << std::endl;*/
//]
return 0;
}
Modified: sandbox/SOC/2011/checks/libs/checks/example/jamfile.v2
==============================================================================
--- sandbox/SOC/2011/checks/libs/checks/example/jamfile.v2 (original)
+++ sandbox/SOC/2011/checks/libs/checks/example/jamfile.v2 2013-01-12 04:28:33 EST (Sat, 12 Jan 2013)
@@ -29,5 +29,5 @@
;
run checks_examples.cpp ; # Example of some function in Boost.Checks.
-#run checks_tutorial.cpp ; # Examples for the "Extending the library" section of the tutorial.
+run checks_tutorial.cpp ; # Examples for the "Extending the library" section of the tutorial.
Modified: sandbox/SOC/2011/checks/libs/checks/example/rtn.hpp
==============================================================================
--- sandbox/SOC/2011/checks/libs/checks/example/rtn.hpp (original)
+++ sandbox/SOC/2011/checks/libs/checks/example/rtn.hpp 2013-01-12 04:28:33 EST (Sat, 12 Jan 2013)
@@ -17,36 +17,50 @@
#define BOOST_CHECKS_RTN_HPP
//[rtn_include_files
+#include <cstddef>
#include <boost/checks/modulus10.hpp>
-#include <boost/checks/basic_checks.hpp>
+#include <boost/checks/checksum.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
//]
//[rtn_preprocessor_tools
#define RTN_SIZE 9
-#define RTN_SIZE_WITHOUT_CHECKDIGIT 8
-typedef boost::checks::weight<3,7,1> rtn_weight;
+namespace boost{
+namespace checks{
+
+typedef weighted_sum<weight<3,7,1> > rtn_processor;
//]
//[rtn_preprocessor_algorithm
-typedef boost::checks::modulus10_algorithm<rtn_weight, 0> rtn_check_algorithm;
-typedef boost::checks::modulus10_algorithm<rtn_weight, 0> rtn_compute_algorithm;
+typedef checksum
+<
+ rtn_processor,
+ mod10_validation,
+ mod10_checkdigit
+> rtn_checksum;
+
+typedef features
+<
+ rtn_checksum,
+ RTN_SIZE
+> rtn;
+
//]
//[rtn_functions
template <typename check_range>
bool check_rtn(const check_range& check_seq)
{
- return boost::checks::check_sequence<rtn_check_algorithm, RTN_SIZE>(boost::begin(check_seq), boost::end(check_seq));
+ return check_sequence<rtn>(check_seq);
}
template <typename check_range>
-typename rtn_compute_algorithm::checkdigit<check_range>::type compute_rtn(const check_range& check_seq)
+size_t compute_rtn(const check_range& check_seq)
{
- return boost::checks::compute_checkdigit<rtn_compute_algorithm, RTN_SIZE_WITHOUT_CHECKDIGIT>(boost::begin(check_seq), boost::end(check_seq));
+ return compute_checkdigit<rtn>(check_seq);
}
//]
-
+}}
#endif
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