Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r83166 - in sandbox/SOC/2011/checks: boost/checks libs/checks/doc libs/checks/example
From: pierre.talbot.6114_at_[hidden]
Date: 2013-02-26 13:50:38


Author: trademark
Date: 2013-02-26 13:50:36 EST (Tue, 26 Feb 2013)
New Revision: 83166
URL: http://svn.boost.org/trac/boost/changeset/83166

Log:
Add size checking documentation.
Update example and documentation.
Text files modified:
   sandbox/SOC/2011/checks/boost/checks/size_check.hpp | 4
   sandbox/SOC/2011/checks/libs/checks/doc/checks.qbk | 6 +
   sandbox/SOC/2011/checks/libs/checks/doc/extending_library.qbk | 4
   sandbox/SOC/2011/checks/libs/checks/doc/reference.qbk | 140 +++++++++++++++++++++++++++++++++++----
   sandbox/SOC/2011/checks/libs/checks/example/rtn.hpp | 13 ---
   sandbox/SOC/2011/checks/libs/checks/example/vin.hpp | 13 ---
   6 files changed, 139 insertions(+), 41 deletions(-)

Modified: sandbox/SOC/2011/checks/boost/checks/size_check.hpp
==============================================================================
--- sandbox/SOC/2011/checks/boost/checks/size_check.hpp (original)
+++ sandbox/SOC/2011/checks/boost/checks/size_check.hpp 2013-02-26 13:50:36 EST (Tue, 26 Feb 2013)
@@ -31,12 +31,12 @@
   static void fail(){}
 };
 
-template <class Exception = size_failure_exception>
+template <class FailureException = size_failure_exception>
 struct size_failure_exception_policy
 {
   static void fail()
   {
- throw Exception;
+ throw FailureException;
   }
 };
 

Modified: sandbox/SOC/2011/checks/libs/checks/doc/checks.qbk
==============================================================================
--- sandbox/SOC/2011/checks/libs/checks/doc/checks.qbk (original)
+++ sandbox/SOC/2011/checks/libs/checks/doc/checks.qbk 2013-02-26 13:50:36 EST (Tue, 26 Feb 2013)
@@ -68,6 +68,12 @@
 [def __CHECKDIGITX_ENCODER__ [link checks.checks.reference.checkdigit.checkdigitx_encoder checkdigitx_encoder]]
 [def __CHECKDIGIT_REF__ [link checks.checks.reference.checkdigit.checkdigitref checkdigit]]
 
+[def __SIZE_CHECKING__ [link checks.checks.reference.size_checking size_checking]]
+[def __NO_SIZE_CHECKING__ [link checks.checks.reference.no_size_checking no_size_checking]]
+[def __SIZE_FAILURE_ERROR_CODE_POLICY__ [link checks.checks.reference.size_failure_error_code_policy size_failure_error_code_policy]]
+[def __SIZE_FAILURE_EXCEPTION_POLICY__ [link checks.checks.reference.size_failure_exception_policy size_failure_exception_policy]]
+[def __SIZE_FAILURE_EXCEPTION__ [link checks.checks.reference.size_failure_exception size_failure_exception]]
+
 [def __TRAVERSAL_TYPE__ [link checks.checks.reference.traversal_type Traversal type]]
 
 [def __overview [link checks.checks.preface Preface]]

Modified: sandbox/SOC/2011/checks/libs/checks/doc/extending_library.qbk
==============================================================================
--- sandbox/SOC/2011/checks/libs/checks/doc/extending_library.qbk (original)
+++ sandbox/SOC/2011/checks/libs/checks/doc/extending_library.qbk 2013-02-26 13:50:36 EST (Tue, 26 Feb 2013)
@@ -126,8 +126,8 @@
 
 The sequence size is important here. The VIN must exactly be composed of 17 digits.
 But what are we doing if the sequence is not of exactly 17 digits ? You can return an
-error code or send an exception. The policy used return an error code (or simply
-false if you validate).
+error code or send an exception. The default policy used with `size_checking` return
+an error code (or simply false if you validate).
 
 [vin_size]
 

Modified: sandbox/SOC/2011/checks/libs/checks/doc/reference.qbk
==============================================================================
--- sandbox/SOC/2011/checks/libs/checks/doc/reference.qbk (original)
+++ sandbox/SOC/2011/checks/libs/checks/doc/reference.qbk 2013-02-26 13:50:36 EST (Tue, 26 Feb 2013)
@@ -380,20 +380,127 @@
 
 [endsect][/section:checkdigit Check digit]
 
-[section:traversal_type no_size_checking]
-[endsect][/section:traversal_type no_size_checking]
-
-[section:traversal_type size_checking]
-[endsect][/section:traversal_type size_checking]
-
-[section:traversal_type size_failure_error_code_policy]
-[endsect][/section:traversal_type size_failure_error_code_policy]
-
-[section:traversal_type size_failure_exception_policy]
-[endsect][/section:traversal_type size_failure_exception_policy]
-
-[section:traversal_type size_failure_exception]
-[endsect][/section:traversal_type size_failure_exception]
+[section:no_size_checking no_size_checking]
+[h3 Synopsis]
+``
+struct no_size_checking{};
+``
+[h3 Description]
+
+This tag can be used in the `checksum` structure if the algorithm doesn't need any size checking.
+
+[h3 Header]
+``
+#include <boost/checks/size_check.hpp>
+``
+
+[h3 See also]
+__SIZE_CHECKING__, __CHECKSUM_REF__.
+
+[endsect][/section:no_size_checking no_size_checking]
+
+[section:size_checking size_checking]
+[h3 Synopsis]
+``
+template <size_t N, class SizeFailurePolicy = size_failure_error_code_policy>
+struct size_checking
+{
+ /* unspecified */
+};
+``
+[h3 Description]
+
+This tag can be used in the `checksum` structure if you want to restrict the size of the sequence.
+If the size is not respected then the failure policy is called.
+
+[h3 Header]
+``
+#include <boost/checks/size_check.hpp>
+``
+
+[h3 Template parameters]
+
+* [*N] is the expected size of the check sequence.
+* [*SizeFailurePolicy] is a policy describing the behavior if the size is not respected. The [*default] policy is __SIZE_FAILURE_ERROR_CODE_POLICY__.
+
+[h3 See also]
+__NO_SIZE_CHECKING__, __SIZE_FAILURE_ERROR_CODE_POLICY__, __SIZE_FAILURE_EXCEPTION_POLICY__, __CHECKSUM_REF__.
+
+[endsect][/section:size_checking size_checking]
+
+[section:size_failure_error_code_policy size_failure_error_code_policy]
+[h3 Synopsis]
+``
+struct size_failure_error_code_policy
+{
+ /* unspecified */
+};
+``
+[h3 Description]
+
+This policy tell the check algorithm to return an error code if the size contract is not respected. The error code doesn't describe the type of the error. It must be use inside __SIZE_CHECKING__.
+
+[h3 Header]
+``
+#include <boost/checks/size_check.hpp>
+``
+
+[h3 See also]
+__SIZE_CHECKING__, __SIZE_FAILURE_CODE_ERROR_POLICY__, __CHECKSUM_REF__.
+
+[endsect][/section:size_failure_error_code_policy size_failure_error_code_policy]
+
+[section:size_failure_exception_policy size_failure_exception_policy]
+[h3 Synopsis]
+``
+template <class FailureException = size_failure_exception>
+struct size_failure_exception_policy
+{
+ /* unspecified */
+};
+``
+[h3 Description]
+
+This policy tell the check algorithm to launch an exception if the size contract is not respected. It must be use inside __SIZE_CHECKING__.
+
+[h3 Header]
+``
+#include <boost/checks/size_check.hpp>
+``
+
+[h3 Template paramater]
+
+[*FailureException] is the exception to be launch in case of failure. The [*default] exception is __SIZE_FAILURE_EXCEPTION__.
+
+[h3 See also]
+__SIZE_FAILURE_EXCEPTION__, __SIZE_CHECKING__, __SIZE_FAILURE_EXCEPTION_POLICY__, __CHECKSUM_REF__.
+
+[endsect][/section:size_failure_exception_policy size_failure_exception_policy]
+
+[section:size_failure_exception size_failure_exception]
+[h3 Synopsis]
+``
+class size_failure_exception : public std::exception
+{
+public:
+ virtual const char * what() const throw()
+ {
+ return "Unexpected size of the sequence.";
+ }
+};
+``
+[h3 Description]
+
+This exception is used with __SIZE_FAILURE_EXCEPTION_POLICY__ and launched when the size contract is not respected.
+
+[h3 Header]
+``
+#include <boost/checks/size_check.hpp>
+``
+
+[h3 See also]
+__SIZE_FAILURE_EXCEPTION_POLICY__.
+[endsect][/section:size_failure_exception size_failure_exception]
 
 [section:traversal_type Traversal type]
 [endsect][/section:traversal_type Traversal type]
@@ -404,4 +511,7 @@
 [section:type_adaptor Type adaptor]
 [endsect][/section:type_adaptor Type adaptor]
 
-[endsect][/section:reference Reference]
\ No newline at end of file
+[section:checksum_ref checksum]
+[endsect][/section:checksum_ref checksum]
+
+[endsect][/section:reference Reference]
\ No newline at end of file

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-02-26 13:50:36 EST (Tue, 26 Feb 2013)
@@ -1,13 +1,4 @@
-// rtn.hpp
-//! \file
-//! \brief Check and compute the Routing Transit Number(RTN)
-//! as an example of implementing a new checksum type.
-/*! \detail Routing Transit Number
- http://en.wikipedia.org/wiki/Routing_transit_number
-*/
-
-// Copyright Pierre Talbot 2011.
-
+// Copyright Pierre Talbot 2011-2013.
 // Use, modification and distribution are subject to the
 // Boost Software License, Version 1.0.
 //(See accompanying file LICENSE_1_0.txt
@@ -31,7 +22,7 @@
 
 //[rtn_checksum
 #define RTN_SIZE 9
-typedef strict_size_policy<RTN_SIZE> rtn_size;
+typedef size_checking<RTN_SIZE> rtn_size;
 typedef weighted_sum<weight<3,7,1> > rtn_processor;
 
 typedef checksum

Modified: sandbox/SOC/2011/checks/libs/checks/example/vin.hpp
==============================================================================
--- sandbox/SOC/2011/checks/libs/checks/example/vin.hpp (original)
+++ sandbox/SOC/2011/checks/libs/checks/example/vin.hpp 2013-02-26 13:50:36 EST (Tue, 26 Feb 2013)
@@ -1,13 +1,4 @@
-// vin.hpp
-//! \file
-//! \brief Check and compute the Vehicle Identification Number.
-//! This is an example of extending the library for a new checksum type.
-/*! \detail Vehicle Identification Number
- http://en.wikipedia.org/wiki/Vehicle_Identification_Number
-*/
-
-// Copyright Pierre Talbot 2011.
-
+// Copyright Pierre Talbot 2011-2013.
 // Use, modification and distribution are subject to the
 // Boost Software License, Version 1.0.
 //(See accompanying file LICENSE_1_0.txt
@@ -62,7 +53,7 @@
 //[vin_size
 #define VIN_SIZE 17
 
-typedef strict_size_policy<VIN_SIZE> vin_size;
+typedef size_checking<VIN_SIZE> vin_size;
 //]
 
 //[vin_processor


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