Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r73749 - sandbox/SOC/2011/checks/boost/checks
From: pierre.talbot.6114_at_[hidden]
Date: 2011-08-14 13:12:24


Author: trademark
Date: 2011-08-14 13:12:23 EDT (Sun, 14 Aug 2011)
New Revision: 73749
URL: http://svn.boost.org/trac/boost/changeset/73749

Log:
Simple modulus 97 algorithm. Should be the base of other check like the IBAN check.
Added:
   sandbox/SOC/2011/checks/boost/checks/modulus97.hpp (contents, props changed)

Added: sandbox/SOC/2011/checks/boost/checks/modulus97.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2011/checks/boost/checks/modulus97.hpp 2011-08-14 13:12:23 EDT (Sun, 14 Aug 2011)
@@ -0,0 +1,37 @@
+// Boost checks/modulus97.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_MOD97_HPP
+#define BOOST_CHECKS_MOD97_HPP
+
+#include <boost/preprocessor/repetition.hpp>
+#include <boost/checks/weight.hpp>
+
+namespace boost{
+ namespace checks{
+
+
+template <unsigned int weight_value>
+struct _mod97_weight
+{
+ static const unsigned int value = weight_value ;
+ typedef _mod97_weight<weight_value * 10 % 97> next ;
+};
+template<>
+struct _mod97_weight<68>
+{
+ static const unsigned int value = 68 ;
+ typedef _mod97_weight type ;
+};
+
+#define _next(z,n,unused) next::
+#define _MOD97_make_weight(z, n ,unused) _mod97_weight<1>::BOOST_PP_REPEAT(n, _next, ~)value
+typedef boost::checks::weight< BOOST_PP_ENUM(96, _MOD97_make_weight, ~) > mod97_weight ;
+
+}}
+
+#endif //BOOST_CHECKS_MOD97_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