Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r62761 - sandbox/SOC/2010/bit_masks/boost/integer
From: bbartmanboost_at_[hidden]
Date: 2010-06-10 16:08:28


Author: bbartman
Date: 2010-06-10 16:08:27 EDT (Thu, 10 Jun 2010)
New Revision: 62761
URL: http://svn.boost.org/trac/boost/changeset/62761

Log:
completed work on referance type for bitfield_type
Text files modified:
   sandbox/SOC/2010/bit_masks/boost/integer/bitfield_tuple.hpp | 69 ++++++++++++++++++++++++++++++++++++++-
   1 files changed, 66 insertions(+), 3 deletions(-)

Modified: sandbox/SOC/2010/bit_masks/boost/integer/bitfield_tuple.hpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/boost/integer/bitfield_tuple.hpp (original)
+++ sandbox/SOC/2010/bit_masks/boost/integer/bitfield_tuple.hpp 2010-06-10 16:08:27 EDT (Thu, 10 Jun 2010)
@@ -7,7 +7,8 @@
 #ifndef BOOST_BITFIELD_TUPLE_HPP
 #define BOOST_BITFIELD_TUPLE_HPP
 #include <boost/integer/details/storage.hpp>
-
+#include <boost/integer/bits_mask.hpp>
+#include <string>
 #include <boost/integer/details/member.hpp>
 #include <boost/integer/bit_width.hpp>
 #include <cstddef>
@@ -403,8 +404,54 @@
     typedef typename _base::processed_args processed_args;
     typedef typename _base::field_vector members;
     typedef typename _base::storage_type storage_type;
+ typedef typename _base::offset bits_used;
 
+
+ /** Proxy type returned by get functions.
+ * This serves as the go between things within this class.
+ */
+ template <typename MaskInfo>
+ struct bit_ref {
 
+ /** typedefs
+ * return_type - is the type which is retrieved from
+ * within storage is turned into and returned as.
+ *
+ * mask - contains all information needed to iteract with data in the
+ * the stroage.
+ */
+ typedef typename MaskInfo::return_type return_type;
+ typedef bits_mask<
+ typename MaskInfo::storage_type,
+ MaskInfo::offset,
+ MaskInfo::field_width
+ > mask;
+
+ typedef bit_ref<MaskInfo> _self;
+
+ /** Reference constructor.
+ * Because the bit_ref is an abstraction of a reference then it also
+ * must behave like a reference type.
+ */
+ bit_ref(storage_type& ref)
+ :_ref(ref)
+ { }
+
+ operator return_type() const {
+ return (_ref & mask()) >> mask::offset;
+ }
+
+
+ _self const& operator=(return_type const& rhs) {
+ _ref ^= (_ref & mask());
+ _ref |= (static_cast<storage_type>(rhs) << mask::offset);
+ return *this;
+ }
+
+ private:
+ storage_type& _ref;
+ bit_ref(); // not default constructible.
+ };
 
 
     /** Value constructor.
@@ -435,7 +482,11 @@
 
     // TODO: look into the creation of a member wise constructor.
     
- /** Interface: Stack Allocated.
+ _self const& operator=(_self const& x) {
+ this->_data = x._data;
+ }
+
+ /**
      * Retuns a copy of the internally stored type.
      */
     //@{
@@ -447,8 +498,20 @@
          return this->get_data();
     }
     //@}
+
+ /** Returns a string with the bits from the internal storage within it. */
+ //@{
+ std::string to_string() const;
+ //@}
+
+
+ /** Get function interfaces.
+ * These provide access into the tuple.
+ */
+ //@{
     
-};
+ //@}
+};
 
 
 


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