Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r62453 - in sandbox/SOC/2010/bit_masks: boost/integer lib/integer/doc lib/integer/test
From: bbartmanboost_at_[hidden]
Date: 2010-06-05 14:22:44


Author: bbartman
Date: 2010-06-05 14:22:43 EDT (Sat, 05 Jun 2010)
New Revision: 62453
URL: http://svn.boost.org/trac/boost/changeset/62453

Log:
working on integrating the boost.fusion sequence stuff with bit_mask_group
Text files modified:
   sandbox/SOC/2010/bit_masks/boost/integer/bit_mask_group.hpp | 40 +++++++++++++++++++++++++---------------
   sandbox/SOC/2010/bit_masks/lib/integer/doc/main.qbk | 4 ++++
   sandbox/SOC/2010/bit_masks/lib/integer/doc/rationale.qbk | 36 ++++++++++++++++++++++++++++++++++++
   sandbox/SOC/2010/bit_masks/lib/integer/test/bit_mask_group_test.cpp | 6 +++---
   4 files changed, 68 insertions(+), 18 deletions(-)

Modified: sandbox/SOC/2010/bit_masks/boost/integer/bit_mask_group.hpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/boost/integer/bit_mask_group.hpp (original)
+++ sandbox/SOC/2010/bit_masks/boost/integer/bit_mask_group.hpp 2010-06-05 14:22:43 EDT (Sat, 05 Jun 2010)
@@ -21,11 +21,11 @@
 
 namespace boost {
 
-template <typename NameType, typename T>
-struct named {
- typedef NameType name;
- typedef T value;
- typedef named<NameType, T> type;
+template <typename T, typename NameType>
+struct tagged {
+ typedef NameType name;
+ typedef T value;
+ typedef tagged<NameType, T> type;
 };
 
 // TODO: move this into a sperate file
@@ -62,10 +62,15 @@
 template <typename TypeVector, typename NamedTypeMap>
 struct bit_mask_group_impl_< unused_parameter, TypeVector, NamedTypeMap > {
 
- typedef bit_mask_group_impl_< unused_parameter, TypeVector, NamedTypeMap> type;
- typedef unused_parameter type_added;
- typedef TypeVector type_vector;
- typedef NamedTypeMap named_type_map;
+ typedef bit_mask_group_impl_<
+ unused_parameter,
+ TypeVector,
+ NamedTypeMap
+ > type;
+
+ typedef unused_parameter type_added;
+ typedef TypeVector type_vector;
+ typedef NamedTypeMap named_type_map;
 
     // fake adding the parameter to the TypeVector instead do nothing.
     template <typename NewT>
@@ -78,13 +83,18 @@
 /** Used for dealing with the "named" types or types which basically contain a
  * single tag which allows them to be referenced instead of an index.
  */
-template <typename Name, typename Value, typename TypeVector, typename NamedTypeMap>
-struct bit_mask_group_impl_< named<Name, Value>, TypeVector, NamedTypeMap>
+template < typename Name,
+ typename Value,
+ typename TypeVector,
+ typename NamedTypeMap>
+struct bit_mask_group_impl_< tagged<Value, Name>, TypeVector, NamedTypeMap>
 {
- typedef bit_mask_group_impl_< Value, TypeVector, NamedTypeMap> type;
- typedef Value type_added;
- typedef typename mpl::push_back<TypeVector, Value>::type type_vector;
- typedef typename mpl::insert<NamedTypeMap,mpl::pair<Name,Value> >::type named_type_map;
+ typedef bit_mask_group_impl_< Value, TypeVector, NamedTypeMap> type;
+ typedef Value type_added;
+ typedef typename mpl::push_back<TypeVector, Value>::type type_vector;
+ typedef typename mpl::insert<
+ NamedTypeMap,mpl::pair<Name, Value>
+ >::type named_type_map;
 
     template <typename NewT>
     struct add {

Modified: sandbox/SOC/2010/bit_masks/lib/integer/doc/main.qbk
==============================================================================
--- sandbox/SOC/2010/bit_masks/lib/integer/doc/main.qbk (original)
+++ sandbox/SOC/2010/bit_masks/lib/integer/doc/main.qbk 2010-06-05 14:22:43 EDT (Sat, 05 Jun 2010)
@@ -98,3 +98,7 @@
 [include:high_bits_mask high_bits.qbk]
 [include:low_bits_mask low_bits.qbk]
 [include:bits_mask bits_mask.qbk]
+[include:rationale rationale.qbk]
+
+
+

Modified: sandbox/SOC/2010/bit_masks/lib/integer/doc/rationale.qbk
==============================================================================
--- sandbox/SOC/2010/bit_masks/lib/integer/doc/rationale.qbk (original)
+++ sandbox/SOC/2010/bit_masks/lib/integer/doc/rationale.qbk 2010-06-05 14:22:43 EDT (Sat, 05 Jun 2010)
@@ -0,0 +1,36 @@
+[section:rationale Rationale And Motivation]
+The motivation and rationale behind the creation a bit masking library stems
+from the following example:
+``
+struct foo {
+ bool b1:1;
+ bool b2:1;
+ int i1:2;
+ int i2:2;
+};
+``
+The struct `foo` is composed of bit fields. This is fine and wouldn't be a big
+issues accept that there is something which the user can't see that can cause
+problems with this struct. The size of struct `foo` need not be any larger then
+`char`, 1 byte, which is the smalles type which can hold it. Now the actual size
+of `foo` is 4 bytes. This can cause havoc if a union was made with this type and
+a char while the user was thinking that their type is 1 byte in size. So in order
+to create something which could handle this situation correctly. This library
+was created to help with the internal management and storage bit fields and
+non-standardly aligned data. The goal is to provide both masking utilities and
+commonlly used structures which would be able to correct the size of the
+structure and provide simple accessors to the data stored within.
+
+[h3 Project Data Structure Motivation and Rationale]
+There are several data structures provided which make doing some slightly more
+complex tasks simple and organized. The structures which the library provides
+are `bit_mask_group`, `bit_mask_tuple`, `bit_field_tuple` and
+`pointer_plus_bits`.
+
+
+`bit_mask_group` is not a container it doesn't store any data however it
+provides a way of organizing your masks. The structure also provides additional
+run time support on top of its tuple style interface.
+
+[endsect]
+

Modified: sandbox/SOC/2010/bit_masks/lib/integer/test/bit_mask_group_test.cpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/lib/integer/test/bit_mask_group_test.cpp (original)
+++ sandbox/SOC/2010/bit_masks/lib/integer/test/bit_mask_group_test.cpp 2010-06-05 14:22:43 EDT (Sat, 05 Jun 2010)
@@ -10,9 +10,9 @@
 struct name_tag { };
 int main() {
     typedef bit_mask_group<
- named<
- name_tag,
- low_bits_mask<int,9>
+ tagged<
+ low_bits_mask<int,9>,
+ name_tag
>,
         bits_mask<int,3,9>
> testing_type1;


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