Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r71311 - sandbox/endian_ext/boost/integer/endian
From: vicente.botet_at_[hidden]
Date: 2011-04-16 07:52:59


Author: viboes
Date: 2011-04-16 07:52:58 EDT (Sat, 16 Apr 2011)
New Revision: 71311
URL: http://svn.boost.org/trac/boost/changeset/71311

Log:
Integer.Endian Updated doxygen comments
Text files modified:
   sandbox/endian_ext/boost/integer/endian/domain_map.hpp | 22 +++++++++++
   sandbox/endian_ext/boost/integer/endian/endian.hpp | 49 +++++++++++++++++++++++---
   sandbox/endian_ext/boost/integer/endian/endian_binary_stream.hpp | 7 +++
   sandbox/endian_ext/boost/integer/endian/endian_pack.hpp | 74 +++++++++++++++++++++++++++++++++++----
   sandbox/endian_ext/boost/integer/endian/endian_type.hpp | 20 ++++++++++
   sandbox/endian_ext/boost/integer/endian/endian_view.hpp | 56 ++++++++++++++++++++++++++++-
   sandbox/endian_ext/boost/integer/endian/endianness.hpp | 4 ++
   7 files changed, 214 insertions(+), 18 deletions(-)

Modified: sandbox/endian_ext/boost/integer/endian/domain_map.hpp
==============================================================================
--- sandbox/endian_ext/boost/integer/endian/domain_map.hpp (original)
+++ sandbox/endian_ext/boost/integer/endian/domain_map.hpp 2011-04-16 07:52:58 EDT (Sat, 16 Apr 2011)
@@ -9,6 +9,12 @@
 
 //--------------------------------------------------------------------------------------//
 
+/*!
+ \file
+ \brief This file contains the default implementation ofr the domain_map metafunction.
+
+ */
+
 
 #ifndef BOOST_ENDIAN_DOMAIN_MAP__HPP
 #define BOOST_ENDIAN_DOMAIN_MAP__HPP
@@ -42,11 +48,25 @@
 
     }
 
- /// By default the shared endianess of a type depends on whether it is fundamental and or a fusion sequence.
+ /**
+ @Requires @c Domain any class. Can be also @c endianness::big or @c endianness::little.
+ @Result The member typedef type names a mpl tree of sequence of endianness types as view from the point of view of the @c Domain.
+ The default definition is a mpl tree having as leaves the @c Domain class for @c T fundamental types, and fusion sequences.
+
+ @Example
+ @code
+ is_same<domain_map<endianness::big, int>::type, endianness::big>::value == true
+ struct ifA {};
+ @endcode
+
+ The user needs to specialize this metafunction for specific domains.
+ */
+
     template <typename Domain, typename T>
     struct domain_map : endian_detail::domain_map_impl<Domain, T> {};
 
     namespace endian_detail {
+ // By default the shared endianess of a type depends on whether it is fundamental and or a fusion sequence.
 
         // fundamental types are native
         template <typename Domain, typename T, bool IsSeq>

Modified: sandbox/endian_ext/boost/integer/endian/endian.hpp
==============================================================================
--- sandbox/endian_ext/boost/integer/endian/endian.hpp (original)
+++ sandbox/endian_ext/boost/integer/endian/endian.hpp 2011-04-16 07:52:58 EDT (Sat, 16 Apr 2011)
@@ -10,6 +10,12 @@
 
 //--------------------------------------------------------------------------------------//
 
+
+/*!
+ \file
+ \brief Provides integer-like byte-holder binary types with explicit control over byte order, value type, size, and alignment. Typedefs provide easy-to-use names for common configurations.
+ */
+
 // Original design developed by Darin Adler based on classes developed by Mark
 // Borgerding. Four original class templates were combined into a single endian
 // class template by Beman Dawes, who also added the unrolled_byte_loops sign
@@ -31,11 +37,15 @@
 #endif
 
 #include <boost/config.hpp>
+#if !defined(BOOST_ENDIAN_DOXYGEN_INVOKED)
 #define BOOST_MINIMAL_INTEGER_COVER_OPERATORS
 #define BOOST_NO_IO_COVER_OPERATORS
+#endif
 #include <boost/integer/endian/cover_operators.hpp>
+#if !defined(BOOST_ENDIAN_DOXYGEN_INVOKED)
 #undef BOOST_NO_IO_COVER_OPERATORS
 #undef BOOST_MINIMAL_INTEGER_COVER_OPERATORS
+#endif
 #include <boost/type_traits/is_signed.hpp>
 #include <boost/cstdint.hpp>
 #include <boost/static_assert.hpp>
@@ -50,7 +60,20 @@
   namespace integer
   {
 
- template <typename E,
+ /**
+ An endian integer is an integer byte-holder with user-specified endianness, value type, size, and alignment.
+ The usual operations on integers are supplied.
+
+.
+
+ @Requires
+ - @c E is one of @c endianness::big or @c endianness::little.
+ - @c T must be a POD with value semantics.
+ - @c nbits is a multiple of @c 8
+ - If @c A is @c alignment::aligned then @c nbits must be equal to @c 8*sizeof(T)
+
+ */
+ template <typename E,
         typename T,
         std::size_t n_bits=sizeof(T)*8,
         BOOST_SCOPED_ENUM(alignment) A = alignment::aligned
@@ -65,22 +88,34 @@
         BOOST_STATIC_CONSTEXPR std::size_t width = n_bits;
         BOOST_STATIC_CONSTEXPR BOOST_SCOPED_ENUM(alignment) alignment_value = A;
         
-# ifndef BOOST_ENDIAN_NO_CTORS
+# ifndef BOOST_ENDIAN_NO_CTORS || defined(BOOST_ENDIAN_DOXYGEN_INVOKED)
+ //! @Effects Constructs an object of type @c endian<E,T,n_bits,A>
+ //! @Note if @c BOOST_ENDIAN_FORCE_PODNESS is defined && C++0x POD's are not available then this constructor will not be present
         endian() BOOST_ENDIAN_DEFAULT_CONSTRUCT
+
+ //! @Effects: Constructs an object of type @c endian<E,T,n_bits,A>.
+ //! @Postcondition @c x==v, where @c x is the constructed object.
+ //! @Note if @c BOOST_ENDIAN_FORCE_PODNESS is defined && C++0x POD's are not available then this constructor will not be present
         template <typename T2>
         explicit endian(T2 val)
             : pack_(val)
         {
         }
 # endif
+ //! @Postcondition @c value_type(*this)==val.
+ //! @Returns @c *this.
         endian & operator=(T val) {
             pack_=val;
             return *this;
         }
+
+ //! @Returns The current value stored in @c *this, converted to @c value_type.
         operator T() const
         {
           return T(pack_);
         }
+
+ //! @Returns The pointer to current value stored in @c *this, converted to <c>const char*</c>.
         const char* data() const { return pack_.data(); }
 
     };
@@ -147,10 +182,12 @@
     typedef endian< native_endian, uint_least64_t, 56, alignment::unaligned > unative56_t;
     typedef endian< native_endian, uint_least64_t, 64, alignment::unaligned > unative64_t;
 
+#if !defined(BOOST_ENDIAN_DOXYGEN_INVOKED)
 #define BOOST_HAS_INT16_T
 #define BOOST_HAS_INT32_T
 #define BOOST_HAS_INT64_T
-
+#endif
+
   // These types only present if platform has exact size integers:
   // aligned big endian signed integer types
   // aligned big endian unsigned integer types
@@ -160,21 +197,21 @@
   // aligned native endian typedefs are not provided because
   // <cstdint> types are superior for this use case
 
-# if defined(BOOST_HAS_INT16_T)
+# if defined(BOOST_HAS_INT16_T) || defined(BOOST_ENDIAN_DOXYGEN_INVOKED)
     typedef endian< big_endian, int16_t, 16, alignment::aligned > aligned_big16_t;
     typedef endian< big_endian, uint16_t, 16, alignment::aligned > aligned_ubig16_t;
     typedef endian< little_endian, int16_t, 16, alignment::aligned > aligned_little16_t;
     typedef endian< little_endian, uint16_t, 16, alignment::aligned > aligned_ulittle16_t;
 # endif
 
-# if defined(BOOST_HAS_INT32_T)
+# if defined(BOOST_HAS_INT32_T) || defined(BOOST_ENDIAN_DOXYGEN_INVOKED)
     typedef endian< big_endian, int32_t, 32, alignment::aligned > aligned_big32_t;
     typedef endian< big_endian, uint32_t, 32, alignment::aligned > aligned_ubig32_t;
     typedef endian< little_endian, int32_t, 32, alignment::aligned > aligned_little32_t;
     typedef endian< little_endian, uint32_t, 32, alignment::aligned > aligned_ulittle32_t;
 # endif
 
-# if defined(BOOST_HAS_INT64_T)
+# if defined(BOOST_HAS_INT64_T) || defined(BOOST_ENDIAN_DOXYGEN_INVOKED)
     typedef endian< big_endian, int64_t, 64, alignment::aligned > aligned_big64_t;
     typedef endian< big_endian, uint64_t, 64, alignment::aligned > aligned_ubig64_t;
     typedef endian< little_endian, int64_t, 64, alignment::aligned > aligned_little64_t;

Modified: sandbox/endian_ext/boost/integer/endian/endian_binary_stream.hpp
==============================================================================
--- sandbox/endian_ext/boost/integer/endian/endian_binary_stream.hpp (original)
+++ sandbox/endian_ext/boost/integer/endian/endian_binary_stream.hpp 2011-04-16 07:52:58 EDT (Sat, 16 Apr 2011)
@@ -7,6 +7,13 @@
 
 // See library home page at http://www.boost.org/libs/integer/endian
 
+
+/*!
+ \file
+ \brief provides operators @c <= and @c => for unformatted binary (as opposed to formatted character) stream
+ insertion and extraction of endian types.
+ */
+
 #ifndef BOOST_ENDIAN_BINARY_STREAM_HPP
 #define BOOST_ENDIAN_BINARY_STREAM_HPP
 

Modified: sandbox/endian_ext/boost/integer/endian/endian_pack.hpp
==============================================================================
--- sandbox/endian_ext/boost/integer/endian/endian_pack.hpp (original)
+++ sandbox/endian_ext/boost/integer/endian/endian_pack.hpp 2011-04-16 07:52:58 EDT (Sat, 16 Apr 2011)
@@ -11,6 +11,15 @@
 
 //--------------------------------------------------------------------------------------//
 
+
+/*!
+ \file
+ \brief This file contains the core class template of Boost.Integer.Endian.
+
+ Provides byte-holder binary types with explicit control over byte order, value type, size, and alignment.
+ Typedefs provide easy-to-use names for common configurations.
+ */
+
 // Original design developed by Darin Adler based on classes developed by Mark
 // Borgerding. Four original class templates were combined into a single endian
 // class template by Beman Dawes, who also added the unrolled_byte_loops sign
@@ -21,12 +30,13 @@
 // Definition of native depending on BOOST_BIG_ENDIAN to big or little done by Vicente J. Botet Escriba.
 // Change the definition of endian_pack using types instead of enum endianness done by Vicente J. Botet Escriba.
 
-
-#define BOOST_ENDIAN_ALLOWS_UDT
-
 #ifndef BOOST_INTEGER_ENDIAN_PACK_HPP
 #define BOOST_INTEGER_ENDIAN_PACK_HPP
 
+#if !defined(BOOST_ENDIAN_DOXYGEN_INVOKED)
+#define BOOST_ENDIAN_ALLOWS_UDT
+#endif
+
 #ifdef BOOST_ENDIAN_LOG
 # include <iostream>
 #endif
@@ -46,6 +56,7 @@
 
 # include <boost/integer/endian/endianness.hpp>
 
+#if !defined(BOOST_ENDIAN_DOXYGEN_INVOKED)
 # if CHAR_BIT != 8
 # error Platforms with CHAR_BIT != 8 are not supported
 # endif
@@ -59,6 +70,7 @@
 # if defined(BOOST_ENDIAN_FORCE_PODNESS)
 # define BOOST_ENDIAN_NO_CTORS
 # endif
+# endif
 
 
 namespace boost
@@ -191,11 +203,52 @@
  
     BOOST_SCOPED_ENUM_START(alignment) { unaligned, aligned }; BOOST_SCOPED_ENUM_END
 
+ /**
+ An @c endian_pack is a byte-holder with user-specified endianness, value type, size, and alignment.
+
+ @Requires
+ - @c E is one of @c endianness::big or @c endianness::little.
+ - @c T must be a POD with value semantics.
+ - @c nbits is a multiple of @c 8
+ - If @c A is @c alignment::aligned then @c nbits must be equal to @c 8*sizeof(T)
+
+ */
     template <typename E,
         typename T,
         std::size_t n_bits=sizeof(T)*8,
         BOOST_SCOPED_ENUM(alignment) A = alignment::aligned
- > class endian_pack;
+ >
+#if !defined(BOOST_ENDIAN_DOXYGEN_INVOKED)
+ class endian_pack;
+#else
+ class endian_pack {
+ public:
+ typedef E endian_type;
+ typedef T value_type;
+ BOOST_STATIC_CONSTEXPR std::size_t width = n_bits;
+ BOOST_STATIC_CONSTEXPR BOOST_SCOPED_ENUM(alignment) alignment_value = A;
+ //! @Effects Constructs an object of type @c endian_pack<E,T,n_bits,A>
+ //! @Note if @c BOOST_ENDIAN_FORCE_PODNESS is defined && C++0x POD's are not available then this constructor will not be present
+ endian_pack() = default;
+ //! @Effects: Constructs an object of type @c endian_pack<E,T,n_bits,A>.
+ //! @Postcondition @c x==v, where @c x is the constructed object.
+ //! @Note if @c BOOST_ENDIAN_FORCE_PODNESS is defined && C++0x POD's are not available then this constructor will not be present
+ template <typename T2>
+ explicit endian_pack(T2 val);
+
+ //! @Postcondition @c value_type(*this)==val.
+ //! @Returns @c *this.
+ endian_pack & operator=(T val);
+
+ //! @Returns The current value stored in @c *this, converted to @c value_type.
+ operator T() const;
+
+ //! @Returns The pointer to current value stored in @c *this, converted to <c>const char*</c>.
+ const char* data() const;
+};
+
+#endif
+#if !defined(BOOST_ENDIAN_DOXYGEN_INVOKED)
 
     // Specializations that represent unaligned bytes.
     // Taking an integer type as a parameter provides a nice way to pass both
@@ -395,6 +448,7 @@
           T m_value;
     };
 #endif // defined(BOOST_ENDIAN_ALLOWS_UDT)
+#endif
 
   // naming convention typedefs ------------------------------------------------------//
 
@@ -458,10 +512,13 @@
     typedef endian_pack< native_endian, uint_least64_t, 56, alignment::unaligned > unative56_pt;
     typedef endian_pack< native_endian, uint_least64_t, 64, alignment::unaligned > unative64_pt;
 
+#if !defined(BOOST_ENDIAN_DOXYGEN_INVOKED)
+
 #define BOOST_HAS_INT16_T
 #define BOOST_HAS_INT32_T
 #define BOOST_HAS_INT64_T
-
+#endif
+
   // These types only present if platform has exact size integers:
   // aligned big endian_pack signed integer types
   // aligned big endian_pack unsigned integer types
@@ -471,21 +528,21 @@
   // aligned native endian_pack typedefs are not provided because
   // <cstdint> types are superior for this use case
 
-# if defined(BOOST_HAS_INT16_T)
+# if defined(BOOST_HAS_INT16_T) || defined(BOOST_ENDIAN_DOXYGEN_INVOKED)
     typedef endian_pack< big_endian, int16_t, 16, alignment::aligned > aligned_big16_pt;
     typedef endian_pack< big_endian, uint16_t, 16, alignment::aligned > aligned_ubig16_pt;
     typedef endian_pack< little_endian, int16_t, 16, alignment::aligned > aligned_little16_pt;
     typedef endian_pack< little_endian, uint16_t, 16, alignment::aligned > aligned_ulittle16_pt;
 # endif
 
-# if defined(BOOST_HAS_INT32_T)
+# if defined(BOOST_HAS_INT32_T) || defined(BOOST_ENDIAN_DOXYGEN_INVOKED)
     typedef endian_pack< big_endian, int32_t, 32, alignment::aligned > aligned_big32_pt;
     typedef endian_pack< big_endian, uint32_t, 32, alignment::aligned > aligned_ubig32_pt;
     typedef endian_pack< little_endian, int32_t, 32, alignment::aligned > aligned_little32_pt;
     typedef endian_pack< little_endian, uint32_t, 32, alignment::aligned > aligned_ulittle32_pt;
 # endif
 
-# if defined(BOOST_HAS_INT64_T)
+# if defined(BOOST_HAS_INT64_T) || defined(BOOST_ENDIAN_DOXYGEN_INVOKED)
     typedef endian_pack< big_endian, int64_t, 64, alignment::aligned > aligned_big64_pt;
     typedef endian_pack< big_endian, uint64_t, 64, alignment::aligned > aligned_ubig64_pt;
     typedef endian_pack< little_endian, int64_t, 64, alignment::aligned > aligned_little64_pt;
@@ -511,3 +568,4 @@
 #endif
 
 #endif // BOOST_INTEGER_ENDIAN_PACK_HPP
+

Modified: sandbox/endian_ext/boost/integer/endian/endian_type.hpp
==============================================================================
--- sandbox/endian_ext/boost/integer/endian/endian_type.hpp (original)
+++ sandbox/endian_ext/boost/integer/endian/endian_type.hpp 2011-04-16 07:52:58 EDT (Sat, 16 Apr 2011)
@@ -9,6 +9,12 @@
 
 //--------------------------------------------------------------------------------------//
 
+
+/*!
+ \file
+ \brief
+ */
+
 #ifndef BOOST_INTEGER_ENDIAN_TYPE_HPP
 #define BOOST_INTEGER_ENDIAN_TYPE_HPP
 
@@ -43,6 +49,20 @@
 
 }
 
+/**
+ The member typedef type names one of the endianness types @c big, @c little or @c mixed.
+ If all the leaves of the type T are of the same endianness type is this endiannes, otherwise it is mixed.
+
+The default behavior works for all the endian aware types, fundamental types and any type that is a fusion sequence.
+
+The user can specialize this metafunction for specific clases.
+
+@Example
+@code
+is_same<endian_type<endian<endianness::big, int> >::type, endianness::big>::value == true
+is_same<endian_type<int>::type, endianness::native>::value == true
+@endcode
+*/
 template <typename T>
 struct endian_type : integer_detail::endian_type_impl<T> {
 };

Modified: sandbox/endian_ext/boost/integer/endian/endian_view.hpp
==============================================================================
--- sandbox/endian_ext/boost/integer/endian/endian_view.hpp (original)
+++ sandbox/endian_ext/boost/integer/endian/endian_view.hpp 2011-04-16 07:52:58 EDT (Sat, 16 Apr 2011)
@@ -9,6 +9,11 @@
 
 //--------------------------------------------------------------------------------------//
 
+/*!
+ \file
+ \brief This file provides the @c endian_view<> class template as well as some factory helper functions.
+ */
+
 
 #ifndef BOOST_INTEGER_ENDIAN_VIEW_HPP
 #define BOOST_INTEGER_ENDIAN_VIEW_HPP
@@ -19,7 +24,8 @@
 
 namespace boost {
 namespace integer {
-namespace endianness {
+#if !defined(BOOST_ENDIAN_DOXYGEN_INVOKED)
+ namespace endianness {
 
     template <typename EndianSource, typename T>
     void convert_from(T& r);
@@ -27,12 +33,38 @@
     void convert_to(T& r);
     template <typename EndianTarget, typename EndianSource, typename T>
     void convert_to_from(T& r);
-}
+ }
+#endif
     template <typename Endian, typename T,
                     bool IsFundamental = is_fundamental<T>::value,
                     bool IsSeq = fusion::traits::is_sequence<T>::value
>
+#if !defined(BOOST_ENDIAN_DOXYGEN_INVOKED)
     class endian_view;
+#else
+ class endian_view {
+ typedef T value_type;
+
+ //! @Effects Constructs an object of type @c endian_view<E, T, n_bits, A>.
+ endian_view(value_type& ref);
+
+ //! @Returns The converted @c value_type of the referenced type as it was seen as an endian aware type.
+ operator value_type() const;
+
+ //! @Postcondition <c>value_type(this->ref_) == v</c>.
+ //! @Returns @c *this.
+ endian_view& operator=(value_type val);
+ //! @Postcondition <c>this->ref_ == rhs.ref_</c>.
+ //! @Returns @c *this.
+ endian_view& operator=(endian_view const& rhs);
+
+ //! @Postcondition <c>value_type(this->ref_) == value_type(rhs.ref_)</c>.
+ //! @Returns @c*this.
+ template <typename Endian2 >
+ endian_view& operator=(endian_view<Endian2,T,true,false> const& rhs);
+ };
+#endif
+#if !defined(BOOST_ENDIAN_DOXYGEN_INVOKED)
 
     template <typename Endian, typename T >
     class endian_view<Endian,T,true,false>
@@ -44,22 +76,34 @@
         value_type &ref_;
         
         typedef endian_pack<Endian,value_type> endian_t;
+
+ //! @Effects Constructs an object of type @c endian_view<E, T, n_bits, A>.
         endian_view(value_type& ref) : ref_(ref) {};
+
+ //! @Returns The converted @c value_type of the referenced type as it was seen as an endian aware type.
         operator value_type() const {
             endian_t& v=reinterpret_cast<endian_t&>(ref_);
             return v;
         }
+
+ //! @Postcondition <c>value_type(this->ref_) == v</c>.
+ //! @Returns @c *this.
         endian_view& operator=(value_type val) {
             endian_t& v=reinterpret_cast<endian_t&>(ref_);
             v=val;
             return *this;
         }
+ //! @Postcondition <c>this->ref_ == rhs.ref_</c>.
+ //! @Returns @c *this.
         endian_view& operator=(endian_view const& rhs) {
             if (this!=&rhs) {
                 ref_=rhs.ref_;
             }
             return *this;
         }
+
+ //! @Postcondition <c>value_type(this->ref_) == value_type(rhs.ref_)</c>.
+ //! @Returns @c*this.
         template <typename Endian2 >
         endian_view& operator=(endian_view<Endian2,T,true,false> const& rhs) {
             endian_t& v=reinterpret_cast<endian_t&>(ref_);
@@ -100,23 +144,29 @@
             return *this;
         }
     };
+#endif
     
+ //! @Returns An @c endian_view<> that depend on the endianness parameter @c E referencing the pararameter @c v.
     template <typename E, typename T>
     endian_view<E,T> as_endian(T& v) {
         return endian_view<E,T>(v);
     }
  
+ //! @Returns A native endian @c endian_view<native_endian> referencing the pararameter @c v.
     template <typename T>
     endian_view<native_endian,T> as(T& v)
     {
- return as_endian<native_endian>(v);
+ return as_endian<native_endian>(v);
     }
+
+ //! @Returns A little endian @c endian_view<little_endian> referencing the pararameter @c v.
     template <typename T>
     endian_view<little_endian,T> as_little(T& v)
     {
         return as_endian<little_endian>(v);
     }
     
+ //! @Returns A little endian @c endian_view<big_endian> referencing the pararameter @c v.
     template <typename T>
     endian_view<big_endian,T> as_big(T& v)
     {

Modified: sandbox/endian_ext/boost/integer/endian/endianness.hpp
==============================================================================
--- sandbox/endian_ext/boost/integer/endian/endianness.hpp (original)
+++ sandbox/endian_ext/boost/integer/endian/endianness.hpp 2011-04-16 07:52:58 EDT (Sat, 16 Apr 2011)
@@ -9,6 +9,10 @@
 
 //--------------------------------------------------------------------------------------//
 
+/*!
+ \file
+ \brief Provides the endianness tags.
+ */
 
 #ifndef BOOST_ENDIAN_ENDIANNESS__HPP
 #define BOOST_ENDIAN_ENDIANNESS__HPP


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