$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r64567 - in sandbox/SOC/2010/bit_masks: boost/integer boost/integer/detail/bitfield_vector lib/integer/test lib/integer/test/bitfield_vector_testing
From: bbartmanboost_at_[hidden]
Date: 2010-08-03 09:00:59
Author: bbartman
Date: 2010-08-03 09:00:57 EDT (Tue, 03 Aug 2010)
New Revision: 64567
URL: http://svn.boost.org/trac/boost/changeset/64567
Log:
removing extra test file and beginning work on the test suite for the proxy_referece_type used by the bitfield_vector
Removed:
   sandbox/SOC/2010/bit_masks/lib/integer/test/bitfield_vector_testing/reference_type_test.cpp
Text files modified: 
   sandbox/SOC/2010/bit_masks/boost/integer/bitfield_vector.hpp                                    |     1                                         
   sandbox/SOC/2010/bit_masks/boost/integer/detail/bitfield_vector/bitfield_vector_member_impl.hpp |    89 ++++++++++++++++++++++++++++++++++++++++
   sandbox/SOC/2010/bit_masks/lib/integer/test/Jamfile.v2                                          |     2                                         
   sandbox/SOC/2010/bit_masks/lib/integer/test/bitfield_vector_testing/proxy_reference_test.cpp    |    17 +++++++                                 
   4 files changed, 108 insertions(+), 1 deletions(-)
Modified: sandbox/SOC/2010/bit_masks/boost/integer/bitfield_vector.hpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/boost/integer/bitfield_vector.hpp	(original)
+++ sandbox/SOC/2010/bit_masks/boost/integer/bitfield_vector.hpp	2010-08-03 09:00:57 EDT (Tue, 03 Aug 2010)
@@ -158,6 +158,7 @@
             this->_impl._end = ptr + next_allocation_size;
         }
     }
+    
 };
 
 } // end boost
Modified: sandbox/SOC/2010/bit_masks/boost/integer/detail/bitfield_vector/bitfield_vector_member_impl.hpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/boost/integer/detail/bitfield_vector/bitfield_vector_member_impl.hpp	(original)
+++ sandbox/SOC/2010/bit_masks/boost/integer/detail/bitfield_vector/bitfield_vector_member_impl.hpp	2010-08-03 09:00:57 EDT (Tue, 03 Aug 2010)
@@ -68,6 +68,95 @@
     }
 };
 
+/** This is the proxy reference type used by the iterator and by the 
+ *  bitfield_tuple for accessing the storage and correctly returning
+ *  and setting the values within the bitfield_vector.
+ */
+template <typename ReturnType,std::size_t Width>
+class proxy_reference_type {
+    typedef proxy_reference_type<ReturnType,Width> _self;
+    proxy_reference_type();
+public:
+    /** Typedefs and integral static constant values. */
+    //@{
+    typedef unsigned char       storage_type;
+    typedef ReturnType          value_type;
+    typedef std::size_t         offset_type;
+    BOOST_STATIC_CONSTANT( std::size_t, width = Width );
+    //@}
+    
+    /** constructors and destructor for the proxy_reference_type type. */
+    //@{
+
+    /** Copy Constructor. */
+    proxy_reference_type(_self const& x)
+        :_ptr(x._ptr), _offset(x._offset)
+    { }
+
+    /** pointer, offset constructor. */
+    proxy_reference_type(storage_type* ptr, offset_type offset)
+        :_ptr(ptr), _offset(offset)
+    { }
+    //@}
+
+    /** Copy assignment. */
+    _self& operator=(_self const& x) {
+        _ptr = x._ptr;
+        _offset = x._offset;
+        return *this;
+    }
+
+    /** Implicit Conversion Operator*/
+    operator value_type() const {
+        value_type ret;
+        // std::size_t bit_index = 0;
+        storage_type* byte_ptr = _ptr;
+        std::size_t remaining_bits = width;
+
+        // creating head mask.
+        storage_type mask = ~(~storage_type(0) << (8 - _offset));
+        // keep track of how many bits from the width have been extraced.
+        remaining_bits -= (8 - _offset);
+        // update return type.
+        ret = value_type(mask & *byte_ptr) << (remaining_bits);
+        // make sure to return if we are finished.
+        if(remaining_bits == 0) {
+            return ret;
+        }
+        // next loop while the
+        ++byte_ptr;
+        mask = ~storage_type(0);
+        while((remaining_bits / 8) > 0) {
+            ret |= value_type(mask & *byte_ptr) << (remaining_bits);
+            
+            // increment values so that everything is
+            // correctly retrieved.
+            remaining_bits -= 8;
+            ++byte_ptr;
+        }
+        // because the field could have ended on a byte boundry then
+        // I must then check before exiting.
+        if(remaining_bits == 0) {
+            return ret;
+        }
+        // if I reached this point it means that I must now deal with the
+        // trailing bits of the field.
+        mask = ~(~storage_type(0) >> remaining_bits);
+        return ret | (value_type(mask & *byte_ptr)<<(remaining_bits));
+    }
+
+    /** value_type storage assignement operator.*/
+    _self& operator=(value_type x);
+
+    bool operator==(_self const& rhs);
+    bool operator!=(_self const& rhs);
+    bool operator<(_self const& rhs);
+private:
+    /** Member variables. */
+    storage_type _ptr;
+    offset_type _offset;
+};
+
 }} // end boost::detail
 
 
Modified: sandbox/SOC/2010/bit_masks/lib/integer/test/Jamfile.v2
==============================================================================
--- sandbox/SOC/2010/bit_masks/lib/integer/test/Jamfile.v2	(original)
+++ sandbox/SOC/2010/bit_masks/lib/integer/test/Jamfile.v2	2010-08-03 09:00:57 EDT (Tue, 03 Aug 2010)
@@ -73,7 +73,7 @@
         [ run bft_testing/get_free_function_test.cpp ]
         [ run bitfield_vector_testing/bitfield_vector_test.cpp ]
         [ run bitfield_vector_testing/bitfield_vector_base_test.cpp ]
-        [ run bitfield_vector_testing/reference_type_test.cpp ]
+        [ run bitfield_vector_testing/proxy_reference_test.cpp ]
         [ run bitfield_vector_testing/member_impl_test.cpp ]
     ;
 
Modified: sandbox/SOC/2010/bit_masks/lib/integer/test/bitfield_vector_testing/proxy_reference_test.cpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/lib/integer/test/bitfield_vector_testing/proxy_reference_test.cpp	(original)
+++ sandbox/SOC/2010/bit_masks/lib/integer/test/bitfield_vector_testing/proxy_reference_test.cpp	2010-08-03 09:00:57 EDT (Tue, 03 Aug 2010)
@@ -0,0 +1,17 @@
+//  Copyright 2010 Brian Bartman.
+//  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)
+
+
+#include <boost/integer/bitfield_vector.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+/** Proxy Reference Type.
+ *  Suite for proxy reference type.
+ */
+int main() {
+    return boost::report_errors();
+}
+
+
Deleted: sandbox/SOC/2010/bit_masks/lib/integer/test/bitfield_vector_testing/reference_type_test.cpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/lib/integer/test/bitfield_vector_testing/reference_type_test.cpp	2010-08-03 09:00:57 EDT (Tue, 03 Aug 2010)
+++ (empty file)
@@ -1,12 +0,0 @@
-//  Copyright 2010 Brian Bartman.
-//  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)
-
-
-#include <boost/integer/bitfield_vector.hpp>
-#include <boost/detail/lightweight_test.hpp>
-
-int main() {
-    return boost::report_errors();
-}