|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r73967 - sandbox/SOC/2011/checks/libs/checks/example
From: pierre.talbot.6114_at_[hidden]
Date: 2011-08-20 19:22:06
Author: trademark
Date: 2011-08-20 19:22:05 EDT (Sat, 20 Aug 2011)
New Revision: 73967
URL: http://svn.boost.org/trac/boost/changeset/73967
Log:
Extending the library, first example with the Routing Transit Number.
Added:
sandbox/SOC/2011/checks/libs/checks/example/rtn.hpp (contents, props changed)
Added: sandbox/SOC/2011/checks/libs/checks/example/rtn.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2011/checks/libs/checks/example/rtn.hpp 2011-08-20 19:22:05 EDT (Sat, 20 Aug 2011)
@@ -0,0 +1,46 @@
+//! \file rtn.hpp
+//! \brief Check and compute the Routing Transit Number (RTN) for example purpose.
+
+// Copyright Pierre Talbot 2011.
+
+// Use, modification and distribution are subject to 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)
+
+#ifndef BOOST_CHECKS_RTN_HPP
+#define BOOST_CHECKS_RTN_HPP
+
+//[rtn_include_files
+#include <boost/checks/modulus10.hpp>
+#include <boost/checks/basic_checks.hpp>
+//]
+
+//[rtn_preprocessor_tools
+#define RTN_SIZE 9
+#define RTN_SIZE_WITHOUT_CHECKDIGIT 8
+
+typedef boost::checks::weight<3,7,1> rtn_weight ;
+typedef boost::checks::leftmost rtn_sense ;
+//]
+
+//[rtn_preprocessor_algorithm
+typedef boost::checks::modulus10_algorithm < rtn_weight, rtn_sense, 0> rtn_check_algorithm ;
+typedef boost::checks::modulus10_algorithm < rtn_weight, rtn_sense, 0> rtn_compute_algorithm ;
+//]
+
+//[rtn_functions
+template <typename check_range>
+bool check_rtn (const check_range& check_seq)
+{
+ return boost::checks::check_sequence<rtn_check_algorithm, RTN_SIZE> ( check_seq ) ;
+}
+
+template <typename check_range>
+typename rtn_compute_algorithm::checkdigit<check_range>::type compute_rtn (const check_range& check_seq)
+{
+ return boost::checks::compute_checkdigit<rtn_compute_algorithm, RTN_SIZE_WITHOUT_CHECKDIGIT> ( check_seq ) ;
+}
+//]
+
+#endif
\ 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