Boost logo

Boost-Commit :

From: dwalker07_at_[hidden]
Date: 2008-08-10 13:49:38


Author: dlwalker
Date: 2008-08-10 13:49:37 EDT (Sun, 10 Aug 2008)
New Revision: 48063
URL: http://svn.boost.org/trac/boost/changeset/48063

Log:
Removed remnants of old methodology
Removed:
   sandbox/md5/boost/coding/operations.hpp
Text files modified:
   sandbox/md5/boost/coding/md5.hpp | 536 ---------------------------------------
   sandbox/md5/boost/coding_fwd.hpp | 20 -
   sandbox/md5/libs/coding/src/md5.cpp | 245 +----------------
   3 files changed, 32 insertions(+), 769 deletions(-)

Modified: sandbox/md5/boost/coding/md5.hpp
==============================================================================
--- sandbox/md5/boost/coding/md5.hpp (original)
+++ sandbox/md5/boost/coding/md5.hpp 2008-08-10 13:49:37 EDT (Sun, 10 Aug 2008)
@@ -6,8 +6,7 @@
 
     Contains the declaration of types and functions used for computing MD5
     message digests of given data blocks and granting I/O capability to any
- applicable types. Non-inline items declared here are defined in
- "$BOOST_ROOT/libs/coding/src/md5.cpp".
+ applicable types.
  
     (C) Copyright Daryle Walker 2008. Distributed under the Boost Software
     License, Version 1.0. (See the accompanying file LICENSE_1_0.txt or a copy
@@ -20,32 +19,10 @@
 
 #include <boost/coding_fwd.hpp>
 #include <boost/coding/md5_digest.hpp> // for boost::coding::md5_digest
-#include <boost/coding/md5_context.hpp> // for boost::coding::md5_context
+#include <boost/coding/md5_context.hpp> // for b:c:md5_context (for grouping)
 #include <boost/coding/md5_computer.hpp> // for boost::coding::md5_computer
 
-#include <boost/array.hpp> // for boost::array
-#include <boost/assert.hpp> // for BOOST_ASSERT
-#include <boost/coding/coding_shell.hpp> // for b:c:bit_coding_shell
-#include <boost/coding/operations.hpp> // for b:c:queued_bit_processing_base
-#include <boost/concept/assert.hpp> // for BOOST_CONCEPT_ASSERT
-#include <boost/concept_check.hpp> // for boost::OutputIterator
-#include <boost/cstdint.hpp> // for boost::uint_least8_t, etc.
-#include <boost/integer.hpp> // for boost::sized_integral, etc.
-#include <boost/integer/integer_mask.hpp> // for boost::integer_lo_mask
-#include <boost/mpl/arithmetic.hpp> // for boost::mpl::times
-#include <boost/mpl/int.hpp> // for boost::mpl::int_
-#include <boost/mpl/size_t.hpp> // for boost::mpl::size_t
-#include <boost/serialization/access.hpp> // for boost::serialization::access
-#include <boost/static_assert.hpp> // for BOOST_STATIC_ASSERT
-#include <boost/typeof/typeof.hpp> // for BOOST_AUTO
-
-#include <algorithm> // for std::equal, swap
-#include <climits> // for CHAR_BIT
-#include <cstddef> // for std::size_t
-#include <ios> // for std::ios_base
-#include <istream> // for std::basic_istream
-#include <locale> // for std::use_facet, ctype
-#include <ostream> // for std::basic_ostream
+#include <cstddef> // for std::size_t
 
 
 namespace boost
@@ -54,504 +31,6 @@
 {
 
 
-// Forward declarations ----------------------------------------------------//
-
-// None right now
-
-
-// MD5 message-digest computation class declaration ------------------------//
-
-/** \brief A class for generating a MD5 message digest from submitted data.
-
- This class can accept data in several runs and produce a hash based on that
- data from the MD5 message-digest algorithm described in RFC 1321. It should
- have a similar interface to Boost.CRC, plus specialized function object
- interfaces for bit- and byte-level processing (inspired by Boost.Bimap).
- Comparisons are supported for check-summing purposes, but not ordering.
- Persistence is supported though Boost.Serialization.
-
- \see boost::coding::md5_digest
- \see boost::coding::compute_md5(void const*,std::size_t)
-
- \todo Replace "uint_fast64_t" with "uint_t&lt;significant_bits_per_length&gt;::
- fast", where "significant_bits_per_length" is 64. (Need to tweak
- Boost.Integer to support 64-bit types.) Also need to make a
- convienent constant for the "16" in the base class declaration.
- (It's the number of words per block, from RFC 1321, section 3.4.)
- \todo The implementation base class was originally inherited privately, but
- the core member functions would give access errors when needed. The
- solution, for now, was either make \e all the base classes (direct
- and indirect) friends of this class, or change the inheritance to
- either public or protected. I haven't figured out why yet, or how to
- switch back to private inheritance without needing to add friendship.
- (Furthermore, I couldn't use \c base_type to establish friendship;
- i.e., both "friend base_type" and "friend class base_type" didn't
- work. I don't know why either.)
- */
-class md5_computerX
- : protected queued_bit_processing_base<md5_computerX, uint_fast64_t, 16u *
- md5_digest::bits_per_word::value>
-{
- typedef queued_bit_processing_base<md5_computerX, uint_fast64_t, 16u *
- md5_digest::bits_per_word::value> base_type;
-
- friend void base_type::process_bit( bool ); // needs "update_hash" access
-
- // Implementation constants, followed by sanity checks
- static std::size_t const words_per_block = base_type::queue_length /
- md5_digest::bits_per_word::value;
-
- BOOST_STATIC_ASSERT( (base_type::queue_length % md5_digest::bits_per_word::value)
- == 0u );
- BOOST_STATIC_ASSERT( words_per_block == 16u ); // RFC 1321, section 3.4
-
-public:
- // Special application interface
- using base_type::bits;
- using base_type::bytes;
-
- // Constants
- //! Number of bits for length quantities
- static int const significant_bits_per_length = 2 *
- md5_digest::bits_per_word::value;
- //! Number of bits in hash queue
- static std::size_t const bits_per_block = base_type::queue_length;
-
- //! Hashing sine table
- static array<md5_digest::word_type, 64> const hashing_table;
-
- // Types
- /** \brief Type of checksums
-
- Represents the type of hashes generated by this type.
- */
- typedef md5_digest value_type;
- /** \brief Type of size values
-
- Represents the type used for sizing parameters and returns. It should
- be an unsigned integer.
- */
- typedef base_type::size_type size_type;
-
- /** \brief Type of MD message lengths
-
- Represents the type needed to store the significant count of bits read.
- */
- typedef uint_least64_t length_type;
- // replace w/ uint_t<significant_bits_per_length>::least
- /** \brief Type of MD buffers
-
- Represents the intermediate MD buffer, holding the checksum for all
- prior \e completed hashed blocks. The zero-index corresponds to the "A"
- register, up to index 3 representing the "D" register.
- */
- typedef array<md5_digest::word_type, md5_digest::words_per_digest::value>
- buffer_type;
-
- // Lifetime management (use automatic destructor)
- //! Default construction
- md5_computerX();
- //! Copy construction
- md5_computerX( md5_computerX const &c );
-
- /*! \name Assignment */ //@{
- // Assignment
- //! Sets state back to initial conditions
- void reset();
- //! Changes the current state to a copy of another object's
- void assign( md5_computerX const &c );
-
- //! Exchanges state with another object
- void swap( md5_computerX &other );//@}
-
- /*! \name Inspection */ //@{
- // Inspectors
- //! Returns the count of bits read so far
- length_type bits_read() const;
- //! Returns the checksum buffer of hashed bits
- buffer_type last_buffer() const;
-
- using base_type::bits_unbuffered;
- using base_type::copy_unbuffered;//@}
-
- /*! \name Bit-stream reading */ //@{
- // Input processing
- using base_type::process_bit;
- using base_type::process_bits;
- using base_type::process_bit_copies;
- using base_type::process_byte;
- using base_type::process_byte_copies;
- using base_type::process_block;
- using base_type::process_bytes;
- using base_type::process_octet;
-
- //! Enters a word for hashing
- void process_word( md5_digest::word_type word );
- //! Enters a double-word for hashing
- void process_double_word( length_type dword );//@}
-
- /*! \name Message-digest writing */ //@{
- // Output processing
- //! Returns the message digest, assuming all bits have been hashed
- value_type checksum() const;//@}
-
- /*! \name Operators */ //@{
- // Operators
- //! Copy-assignment
- md5_computerX & operator =( md5_computerX const &c );
-
- //! Equals
- bool operator ==( md5_computerX const &c ) const;
- //! Not-equals
- bool operator !=( md5_computerX const &c ) const;
-
- //! Application
- value_type operator ()() const;//@}
-
- // Extras
- //! Creates a copy of #hashing_table using calculated, not static, values
- static array<md5_digest::word_type, 64> generate_hashing_table();
-
-private:
- // Bad if computers someday get so big that a byte overflows the queue!
- BOOST_STATIC_ASSERT( bits_per_block > CHAR_BIT );
-
- // State maintainence
- bool test_invariant() const { return true; } // Nothing special right now
-
- // Serialization
- friend class serialization::access;
-
- /*! \name Persistence */ //@{
- //! Enables persistence with Boost.Serialization-compatible archives
- template < class Archive >
- void serialize( Archive &ar, const unsigned int version );//@}
- // may have to do save/load split; support XML archives
-
- // Implementation functions
- void update_hash( bool const *queue_b, bool const *queue_e );
-
- // Implementation types
- typedef md5_computerX self_type;
-
- typedef uint_t<md5_digest::bits_per_word::value>::fast iword_type;
- typedef array<iword_type, md5_digest::words_per_digest::value> ibuffer_type;
-
- // (Computation) member data
- ibuffer_type buffer_;
-
- static ibuffer_type const initial_buffer_;
-
- friend class md5_context;
-
-}; // md5_computerX
-
-
-// MD5 message-digest computation constructor definitions ------------------//
-
-/** Constructs a \c md5_computerX set to initial conditions. That is, with the
- buffer initialized as in RFC 1321, section 3.3, and no bits counted as read
- or currently left to be hashed.
-
- \post <code>#bits_read() == 0</code>
- \post <code>#last_buffer() == { 0x67452301, 0xEFCDAB89, 0x98BACDFE,
- 0x10325476 }</code>
- \post <code>#copy_unbuffered(<var>o</var>)</code> leaves \p o unused
- \post \c #bits and \c #bytes point to \c *this
- */
-inline
-md5_computerX::md5_computerX()
- : base_type()
- , buffer_( self_type::initial_buffer_ )
-{
- BOOST_ASSERT( this->test_invariant() );
-}
-
-/** Constructs a \c md5_computerX to the same computation state as <var>c</var>.
-
- \param c The original object to be copied.
-
- \post <code>#bits_read() == <var>c</var>.bits_read()</code>
- \post <code>#last_buffer() == <var>c</var>.last_buffer()</code>
- \post Given <code>#copy_unbuffered(<var>o1</var>)</code> and
- <code><var>c</var>.copy_unbuffered(<var>o2</var>)</code>, where both
- \p o1 and \p o2 are random access iterators to different container
- segments that each have at least <code>#bits_unbuffered()</code>
- elements available, <code>std::equal( o1, o1 + bits_unbuffered(), o2
- ) == true</code>
- \post \c #bits and \c #bytes point to \c *this
- */
-inline
-md5_computerX::md5_computerX( md5_computerX const &c )
- : base_type( c )
- , buffer_( c.buffer_ )
-{
- BOOST_ASSERT( this->test_invariant() );
-}
-
-
-// MD5 message-digest computation inspector member function definitions ----//
-
-/** Returns the number of bits that have been processed, both those that have
- been hashed and those that are on queue. Only the low-order 64 bits of
- count are significant and kept/reliable.
-
- \return How many bits have been submitted, hashed and queued.
- */
-inline
-md5_computerX::length_type
-md5_computerX::bits_read() const
-{
- // Don't count any wrap-around past 2**64
- // (Use mask value once Boost.Integer is upped to 64-bit support)
- return this->base_type::bits_read() & 0xFFFFFFFFFFFFFFFFull;
-}
-
-/** Returns the checksum of all the bits that have been hashed so far. Hashing
- occurs only after every \c #bits_per_block bit entries, so check
- \c #bits_unbuffered() for any queued stragglers.
-
- \return The current state of the MD buffer, not counting any unhashed bits.
- */
-inline
-md5_computerX::buffer_type
-md5_computerX::last_buffer() const
-{
- // boost::array has no constructors (since it's POD), that means that if
- // buffer_type and ibuffer_type differ, we need to convert via assignment.
- buffer_type r;
-
- r = this->buffer_;
- return r;
-}
-
-
-// MD5 message-digest computation assignment member function definitions ---//
-
-/** Changes an object to be like it was default-constructed.
-
- \post <code>#bits_read() == 0</code>
- \post <code>#last_buffer() == { 0x67452301, 0xEFCDAB89, 0x98BACDFE,
- 0x10325476 }</code>
- \post <code>#copy_unbuffered(<var>o</var>)</code> leaves \p o unused
-
- \see #md5_computerX()
- */
-inline
-void
-md5_computerX::reset()
-{
- this->base_type::reset();
- this->buffer_ = self_type::initial_buffer_;
-
- BOOST_ASSERT( this->test_invariant() );
-}
-
-/** Changes an object to be like the given object. Only the computation
- elements are copied; no function object proxies are reseated.
-
- \param c The object with the new state to be copied.
-
- \post <code>#bits_read() == <var>c</var>.bits_read()</code>
- \post <code>#last_buffer() == <var>c</var>.last_buffer()</code>
- \post Given <code>#copy_unbuffered(<var>o1</var>)</code> and
- <code><var>c</var>.copy_unbuffered(<var>o2</var>)</code>, where both
- \p o1 and \p o2 are random access iterators to different container
- segments that each have at least <code>#bits_unbuffered()</code>
- elements available, <code>std::equal( o1, o1 + bits_unbuffered(), o2
- ) == true</code>
- \post \c #bits and \c #bytes \e still point to \c *this
-
- \see #md5_computerX(md5_computerX const&)
- */
-inline
-void
-md5_computerX::assign( md5_computerX const &c )
-{
- this->base_type::assign( c );
- this->buffer_ = c.buffer_;
-
- BOOST_ASSERT( this->test_invariant() );
-}
-
-/** Swaps the content of this object with another. Only the computation
- elements are changed; no function object proxies are reseated.
-
- \param other The other object to trade state with this object.
-
- \post <code>*this == <var>old_other</var> &amp;&amp; <var>old_this</var> ==
- <var>other</var></code>
- */
-inline
-void
-md5_computerX::swap( md5_computerX &other )
-{
- // Use the appropriate swap via Koeing look-up
- using std::swap;
-
- // Swap the computation members (don't reseat the function object proxies)
- this->base_type::swap( other );
- swap( this->buffer_, other.buffer_ );
-
- BOOST_ASSERT( this->test_invariant() );
- BOOST_ASSERT( other.test_invariant() );
-}
-
-
-// MD5 message-digest computation bit-input member function definitions ----//
-
-/** Submits 32-bit MD-word for computation. The word is submitted an octet at a
- time, from the lowest-order octet to the highest.
-
- \param word The word value to be submitted.
-
- \post <code>#bits_read() == <var>old_this</var>.bits_read() + 32</code>
- \post <code>#bits_unbuffered() == (<var>old_this</var>.bits_unbuffered() +
- 32) % bits_per_block</code>
- \post <code>#last_buffer() == (<var>old_this</var>.bits_unbuffered() + 32
- &gt;= bits_per_block) ? <var>new_value</var> :
- <var>old_this</var>.last_buffer()</code> (The new value is computed
- with the algorithm described in RFC 1321, section 3.4.)
- \post If <code>bits_read() % bits_per_block == 0</code>, then
- <code>#copy_unbuffered(<var>o1</var>)</code> leaves \p o1 unused,
- otherwise if <code><var>old_this</var>.bits_unbuffered() + 32 &lt;
- bits_per_block,</code> then <code>copy_unbuffered(<var>o2</var>) -
- <var>old_this</var>.copy_unbuffered(<var>o2</var>) == 32</code>
- (assuming that \p o2 is, at least, a forward iterator), otherwise the
- range \p o3 to <code>copy_unbuffered(<var>o3</var>)</code> contains
- the <code><var>old_this</var>.bits_unbuffered() + 32 -
- bits_per_block</code> lowest-order bits of \p word
-
- \see #process_octet(boost::uint_least8_t)
- */
-inline
-void
-md5_computerX::process_word( md5_digest::word_type word )
-{
- this->process_octet( word & 0xFFul );
- this->process_octet( (word >> 8) & 0xFFul );
- this->process_octet( (word >> 16) & 0xFFul );
- this->process_octet( (word >> 24) & 0xFFul );
-}
-
-/** Submits 64-bit MD-length for computation. The double-word is submitted a
- word at a time, first the low-order word then the high-order word.
-
- \param dword The double-word value to be submitted.
-
- \post <code>#bits_read() == <var>old_this</var>.bits_read() + 64</code>
- \post <code>#bits_unbuffered() == (<var>old_this</var>.bits_unbuffered() +
- 64) % bits_per_block</code>
- \post <code>#last_buffer() == (<var>old_this</var>.bits_unbuffered() + 64
- &gt;= bits_per_block) ? <var>new_value</var> :
- <var>old_this</var>.last_buffer()</code> (The new value is computed
- with the algorithm described in RFC 1321, section 3.4.)
- \post If <code>bits_read() % bits_per_block == 0</code>, then
- <code>#copy_unbuffered(<var>o1</var>)</code> leaves \p o1 unused,
- otherwise if <code><var>old_this</var>.bits_unbuffered() + 64 &lt;
- bits_per_block,</code> then <code>copy_unbuffered(<var>o2</var>) -
- <var>old_this</var>.copy_unbuffered(<var>o2</var>) == 64</code>
- (assuming that \p o2 is, at least, a forward iterator), otherwise the
- range \p o3 to <code>copy_unbuffered(<var>o3</var>)</code> contains
- the <code><var>old_this</var>.bits_unbuffered() + 64 -
- bits_per_block</code> lowest-order bits of \p word
-
- \see #process_word(boost::coding::md5_digest::word_type)
- */
-inline
-void
-md5_computerX::process_double_word( md5_computerX::length_type dword )
-{
- this->process_word( dword & 0xFFFFFFFFull );
- this->process_word( (dword >> 32) & 0xFFFFFFFFull );
-}
-
-
-// MD5 message-digest structure member operator function definitions -------//
-
-/** Changes a MD5 message computer to have the same observable state as a given
- computer. (No function object proxies are reseated, however.)
-
- \param c The source object with the new state.
-
- \return \c *this
-
- \post <code>#bits_read() == <var>c</var>.bits_read()</code>
- \post <code>#last_buffer() == <var>c</var>.last_buffer()</code>
- \post Given <code>#copy_unbuffered(<var>o1</var>)</code> and
- <code><var>c</var>.copy_unbuffered(<var>o2</var>)</code>, where both
- \p o1 and \p o2 are random access iterators to different container
- segments that each have at least <code>#bits_unbuffered()</code>
- elements available, <code>std::equal( o1, o1 + bits_unbuffered(), o2
- ) == true</code>
- \post \c #bits and \c #bytes \e still point to \c *this
-
- \see #assign(md5_computerX const&)
- */
-inline
-md5_computerX &
-md5_computerX::operator =( md5_computerX const &c )
-{
- this->assign( c );
- return *this;
-}
-
-/** Compares MD5 message computers for equivalence. Such computers are equal if
- all of the corresponding parts of their significant state (data length,
- running hash, and bit queue) are equal.
-
- \param c The right-side operand to be compared.
-
- \retval true \c *this and \p c are equivalent.
- \retval false \c *this and \p c are not equivalent.
-
- \see #bits_read()
- \see #last_buffer()
- \see #copy_unbuffered(OutputIterator)
- */
-inline
-bool
-md5_computerX::operator ==( md5_computerX const &c ) const
-{
- // Don't compare the function object proxies since they don't carry
- // significant state. (Furthermore, they can't change once initalized and
- // don't have any comparison operators.)
- return ( this->buffer_ == c.buffer_ ) && this->base_type::operator ==( c );
-}
-
-/** Compares MD5 message computers for non-equivalence. Such computers are
- unequal if at least one set of corresponding parts of their significant
- state (data length, running hash, and bit queue) are unequal.
-
- \param c The right-side operand to be compared.
-
- \retval true \c *this and \p c are not equivalent.
- \retval false \c *this and \p c are equivalent.
-
- \see #operator==(md5_computerX const&)const
- */
-inline
-bool
-md5_computerX::operator !=( md5_computerX const &c ) const
-{
- return !this->operator ==( c );
-}
-
-/** Computes the check-sum of the submitted data, through a standard generator
- interface.
-
- \return The generated check-sum.
-
- \see #checksum()const
- */
-inline
-md5_computerX::value_type
-md5_computerX::operator ()() const
-{
- return this->checksum();
-}
-
-
 // MD5 message-digest computation function definition ----------------------//
 
 /** \brief Immediate MD5 message-digest computation
@@ -571,13 +50,8 @@
     \see boost::coding::md5_digest
     \see boost::coding::md5_computer
  */
-inline
-md5_digest
-compute_md5
-(
- void const * buffer,
- std::size_t byte_count
-)
+inline md5_digest
+compute_md5( void const *buffer, std::size_t byte_count )
 {
     md5_computer c;
 

Deleted: sandbox/md5/boost/coding/operations.hpp
==============================================================================
--- sandbox/md5/boost/coding/operations.hpp 2008-08-10 13:49:37 EDT (Sun, 10 Aug 2008)
+++ (empty file)
@@ -1,897 +0,0 @@
-// Boost coding/operations.hpp header file ----------------------------------//
-
-// (C) Copyright Daryle Walker 2008. Distributed under the Boost Software
-// License, Version 1.0. (See the accompanying file LICENSE_1_0.txt or a copy
-// at <http://www.boost.org/LICENSE_1_0.txt>.)
-
-// See <http://www.boost.org/libs/coding> for documentation.
-
-/** \file
- \brief Definitions of coding helper base class templates
-
- Contains the definition of templates that can be used for base classes of
- bit- and byte-encoding computer types.
- */
-
-#ifndef BOOST_CODING_OPERATIONS_HPP
-#define BOOST_CODING_OPERATIONS_HPP
-
-#include <boost/coding_fwd.hpp>
-
-#include <boost/array.hpp> // for boost::array
-#include <boost/assert.hpp> // for BOOST_ASSERT
-#include <boost/concept/assert.hpp> // for BOOST_CONCEPT_ASSERT
-#include <boost/concept_check.hpp> // for boost::OutputIterator
-#include <boost/cstdint.hpp> // for boost::uint_least8_t
-#include <boost/static_assert.hpp> // for BOOST_STATIC_ASSERT
-#include <boost/type_traits.hpp> // for boost::is_class, is_integral, etc.
-
-#include <algorithm> // for std::copy, swap, equal
-#include <climits> // for CHAR_BIT
-
-
-namespace boost
-{
-namespace coding
-{
-
-
-// Byte-processing base class template declaration -------------------------//
-
-/** \brief Base class template for byte-processing operations
-
- This template is intended to base a class using the curiously recurring
- template pattern to gain completed definitions of common byte-processing
- operations.
-
- \pre \p Derived is a class or class template and it must have, either
- directly or through an intermediate base class, an unambiguous
- non-static member function named \c process_byte that returns \c void
- and takes one argument of type <code>unsigned char</code>. (A
- different, yet compatible, signature is acceptable.)
- \pre \p SizeType is a built-in unsigned integral type.
-
- \tparam Derived The final operand type that this class template will form
- a base. Any intermediate helper class templates should
- pass \p Derived on to \c byte_processing_base.
- \tparam SizeType The type used for size parameters. If not given,
- \c std::size_t is the default.
-
- \todo Using #bytes always changes \c *this. Is there some way to hold off
- updates until explicit assignment?
- */
-template < class Derived, typename SizeType >
-class byte_processing_base
-{
- // Parameter checks (can't check for the existence of "process_byte")
- BOOST_STATIC_ASSERT( is_class<Derived>::value );
- BOOST_STATIC_ASSERT( is_integral<SizeType>::value &&
- is_unsigned<SizeType>::value );
-
- // Byte-wise application proxy class
- class byte_applicator
- {
- friend class byte_processing_base;
- Derived & source_;
- explicit byte_applicator( Derived &source )
- : source_( source ) {}
- public:
- void operator ()( unsigned char byte )
- { this->source_.process_byte(byte); }
- byte_applicator & operator =( byte_applicator const &c )
- { this->source_ = c.source_; return *this; }
- }; // byte_applicator
-
-public:
- // Special application interface
- /** \brief Proxy for byte-oriented application interface
-
- Accesses an interface where <code>*this</code> can be used as a function
- object take can take a single <code>unsigned char</code> value as input.
- It cannot be reseated from <code>*this</code>, but assignment to it will
- copy the other's owner's state to <code>*this</code>, enabling
- algorithms that return updated function objects to work.
-
- \attention Since #byte_applicator stores a non-constant reference to
- its owner, the owner will be change through any application
- through \c bytes, even if \c bytes is passed by value.
- */
- byte_applicator bytes;
-
- /*! \name Byte-stream reading */ //@{
- // Types
- /** \brief Type of size values
-
- Represents the type used for sizing parameters.
- */
- typedef SizeType size_type;
-
- // Input processing
- //! Enters several bytes, all of the same value
- void process_byte_copies( unsigned char value, size_type byte_count );
-
- //! Enters a range of bytes in memory
- void process_block( void const *bytes_begin, void const *bytes_end );
- //! Enters a byte buffer in memory
- void process_bytes( void const *buffer, size_type byte_count );//@}
-
- /*! \name Operators */ //@{
- // Operators
- //! Copy-assignment
- byte_processing_base & operator =( byte_processing_base const & );//@}
-
-protected:
- // Implementation types
- /** \brief Final operand type
-
- Represents the type that should ultimately inherit from this template.
- */
- typedef Derived derived_type;
-
- // Lifetime management (use automatic destructor)
- //! Default construction
- byte_processing_base();
- //! Copy construction
- byte_processing_base( byte_processing_base const & );
-
-}; // byte_processing_base
-
-
-// Bit-processing base class template declarations -------------------------//
-
-/** \brief Base class template for bit-processing operations, big endian
-
- This template is intended to base a class using the curiously recurring
- template pattern to gain completed definitions of common bit-processing
- operations. Bits within a byte are processed in order starting from the
- most-significant places.
-
- \pre \p Derived is a class or class template and it must have, either
- directly or through an intermediate base class, an unambiguous
- non-static member function named \c process_bit that returns \c void
- and takes a single \c bool argument. (A different, yet compatible,
- signature is acceptable.)
- \pre \p SizeType is a built-in unsigned integral type.
-
- \tparam Derived The final operand type that this class template will form
- a base. Any intermediate helper class templates should
- pass \p Derived on to \c bit_processing_base.
- \tparam SizeType The type used for size parameters. If not given,
- \c std::size_t is the default.
-
- \see boost::coding::byte_processing_base
-
- \todo Using #bits always changes \c *this. Is there some way to hold off
- updates until explicit assignment?
- */
-template < class Derived, typename SizeType >
-class bit_processing_b_base
- : public byte_processing_base<Derived, SizeType>
-{
- typedef byte_processing_base<Derived, SizeType> base_type;
-
- // The parameter checks that the base class uses are acceptable. (Except
- // that we can't check for the existence of "process_bit".)
-
- // Bit-wise application proxy class
- class bit_applicator
- {
- friend class bit_processing_b_base;
- Derived & source_;
- explicit bit_applicator( Derived &source )
- : source_( source ) {}
- public:
- void operator ()( bool bit )
- { this->source_.process_bit(bit); }
- bit_applicator & operator =( bit_applicator const &c )
- { this->source_ = c.source_; return *this; }
- }; // bit_applicator
-
-public:
- // Special application interface
- /** \brief Proxy for bit-oriented application interface
-
- Accesses an interface where <code>*this</code> can be used as a function
- object take can take a single \c bool value as input. It cannot be
- reseated from <code>*this</code>, but assignment to it will copy the
- other's owner's state to <code>*this</code>, enabling algorithms that
- return updated function objects to work.
-
- \attention Since #bit_applicator stores a non-constant reference to its
- owner, the owner will be change through any application
- through \c bits, even if \c bits is passed by value.
-
- \see #bit_applicator
- */
- bit_applicator bits;
-
- /*! \name Bit-stream reading */ //@{
- // Types
- /** \brief Type of size values
-
- Represents the type used for sizing parameters.
- */
- typedef typename base_type::size_type size_type;
-
- // Input processing
- //! Enters lowest-signficant part of a byte, relatively high-order bit first
- void process_bits( unsigned char bits, size_type bit_count );
- //! Enters several bits, all of the same value
- void process_bit_copies( bool value, size_type bit_count );
-
- //! Enters a whole byte, high-order bit first
- void process_byte( unsigned char byte );
-
- //! Enters an octet, highest bit first
- void process_octet( uint_least8_t octet );//@}
-
- /*! \name Operators */ //@{
- // Operators
- //! Copy-assignment
- bit_processing_b_base & operator =( bit_processing_b_base const &c );//@}
-
-protected:
- // Implementation types
- /** \brief Final operand type
-
- Represents the type that should ultimately inherit from this template.
- */
- typedef typename base_type::derived_type derived_type;
-
- // Lifetime management (use automatic destructor)
- //! Default construction
- bit_processing_b_base();
- //! Copy construction
- bit_processing_b_base( bit_processing_b_base const &c );
-
-}; // bit_processing_b_base
-
-
-// Queued bit-processing base class template declarations ------------------//
-
-/** \brief Base class template for queued bit-processing operations
-
- This template is intended to base a class using the curiously recurring
- template pattern to gain a definition of a bit-queueing operation, plus some
- inspectors on the bit queue. Bits, either individually or within a byte,
- are processed in submission order, but in fixed-size runs. Bits are kept in
- a queue until enough bits have been saved, then a full bit pack is processed
- in one shot.
-
- \pre \p Derived is a class or class template and it must have, either
- directly or through an intermediate base class, an unambiguous
- non-static member function named \c update_hash that returns nothing
- (i.e. \c void) but takes two <code>bool const *</code> bounding an
- array segment. (A different, yet compatible, signature is
- acceptable.)
- \pre \p LengthType is a built-in unsigned integral type.
- \pre <code><var>QueueLength</var> &gt;= 2</code>. (If \p QueueLength is
- less than two, then \c update_hash will be called after \e every
- submission, which would make having a queue pointless.)
- \pre \p SizeType is a built-in unsigned integral type.
-
- \tparam Derived The final operand type that this class template will
- form a base. Any intermediate helper class templates
- should pass \p Derived on to
- \c queued_bit_processing_b_base.
- \tparam LengthType The type used for queue-size parameters.
- \tparam QueueLength The number of processed bits to queue between hashings.
- \tparam SizeType The type used for processing-size parameters. If not
- given, \c std::size_t is the default.
-
- \see boost::coding::bit_processing_b_base
- */
-template < class Derived, typename LengthType, LengthType QueueLength, typename
- SizeType >
-class queued_bit_processing_base
- : public bit_processing_b_base<Derived, SizeType>
-{
- typedef bit_processing_b_base<Derived, SizeType> base_type;
-
- // Parameter checks (some template arguments are checked by the base class
- // template; can't check for the existence of "update_hash".)
- BOOST_STATIC_ASSERT( is_integral<LengthType>::value &&
- is_unsigned<LengthType>::value );
- BOOST_STATIC_ASSERT( QueueLength >= 2u );
-
-public:
- /*! \name Inspection */ //@{
- // Types
- /** \brief Type of length values
-
- Represents the type used for processing- and queueing-size results.
- */
- typedef LengthType length_type;
-
- // Constants
- //! Number of bits in the hash queue
- static length_type const queue_length = QueueLength;
-
- // Inspectors
- //! Returns the count of bits read so far, hashed and queued
- length_type bits_read() const;
- //! Returns the count of the queued bits
- length_type bits_unbuffered() const;
-
- //! Copies out the queued bits
- template < typename OutputIterator >
- OutputIterator copy_unbuffered( OutputIterator o ) const;//@}
-
- /*! \name Bit-stream reading */ //@{
- // More types
- /** \brief Type of size values
-
- Represents the type used for reading-size parameters.
- */
- typedef typename base_type::size_type size_type;
-
- // Input processing
- //! Enters one bit for hashing
- void process_bit( bool bit );//@}
-
- /*! \name Operators */ //@{
- // Operators (use automatic copy-assignment operator)
- //! Equals
- bool operator ==( queued_bit_processing_base const &c ) const;
- //! Not-equals
- bool operator !=( queued_bit_processing_base const &c ) const;//@}
-
-protected:
- // Implementation types
- /** \brief Final operand type
-
- Represents the type that should ultimately inherit from this template.
- */
- typedef typename base_type::derived_type derived_type;
-
- // Lifetime management (use automatic copy constructor and destructor)
- //! Default construction
- queued_bit_processing_base();
-
- /*! \name Assignment */ //@{
- // Assignment
- //! Sets state back to initial conditions
- void reset();
- //! Changes the current state to a copy of another object's
- void assign( queued_bit_processing_base const &c );
-
- //! Exchanges state with another object
- void swap( queued_bit_processing_base &other );//@}
-
-private:
- // More implementation types
- typedef array<bool, queue_length> queue_type;
-
- // Member data
- length_type bit_count;
- queue_type queued_bits;
-
-}; // queued_bit_processing_base
-
-
-// Byte-processing base class template member definitions ------------------//
-
-/** Constructs a byte processor set to initial conditions.
-
- \post \c #bytes points to \c *this
- */
-template < class Derived, typename SizeType >
-inline
-byte_processing_base<Derived, SizeType>::byte_processing_base()
- : bytes( *static_cast<derived_type *>(this) )
-{
-}
-
-/** Constructs a byte processor to the same significant state as another.
-
- \post \c #bytes points to \c *this
- */
-template < class Derived, typename SizeType >
-inline
-byte_processing_base<Derived, SizeType>::byte_processing_base
-(
- byte_processing_base const & // unused
-)
- : bytes( *static_cast<derived_type *>(this) )
-{
-}
-
-/** Submits multiple copies of a single byte value for processing.
-
- \param value The byte value to be submitted.
- \param byte_count The number of bytes to submit.
-
- \post This object's \c process_byte member function has been called
- \p byte_count times with \p value as the parameter.
- */
-template < class Derived, typename SizeType >
-inline
-void
-byte_processing_base<Derived, SizeType>::process_byte_copies
-(
- unsigned char value,
- size_type byte_count
-)
-{
- while ( byte_count-- )
- this->bytes( value );
-}
-
-/** Submits bytes, delimited by a pointer range, for processing.
-
- \pre If \p bytes_begin is not \c NULL, then \p bytes_end has to be
- reachable from \p bytes_begin via forward iterations of their
- equivalent <code>unsigned char const *</code> values, otherwise
- \p bytes_end has to be \c NULL too.
-
- \param bytes_begin The start of the byte range to be submitted.
- \param bytes_end One-past-the-end of the byte range in \p bytes_begin.
-
- \post This object's \c process_byte member function has been called for
- each byte in the given range, starting from the one at the address
- \p bytes_begin to the byte just before the \p bytes_end mark.
- */
-template < class Derived, typename SizeType >
-inline
-void
-byte_processing_base<Derived, SizeType>::process_block
-(
- void const * bytes_begin,
- void const * bytes_end
-)
-{
- // Parameter check (can't check if bytes_end is reachable from bytes_begin)
- BOOST_ASSERT( !bytes_begin == !bytes_end );
-
- for ( unsigned char const * p =
- static_cast<unsigned char const *>(bytes_begin) ; p != bytes_end ; ++p )
- this->bytes( *p );
-}
-
-/** Submits bytes, bounded by a pointer and length, for processing.
-
- \pre If \p buffer is \c NULL, then \p byte_count must be zero.
-
- \param buffer The start of the byte range to be submitted.
- \param byte_count Number of (leading) bytes to use from the range.
-
- \post This object's \c process_byte member function has been called for
- each byte in the given range, starting from the one at the address
- \p buffer, going forward for \p byte_count bytes total.
- */
-template < class Derived, typename SizeType >
-inline
-void
-byte_processing_base<Derived, SizeType>::process_bytes
-(
- void const * buffer,
- size_type byte_count
-)
-{
- // Parameter check
- BOOST_ASSERT( buffer || !byte_count );
-
- for ( unsigned char const * p = static_cast<unsigned char const *>(buffer)
- ; byte_count-- ; ++p )
- this->bytes( *p );
-}
-
-/** Changes a byte processor to have the same observable state as a given
- processor. (The function object proxy isn't reseated, however.)
-
- \return \c *this
-
- \post \c #bytes \e still points to \c *this
- */
-template < class Derived, typename SizeType >
-inline
-byte_processing_base<Derived, SizeType> &
-byte_processing_base<Derived, SizeType>::operator =
-(
- byte_processing_base const & // unused
-)
-{
- // Do nothing, so "bytes" can't be reseated
- return *this;
-}
-
-
-// Bit-processing base class template member definitions -------------------//
-
-/** Constructs a bit processor set to initial conditions.
-
- \post \c #bits points to \c *this
- */
-template < class Derived, typename SizeType >
-inline
-bit_processing_b_base<Derived, SizeType>::bit_processing_b_base()
- : base_type()
- , bits( *static_cast<derived_type *>(this) )
-{
-}
-
-/** Constructs a bit processor to the same computation state as \p c.
-
- \param c The original object to be copied.
-
- \post \c #bits points to \c *this
- */
-template < class Derived, typename SizeType >
-inline
-bit_processing_b_base<Derived, SizeType>::bit_processing_b_base
-(
- bit_processing_b_base const & c
-)
- : base_type( c )
- , bits( *static_cast<derived_type *>(this) )
-{
-}
-
-/** Submits part of a byte for processing. The lowest-order bits are submitted
- starting from the relatively highest-order bit to the lowest.
-
- \pre <code>0 &lt;= <var>bit_count</var> &lt;= CHAR_BIT</code>.
-
- \param bits The byte from which the values are submitted.
- \param bit_count The number of bits to submit.
-
- \post This object's \c process_bit member function has been called for
- each qualifying bit within \p bits, starting from the bit at the
- 2<sup><var>bit_count</var> - 1</sup>-place, going down to the
- ones-place. (If \p bit_count is zero, no calls are made.)
- */
-template < class Derived, typename SizeType >
-inline
-void
-bit_processing_b_base<Derived, SizeType>::process_bits
-(
- unsigned char bits,
- size_type bit_count
-)
-{
- // Parameter check
- BOOST_ASSERT( (0u <= bit_count) && (bit_count <= CHAR_BIT) );
-
- while ( bit_count-- )
- this->bits( bits & (0x01u << bit_count) );
-}
-
-/** Submits multiple copies of a single bit value for processing.
-
- \param value The bit value to be submitted.
- \param bit_count The number of bits to submit.
-
- \post This object's \c process_bit member function has been called
- \p bit_count times with \p value as the parameter.
- */
-template < class Derived, typename SizeType >
-inline
-void
-bit_processing_b_base<Derived, SizeType>::process_bit_copies
-(
- bool value,
- size_type bit_count
-)
-{
- while ( bit_count-- )
- this->bits( value );
-}
-
-/** Submits a byte for processing. The bits are submitted starting from the
- highest-order bit to the lowest. Note that this member function enables the
- inherited input-processing member functions \c #process_byte_copies,
- \c #process_block, and \c #process_bytes.
-
- \param byte The byte value to be submitted.
-
- \post This object's \c process_bit member function has been called for
- each bit in the given \p byte, starting from the high-order bit,
- going down to the low-order bit.
-
- \see #process_bits(unsigned char,#size_type)
- */
-template < class Derived, typename SizeType >
-inline
-void
-bit_processing_b_base<Derived, SizeType>::process_byte( unsigned char byte )
-{
- this->process_bits( byte, CHAR_BIT );
-}
-
-/** Submits an octet for processing. The bits are submitted starting from the
- highest-order bit to the lowest. Note that a byte may be larger than eight
- bits, so the lowest-significant bits within the containing byte (or larger
- register) are chosen. This way, you don't have to shift up your octet value
- by <code>sizeof(<var>octet</var>) * CHAR_BIT - 8</code> (or whatever) bits.
-
- \param octet The octet value to be submitted.
-
- \post This object's \c process_bit member function has been called for
- each qualifying bit in \p octet, starting from the bit at the
- 128s-place, going down to the ones-place.
-
- \see #process_bits(unsigned char,#size_type)
- */
-template < class Derived, typename SizeType >
-inline
-void
-bit_processing_b_base<Derived, SizeType>::process_octet( uint_least8_t octet )
-{
- // CHAR_BIT >= 8 (C-1999, section 5.2.4.2.1) -> all octet values can safely
- // be converted to "unsigned char," no matter what "uint_least8_t" is.
- this->process_bits( octet, 8u );
-}
-
-/** Changes a bit processor to have the same observable state as a given
- processor. (No function object proxies are reseated, however.)
-
- \param c The source object with the new state.
-
- \return \c *this
-
- \post \c #bits \e still points to \c *this
- */
-template < class Derived, typename SizeType >
-inline
-bit_processing_b_base<Derived, SizeType> &
-bit_processing_b_base<Derived, SizeType>::operator =
-(
- bit_processing_b_base const & c
-)
-{
- // Do nothing, so "bits" can't be reseated
- this->base_type::operator =( c );
- return *this;
-}
-
-
-// Queued bit-processing base class template member definitions ------------//
-
-/** Represents the number of submitted bits that are queued until that queue
- is emptied as a single block to be hashed. The count of unhashed bits
- is always less than this value. (The input processing member functions,
- like \c #process_bit, trigger \c update_hash right after a bit fills the
- queue.)
- */
-template < class Derived, typename LengthType, LengthType QueueLength, typename
- SizeType >
-typename queued_bit_processing_base<Derived, LengthType, QueueLength,
- SizeType>::length_type const queued_bit_processing_base<Derived, LengthType,
- QueueLength, SizeType>::queue_length;
-
-/** Constructs an empty processing queue.
-
- \post <code>#bits_read() == 0</code>.
- \post <code>#copy_unbuffered(<var>o</var>)</code> leaves \p o unused.
- */
-template < class Derived, typename LengthType, LengthType QueueLength, typename
- SizeType >
-inline
-queued_bit_processing_base<Derived, LengthType, QueueLength,
- SizeType>::queued_bit_processing_base()
- : bit_count(), queued_bits()
-{
-}
-
-/** Returns the number of bits that have been processed, both those that have
- been hashed and those that are on queue. (Beware if the number of
- submissions has exceeded <code>std::numeric_limits&lt; #length_type
- &gt;::max()</code>.)
-
- \return How many bits have been submitted, hashed and queued.
- */
-template < class Derived, typename LengthType, LengthType QueueLength, typename
- SizeType >
-inline
-typename queued_bit_processing_base<Derived, LengthType, QueueLength,
- SizeType>::length_type
-queued_bit_processing_base<Derived, LengthType, QueueLength,
- SizeType>::bits_read() const
-{
- return this->bit_count;
-}
-
-/** Returns the number of bits that are still in the queue, unhashed. Hashing
- occurs only after every \c #queue_length bit submissions, so this member
- function can confirm queued stragglers. (The identities of hashed bits are
- not retrievable.)
-
- \return How many bits are queued to be hashed.
-
- \see #bits_read()
- \see #queue_length
- */
-template < class Derived, typename LengthType, LengthType QueueLength, typename
- SizeType >
-inline
-typename queued_bit_processing_base<Derived, LengthType, QueueLength,
- SizeType>::length_type
-queued_bit_processing_base<Derived, LengthType, QueueLength,
- SizeType>::bits_unbuffered() const
-{
- return this->bit_count % queue_length;
-}
-
-/** Copies the last submitted bits that have not yet hashed starting from the
- oldest submission. Use \c #bits_unbuffered() for advance notice of how
- many iterations are done. (Always less than \c #queue_length elements are
- copied.)
-
- \pre At least \c #bits_unbuffered() more elements are free to be created
- and/or assigned through \p o.
-
- \tparam OutputIterator The type of the iterator submitted. It should match
- the requirements of either an output or a forward
- (or above) mutable iterator over something that can
- receive \c bool values via dereferenced assignment.
-
- \param o The iterator starting the destination range.
-
- \return \p o after copying.
-
- \see #bits_unbuffered()
- \see #queue_length
- */
-template < class Derived, typename LengthType, LengthType QueueLength, typename
- SizeType >
-template < typename OutputIterator >
-inline
-OutputIterator
-queued_bit_processing_base<Derived, LengthType, QueueLength,
- SizeType>::copy_unbuffered( OutputIterator o ) const
-{
- // Parameter check
- BOOST_CONCEPT_ASSERT( (boost::OutputIterator<OutputIterator, bool>) );
-
- return std::copy( this->queued_bits.begin(), this->queued_bits.begin() +
- this->bits_unbuffered(), o );
-}
-
-/** Changes an object to be like it was default-constructed.
-
- \post <code>#bits_read() == 0</code>.
- \post <code>#copy_unbuffered(<var>o</var>)</code> leaves \p o unused.
-
- \see #queued_bit_processing_base()
- */
-template < class Derived, typename LengthType, LengthType QueueLength, typename
- SizeType >
-inline
-void
-queued_bit_processing_base<Derived, LengthType, QueueLength, SizeType>::reset()
-{
- // With this setting, any used bits in "queued_bits" will be ignored.
- this->bit_count = 0u;
-}
-
-/** Changes an object to be like the given object.
-
- \param c The object with the new state to be copied.
-
- \post <code>*this == <var>c</var></code>.
- */
-template < class Derived, typename LengthType, LengthType QueueLength, typename
- SizeType >
-inline
-void
-queued_bit_processing_base<Derived, LengthType, QueueLength, SizeType>::assign(
- queued_bit_processing_base const &c )
-{
- // Just rip off the automatically-defined copy-assignment operator
- *this = c;
-}
-
-/** Swaps the content of this object with another.
-
- \param other The other object to trade state with this object.
-
- \post <code>*this == <var>old_other</var> &amp;&amp; <var>old_this</var> ==
- <var>other</var></code>.
- */
-template < class Derived, typename LengthType, LengthType QueueLength, typename
- SizeType >
-inline
-void
-queued_bit_processing_base<Derived, LengthType, QueueLength, SizeType>::swap(
- queued_bit_processing_base &other )
-{
- // Use the appropriate swap via Koeing look-up
- using std::swap;
-
- // Swap members
- swap( this->bit_count, other.bit_count );
- swap( this->queued_bits, other.queued_bits );
-}
-
-/** Submits a single bit to the processing queue. If this bit fills the queue,
- the queue's bits are hashed and the queue is emptied.
-
- \param bit The bit value to be submitted.
-
- \post <code>#bits_read() == <var>old_this</var>.bits_read() + 1</code>.
- \post <code>#bits_unbuffered() == bits_read() % #queue_length ? 0 :
- <var>old_this</var>.bits_unbuffered() + 1</code>.
- \post This object's \c update_hash member function has been called,
- accepting all the bits from the queue in submission order.
- \post If <code>bits_read() % queue_length == 0</code>, then
- <code>#copy_unbuffered(<var>o1</var>)</code> leaves \p o1 unused,
- otherwise <code>std::distance(
- <var>old_this</var>.copy_unbuffered(<var>o2</var>),
- copy_unbuffered(<var>o2</var>) ) == 1</code> (assuming that \p o2 is,
- at least, a forward iterator).
- */
-template < class Derived, typename LengthType, LengthType QueueLength, typename
- SizeType >
-inline
-void
-queued_bit_processing_base<Derived, LengthType, QueueLength,
- SizeType>::process_bit( bool bit )
-{
- this->queued_bits[ this->bits_unbuffered() ] = bit;
-
- if ( (++this->bit_count % queue_length) == 0u )
- {
- static_cast<derived_type *>(this)->update_hash(
- this->queued_bits.begin(), this->queued_bits.end() );
- }
-}
-
-/** Compares bit processing queues for equivalence. Such processing queues are
- equal if all of the corresponding parts of their significant state (data
- length and bit queue) are equal. In other words, if \c *this and \p c are
- equivalent, then:
- - <code>#bits_read() == <var>c</var>.bits_read()</code>.
- - Given two empty containers \p x1 and \p x2 of the same standard-acting
- type that holds \c bool elements and has the \c push_back member function,
- after applying <code>#copy_unbuffered( std::back_inserter(<var>x1</var>)
- )</code> and <code><var>c</var>.copy_unbuffered(
- std::back_inserter(<var>x2</var>) )</code>, <code><var>x1</var> ==
- <var>x2</var></code>.
-
- \param c The right-side operand to be compared.
-
- \retval true \c *this and \p c are equivalent.
- \retval false \c *this and \p c are not equivalent.
-
- \see #bits_read()
- \see #copy_unbuffered(OutputIterator)
- */
-template < class Derived, typename LengthType, LengthType QueueLength, typename
- SizeType >
-inline
-bool
-queued_bit_processing_base<Derived, LengthType, QueueLength, SizeType>::operator
- ==( queued_bit_processing_base const &c ) const
-{
- return ( this->bit_count == c.bit_count ) && std::equal(
- this->queued_bits.begin(), this->queued_bits.begin() +
- this->bits_unbuffered(), c.queued_bits.begin() );
-}
-
-/** Compares bit processing queues for non-equivalence. Such processing queues
- are unequal if at least one set of corresponding parts of their significant
- state (data length or bit queue) are unequal.
-
- \param c The right-side operand to be compared.
-
- \retval true \c *this and \p c are not equivalent.
- \retval false \c *this and \p c are equivalent.
-
- \see #operator==(queued_bit_processing_base const&)const
- */
-template < class Derived, typename LengthType, LengthType QueueLength, typename
- SizeType >
-inline
-bool
-queued_bit_processing_base<Derived, LengthType, QueueLength, SizeType>::operator
- !=( queued_bit_processing_base const &c ) const
-{
- return !this->operator ==( c );
-}
-
-
-} // namespace coding
-} // namespace boost
-
-
-#endif // BOOST_CODING_OPERATIONS_HPP

Modified: sandbox/md5/boost/coding_fwd.hpp
==============================================================================
--- sandbox/md5/boost/coding_fwd.hpp (original)
+++ sandbox/md5/boost/coding_fwd.hpp 2008-08-10 13:49:37 EDT (Sun, 10 Aug 2008)
@@ -16,8 +16,6 @@
 #ifndef BOOST_CODING_FWD_HPP
 #define BOOST_CODING_FWD_HPP
 
-#include <cstddef> // for std::size_t
-
 
 namespace boost
 {
@@ -43,19 +41,6 @@
 class bit_coding_shell;
 
 
-// From <boost/coding/operations.hpp> --------------------------------------//
-
-template < class Derived, typename SizeType = std::size_t >
-class byte_processing_base;
-
-template < class Derived, typename SizeType = std::size_t >
-class bit_processing_b_base;
-
-template < class Derived, typename LengthType, LengthType QueueLength, typename
- SizeType = std::size_t >
-class queued_bit_processing_base;
-
-
 // From <boost/coding/md5_digest_core.hpp> ---------------------------------//
 
 struct md5_digest;
@@ -82,9 +67,8 @@
 
 // From <boost/coding/md5.hpp> ---------------------------------------------//
 
-class md5_computerX;
-
-// Also has a free function
+// Has a free function
+// #includes "md5_digest.hpp", "md5_context.hpp", and "md5_computer.hpp"
 
 
 } // namespace coding

Modified: sandbox/md5/libs/coding/src/md5.cpp
==============================================================================
--- sandbox/md5/libs/coding/src/md5.cpp (original)
+++ sandbox/md5/libs/coding/src/md5.cpp 2008-08-10 13:49:37 EDT (Sun, 10 Aug 2008)
@@ -16,18 +16,19 @@
  */
 // See <http://www.boost.org/libs/coding> for documentation.
 
-#include <boost/coding/md5.hpp>
+#include <boost/coding/md5_context.hpp>
+#include <boost/coding/md5_computer.hpp>
 
 #include <boost/array.hpp> // for boost::array
 #include <boost/assert.hpp> // for BOOST_ASSERT
 #include <boost/integer/integer_mask.hpp> // for boost::integer_lo_mask
+#include <boost/limits.hpp> // for std::numeric_limits
 #include <boost/math/common_factor_rt.hpp> // for boost::math::gcd
 #include <boost/static_assert.hpp> // for BOOST_STATIC_ASSERT
 
 #include <algorithm> // for std::copy
 #include <cmath> // for std::sin, abs, ldexp, modf
 #include <cstddef> // for std::size_t
-#include <limits> // for std::numeric_limits
 #include <numeric> // for std::inner_product, partial_sum
 #include <valarray> // for std::valarray, etc.
 
@@ -128,7 +129,7 @@
 
 template < typename Unsigned, int TotalRotated >
 Unsigned const left_rotator<Unsigned, TotalRotated>::mask_ =
- boost::low_bits_mask_t<TotalRotated>::sig_bits;
+ boost::integer_lo_mask<TotalRotated>::value;
 
 // Order of listed bits within a 32-bit word: octets are listed lowest-order
 // first, but the bits within octets are listed highest-order first! The order
@@ -172,12 +173,6 @@
     return r;
 }
 
-// The exact amount of bits needed to be in the queue so an appendage of the
-// length will exactly fill the queue.
-std::size_t const padding_remainder =
- boost::coding::md5_computerX::bits_per_block -
- boost::coding::md5_computerX::significant_bits_per_length;
-
 } // unnamed namespace
 
 
@@ -187,31 +182,29 @@
 {
 
 
-// MD5 message-digest computer class-static member definitions -------------//
+// MD5 message-digest core computation non-inline member definitions -------//
 
-std::size_t const md5_computerX::words_per_block;
+/** Provides the computed check-sum of all the submitted bits (as if the message
+ is complete), through a standard generator interface.
 
-/** Represents the number of significant (low-order) bits kept for the
- message length, which can also be processed as two words, all as given
- in RFC 1321, section 3.2, paragraph 1.
- */
-int const md5_computerX::significant_bits_per_length;
-/** Represents the number of submitted bits that are queued until that queue
- is emptied as a single block to be hashed, implied from RFC 1321,
- section 3.4. The count of unhashed bits is always less than this value.
- (The input processing member functions trigger a hash right after a bit
- fills the queue.)
+ \return The check-sum.
  */
-std::size_t const md5_computerX::bits_per_block;
+md5_context::product_type
+md5_context::operator ()() const
+{
+ self_type copy( *this );
+ copy.finish();
 
-/** Sample of the table described in RFC 1321, section 3.4, paragraph 4.
- Its values are taken directly from the "MD5Transform" function in the
- RFC's section A.3, and are not computed. Of course, the index is
- zero-based (C++) instead of one-based (RFC).
+ product_type result;
+ std::copy( copy.buffer.begin(), copy.buffer.end(), result.hash );
+ return result;
+}
 
- \see #generate_hashing_table
- */
-array<md5_digest::word_type, 64> const md5_computerX::hashing_table = { {
+// Sample of the table described in RFC 1321, section 3.4, paragraph 4. Its
+// values are taken directly from the "MD5Transform" function in the RFC's
+// section A.3, and are not computed. Of course, the index is zero-based (C++)
+// instead of one-based (RFC).
+md5_context::hash_table_type const md5_context::hashing_table = { {
     0xD76AA478ul,
     0xE8C7B756ul,
     0x242070DBul,
@@ -281,196 +274,8 @@
 // Initial values of the MD buffer, taken from RFC 1321, section 3.3. (Note
 // that the RFC lists each number low-order byte first, while numbers need to be
 // written high-order byte first in C++.)
-md5_computerX::ibuffer_type const md5_computerX::initial_buffer_ = {
- {0x67452301ul, 0xEFCDAB89ul, 0x98BADCFEul, 0x10325476ul} };
-
-
-// MD5 message-digest computer class-static member function definitions ----//
-
-/** Constructs the hashing sine table based on the directions given in RFC
- 1321, section 3.4, paragraph 4. It should give the same values as
- #hashing_table, but it's dependent on the quality of the environment's
- math library, thereby giving a test of the environment.
-
- \return The computed hashing sine table
-
- \see #hashing_table
- */
-array<md5_digest::word_type, 64>
-md5_computerX::generate_hashing_table()
-{
- array<md5_digest::word_type, 64> r;
-
- for ( int i = 0 ; i < 64 ; ++i )
- {
- double x = std::ldexp( std::abs(std::sin( static_cast<double>(i + 1)
- )), +32 ); // 2**32 * abs(sin(I)), where I = i + 1
-
- std::modf( x, &x ); // x -> x rounded towards zero
- r[ i ] = static_cast<unsigned long>( x );
- }
- return r;
-}
-
-
-// MD5 message-digest computer implementation member function definitions --//
-
-// Hash an entire block into the running checksum, using RFC 1321, section 3.4
-void
-md5_computerX::update_hash( bool const *queue_b, bool const *queue_e )
-{
- using std::size_t;
-
- // Convert the queued bit block to a word block
- std::valarray<iword_type> words( words_per_block ), scratch( queue_e -
- queue_b );
-
- BOOST_ASSERT( scratch.size() == bits_per_block );
- std::copy( queue_b, queue_e, &scratch[0] );
- for ( size_t i = 0u ; i < words_per_block ; ++i )
- {
- // Use the default inner-product; since "unbuffered_" has "bool"
- // elements, which convert to 0 or 1, multiplication acts as AND; since
- // "order_in_word" has distinct single-bit values, addition acts as OR
- words[ i ] = std::inner_product( order_in_word.begin(),
- order_in_word.end(), &scratch[ i * md5_digest::bits_per_word::value ],
- iword_type(0u) );
- }
-
- // Set up rounds
- ibuffer_type buffer = this->buffer_;
-
- scratch.resize( words.size() ); // repurposed!
-
- // Round 1
- {
- md5_special_op<md5_f, iword_type, md5_digest::bits_per_word::value> ff;
-
- scratch = words[ skipped_indices(words_per_block, 0, 1) ];
- for ( size_t i = 0u ; i < words_per_block ; ++i )
- {
- ff( buffer[( 16u - i ) % 4u], buffer[( 17u - i ) % 4u],
- buffer[( 18u - i ) % 4u], buffer[( 19u - i ) % 4u], scratch[i],
- md5_s[0][i % 4u], hashing_table[i] );
- }
- }
-
- // Round 2
- {
- md5_special_op<md5_g, iword_type, md5_digest::bits_per_word::value> gg;
-
- scratch = words[ skipped_indices(words_per_block, 1, 5) ];
- for ( size_t i = 0u ; i < words_per_block ; ++i )
- {
- gg( buffer[( 16u - i ) % 4u], buffer[( 17u - i ) % 4u],
- buffer[( 18u - i ) % 4u], buffer[( 19u - i ) % 4u], scratch[i],
- md5_s[1][i % 4u], hashing_table[16 + i] );
- }
- }
-
- // Round 3
- {
- md5_special_op<md5_h, iword_type, md5_digest::bits_per_word::value> hh;
-
- scratch = words[ skipped_indices(words_per_block, 5, 3) ];
- for ( size_t i = 0u ; i < words_per_block ; ++i )
- {
- hh( buffer[( 16u - i ) % 4u], buffer[( 17u - i ) % 4u],
- buffer[( 18u - i ) % 4u], buffer[( 19u - i ) % 4u], scratch[i],
- md5_s[2][i % 4u], hashing_table[32 + i] );
- }
- }
-
- // Round 4
- {
- md5_special_op<md5_i, iword_type, md5_digest::bits_per_word::value> ii;
-
- scratch = words[ skipped_indices(words_per_block, 0, 7) ];
- for ( size_t i = 0u ; i < words_per_block ; ++i )
- {
- ii( buffer[( 16u - i ) % 4u], buffer[( 17u - i ) % 4u],
- buffer[( 18u - i ) % 4u], buffer[( 19u - i ) % 4u], scratch[i],
- md5_s[3][i % 4u], hashing_table[48 + i] );
- }
- }
-
- // Update buffer
- for ( size_t i = 0u ; i < md5_digest::words_per_digest::value ; ++i )
- {
- this->buffer_[ i ] += buffer[ i ];
- this->buffer_[ i ] &= integer_lo_mask<md5_digest::bits_per_word::value>
- ::value;
- }
-}
-
-
-// MD5 message-digest computation digest-output member function definition -//
-
-/** Provides the computed check-sum of all the submitted bits. (The queued
- bits are temporarily hashed with a special finishing procedure.)
-
- \return The check-sum (i.e. message digest).
- */
-md5_computerX::value_type
-md5_computerX::checksum() const
-{
- // As explained in RFC 1321, section 3, the final check-sum is the state of
- // the hash after padding and the original length are appended to the
- // message data. (The padding is sized such that the length's bits always
- // exactly finishes a block.) The padding is one mandatory TRUE value
- // followed by the appropriate amount of FALSE values.
- //
- // Technically, the modulo-bits_per_block is needed only if bits_unbuffered
- // exceeds padding_remainder (when it doesn't, just do the subtraction
- // directly), but this way always works and a conditional is avoided. (The
- // corresponding test added cases to make sure the old conditional was hit.)
- self_type cache( *this );
-
- cache.process_bit( true );
- cache.process_bit_copies( false, (padding_remainder +
- self_type::bits_per_block - cache.bits_unbuffered()) %
- self_type::bits_per_block );
- cache.process_double_word( this->bits_read() );
- BOOST_ASSERT( cache.bits_unbuffered() == 0u );
-
- self_type::buffer_type const rb = cache.last_buffer();
- self_type::value_type r;
-
- std::copy( rb.begin(), rb.end(), r.hash );
- return r;
-}
-
-
-// MD5 message-digest core computation non-inline member definitions -------//
-
-/** Provides the computed check-sum of all the submitted bits (as if the message
- is complete), through a standard generator interface.
-
- \return The check-sum.
- */
-md5_context::product_type
-md5_context::operator ()() const
-{
- self_type copy( *this );
- copy.finish();
-
- product_type result;
- std::copy( copy.buffer.begin(), copy.buffer.end(), result.hash );
- return result;
-}
-
-// Sample of the table described in RFC 1321, section 3.4, paragraph 4. Its
-// values are taken directly from the "MD5Transform" function in the RFC's
-// section A.3, and are not computed. Of course, the index is zero-based (C++)
-// instead of one-based (RFC).
-md5_context::hash_table_type const md5_context::hashing_table =
- md5_computerX::hashing_table;
-
-// Initial values of the MD buffer, taken from RFC 1321, section 3.3. (Note
-// that the RFC lists each number low-order byte first, while numbers need to be
-// written high-order byte first in C++.)
-md5_context::buffer_type const md5_context::initial_buffer =
- md5_computerX::initial_buffer_;
+md5_context::buffer_type const md5_context::initial_buffer = { {0x67452301ul,
+ 0xEFCDAB89ul, 0x98BADCFEul, 0x10325476ul} };
 
 // Hash an entire block into the running checksum, using RFC 1321, section 3.4
 void
@@ -586,7 +391,7 @@
     \see #generate_hashing_table
  */
 md5_computer::hash_table_type const md5_computer::hashing_table =
- md5_computerX::hashing_table;
+ md5_context::hashing_table;
 
 /** Constructs the hashing sine table based on the directions given in RFC 1321,
     section 3.4, paragraph 4. It should give the same values as


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