diff --git a/boost/integer/cover_operators.hpp b/boost/integer/cover_operators.hpp index 7ddea20..56cf3c8 100644 --- a/boost/integer/cover_operators.hpp +++ b/boost/integer/cover_operators.hpp @@ -12,6 +12,8 @@ // then a smaller number of cover operations are needed. Define the macro // BOOST_MINIMAL_INTEGER_COVER_OPERATORS to indicate this. +// Define BOOST_NO_IO_COVER_OPERATORS if I/O cover operations are not desired. + //----------------------------------------------------------------------------// #ifndef BOOST_INTEGER_COVER_OPERATORS_HPP @@ -87,6 +89,7 @@ namespace boost } # endif +# ifndef BOOST_NO_IO_COVER_OPERATORS // TODO: stream I/O needs to be templatized on the stream type, so will // work with wide streams, etc. @@ -100,6 +103,7 @@ namespace boost x = i; return s; } +# endif }; } // namespace integer } // namespace boost diff --git a/boost/integer/endian.hpp b/boost/integer/endian.hpp index 62468da..fb2584d 100644 --- a/boost/integer/endian.hpp +++ b/boost/integer/endian.hpp @@ -1,43 +1,37 @@ -// Boost endian.hpp header file ---------------------------------------------// +// Boost endian.hpp header file -------------------------------------------------------// // (C) Copyright Darin Adler 2000 -// (C) Copyright Beman Dawes 2006 +// (C) Copyright Beman Dawes 2006, 2009 -// 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) +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt // See library home page at http://www.boost.org/libs/endian -//----------------------------------------------------------------------------// +//--------------------------------------------------------------------------------------// // Original design developed by Darin Adler based on classes developed by Mark -// Borgerding. Four original class templates combined into a single endian +// Borgerding. Four original class templates were combined into a single endian // class template by Beman Dawes, who also added the unrolled_byte_loops sign // partial specialization to correctly extend the sign when cover integer size // differs from endian representation size. -// TODO: -// * Use C++0x scoped enums if available -// * Use C++0x defaulted default constructor if available -// * Propose, use, BOOST_CONSTEXPR. -// * Propose BOOST_EXPLICIT, apply if needed -// * Should there be a conversion to bool? +// TODO: When a compiler supporting constexpr becomes available, try possible uses. #ifndef BOOST_ENDIAN_HPP #define BOOST_ENDIAN_HPP -// Pending updates to boost/config.hpp for C++0x, assume that the C++0x feature -// we care about is not present: -#define BOOST_NO_DEFAULTED_FUNCTIONS - #include #include #define BOOST_MINIMAL_INTEGER_COVER_OPERATORS +#define BOOST_NO_IO_COVER_OPERATORS #include +#undef BOOST_NO_IO_COVER_OPERATORS #undef BOOST_MINIMAL_INTEGER_COVER_OPERATORS #include #include #include +#include #include #include @@ -154,14 +148,13 @@ namespace boost # endif - // endian class template and specializations -----------------------------// + // endian class template and specializations ---------------------------------------// - // simulate C++0x scoped enums - namespace endianness { enum enum_t { big, little, native }; } - namespace alignment { enum enum_t { unaligned, aligned }; } + BOOST_SCOPED_ENUM_START(endianness) { big, little, native }; BOOST_SCOPED_ENUM_END + BOOST_SCOPED_ENUM_START(alignment) { unaligned, aligned }; BOOST_SCOPED_ENUM_END - template + template class endian; // Specializations that represent unaligned bytes. @@ -319,7 +312,7 @@ namespace boost T m_value; }; - // naming convention typedefs --------------------------------------------// + // naming convention typedefs ------------------------------------------------------// // unaligned big endian signed integer types typedef endian< endianness::big, int_least8_t, 8 > big8_t; diff --git a/boost/integer/endian_io.hpp b/boost/integer/endian_io.hpp new file mode 100644 index 0000000..4b9cae5 --- /dev/null +++ b/boost/integer/endian_io.hpp @@ -0,0 +1,116 @@ +// boost/integer/endian_io.hpp -------------------------------------------------------// + +// Copyright Beman Dawes, 2009 + +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt + +// See library home page at http://www.boost.org/libs/endian + +#ifndef BOOST_ENDIAN_IO_HPP +#define BOOST_ENDIAN_IO_HPP + +#include +#include +#include +#include + +namespace boost +{ + namespace integer + { + template< class T > struct is_endian { static const bool value = false; }; + + template<> struct is_endian { static const bool value = true; }; + template<> struct is_endian { static const bool value = true; }; + template<> struct is_endian { static const bool value = true; }; + template<> struct is_endian { static const bool value = true; }; + template<> struct is_endian { static const bool value = true; }; + template<> struct is_endian { static const bool value = true; }; + template<> struct is_endian { static const bool value = true; }; + template<> struct is_endian { static const bool value = true; }; + + template<> struct is_endian { static const bool value = true; }; + template<> struct is_endian { static const bool value = true; }; + template<> struct is_endian { static const bool value = true; }; + template<> struct is_endian { static const bool value = true; }; + template<> struct is_endian { static const bool value = true; }; + template<> struct is_endian { static const bool value = true; }; + template<> struct is_endian { static const bool value = true; }; + template<> struct is_endian { static const bool value = true; }; + + template<> struct is_endian { static const bool value = true; }; + template<> struct is_endian { static const bool value = true; }; + template<> struct is_endian { static const bool value = true; }; + template<> struct is_endian { static const bool value = true; }; + template<> struct is_endian { static const bool value = true; }; + template<> struct is_endian { static const bool value = true; }; + template<> struct is_endian { static const bool value = true; }; + template<> struct is_endian { static const bool value = true; }; + + template<> struct is_endian { static const bool value = true; }; + template<> struct is_endian { static const bool value = true; }; + template<> struct is_endian { static const bool value = true; }; + template<> struct is_endian { static const bool value = true; }; + template<> struct is_endian { static const bool value = true; }; + template<> struct is_endian { static const bool value = true; }; + template<> struct is_endian { static const bool value = true; }; + template<> struct is_endian { static const bool value = true; }; + + template<> struct is_endian { static const bool value = true; }; + template<> struct is_endian { static const bool value = true; }; + template<> struct is_endian { static const bool value = true; }; + template<> struct is_endian { static const bool value = true; }; + template<> struct is_endian { static const bool value = true; }; + template<> struct is_endian { static const bool value = true; }; + template<> struct is_endian { static const bool value = true; }; + template<> struct is_endian { static const bool value = true; }; + + template<> struct is_endian { static const bool value = true; }; + template<> struct is_endian { static const bool value = true; }; + template<> struct is_endian { static const bool value = true; }; + template<> struct is_endian { static const bool value = true; }; + template<> struct is_endian { static const bool value = true; }; + template<> struct is_endian { static const bool value = true; }; + template<> struct is_endian { static const bool value = true; }; + template<> struct is_endian { static const bool value = true; }; + + # if defined(BOOST_HAS_INT16_T) + template<> struct is_endian { static const bool value = true; }; + template<> struct is_endian { static const bool value = true; }; + template<> struct is_endian { static const bool value = true; }; + template<> struct is_endian { static const bool value = true; }; +# endif + +# if defined(BOOST_HAS_INT32_T) + template<> struct is_endian { static const bool value = true; }; + template<> struct is_endian { static const bool value = true; }; + template<> struct is_endian { static const bool value = true; }; + template<> struct is_endian { static const bool value = true; }; +# endif + +# if defined(BOOST_HAS_INT64_T) + template<> struct is_endian { static const bool value = true; }; + template<> struct is_endian { static const bool value = true; }; + template<> struct is_endian { static const bool value = true; }; + template<> struct is_endian { static const bool value = true; }; +# endif + + template < class Endian > + inline typename boost::enable_if< is_endian, std::ostream & >::type + operator<<( std::ostream & os, const Endian & e ) + { + return os.write( reinterpret_cast(&e), sizeof(e) ); + } + + template < class Endian > + inline typename boost::enable_if< is_endian, std::ostream & >::type + operator>>( std::ostream & os, const Endian & e ) + { + return os.read( reinterpret_cast(&e), sizeof(e) ); + } + + } // namespace integer +} // namespace boost + +#endif // BOOST_ENDIAN_IO_HPP diff --git a/doc/html/minimal.css b/doc/html/minimal.css new file mode 100644 index 0000000..2e5812a --- /dev/null +++ b/doc/html/minimal.css @@ -0,0 +1,29 @@ +/* + + © Copyright Beman Dawes, 2007 + + Distributed under the Boost Software License, Version 1.0. + See www.boost.org/LICENSE_1_0.txt + +*/ + +/******************************************************************************* + Body +*******************************************************************************/ + +body { font-family: sans-serif; margin: 1em; } + +/******************************************************************************* + Table +*******************************************************************************/ + +table { margin: 0.5em; } + +/******************************************************************************* + Font sizes +*******************************************************************************/ + +p, td, li, blockquote { font-size: 10pt; } +pre { font-size: 9pt; } + +/*** end ***/ \ No newline at end of file diff --git a/libs/integer/doc/endian.html b/libs/integer/doc/endian.html index e9fd0f7..9a8f171 100644 --- a/libs/integer/doc/endian.html +++ b/libs/integer/doc/endian.html @@ -6,26 +6,61 @@ Boost Endian Integers + -

Boost Endian Integers (boost/integer/endian.hpp)

-

Introduction
-Limitations
-Feature set
-Typedefs
-    Comment on naming
-Class template endian
-    -Synopsis
-    Members
-FAQ
-Example
-Design
-Experience
-Acknowledgements

+ + + + + +
+ +boost.png (6897 bytes) + Endian Integers +
+ + + + + +
Boost Home  Tutorial
+ + + + + + + + + + + + + + +
+ Contents
+ Introduction
+ Limitations
+ Feature set
+ Typedefs
+     Comment on naming
+ Class template endian
+     + Synopsis
+     Members
+ FAQ
+ Example
+ Design
+ Experience
+ Acknowledgements +
+ Headers
+ <boost/integer/endian.hpp>

Introduction

The boost/integer/endian.hpp header provides integer-like byte-holder binary types with explicit control over @@ -514,7 +549,7 @@ Tomas Puverle, and Yuval Ronen.


Last revised: -06 August, 2008

+11 March, 2009

© Copyright Beman Dawes, 2006

Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at diff --git a/libs/integer/example/endian_hello_world.cpp b/libs/integer/example/endian_hello_world.cpp new file mode 100644 index 0000000..f68eb36 --- /dev/null +++ b/libs/integer/example/endian_hello_world.cpp @@ -0,0 +1,24 @@ +// endian_io_test.cpp ----------------------------------------------------------------// + +// Copyright Beman Dawes, 2009 + +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt + +// See library home page at http://www.boost.org/libs/endian + +#include +#include + +using namespace boost; +using namespace boost::integer; + +int main() +{ + long value = 3224115L; // integer value of ASCII { '1', '2', '3' } + big24_t big( value ); + little24_t little( value ); + + std::cout << "Hello, endian world "<< value << ' ' << big << ' ' << little << '\n'; +} + diff --git a/libs/integer/test/Jamfile.v2 b/libs/integer/test/Jamfile.v2 index 73478c9..a2f1130 100644 --- a/libs/integer/test/Jamfile.v2 +++ b/libs/integer/test/Jamfile.v2 @@ -7,7 +7,10 @@ # See library home page at http://www.boost.org/libs/endian - + import testing ; + test-suite "endian" - : [ run libs/integer/test/endian_test.cpp ] + : [ run endian_test.cpp ] +# [ run endian_operations_test.cpp ] +# [ run endian_in_union_test.cpp ] ; diff --git a/libs/integer/test/endian-in-sandbox/common.vsprops b/libs/integer/test/endian-in-sandbox/common.vsprops index 2f84c92..65f2675 100644 --- a/libs/integer/test/endian-in-sandbox/common.vsprops +++ b/libs/integer/test/endian-in-sandbox/common.vsprops @@ -10,4 +10,9 @@ Name="VCCLCompilerTool" AdditionalIncludeDirectories=""$(BOOST_SANDBOX)\endian";"$(BOOST_TRUNK)"" /> + diff --git a/libs/integer/test/endian-in-sandbox/endian-in-sandbox.sln b/libs/integer/test/endian-in-sandbox/endian-in-sandbox.sln index 36e4506..a2492d3 100644 --- a/libs/integer/test/endian-in-sandbox/endian-in-sandbox.sln +++ b/libs/integer/test/endian-in-sandbox/endian-in-sandbox.sln @@ -7,6 +7,12 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "endian_in_union_test", "end EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "endian_operations_test", "endian_operations_test\endian_operations_test.vcproj", "{A0060A5B-673C-4AD8-BD08-A5C643B1A1CB}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "scoped_enum_emulation_test", "scoped_enum_emulation_test\scoped_enum_emulation_test.vcproj", "{8420E151-B23B-4651-B526-6AB11EF1E278}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "endian_example", "endian_example\endian_example.vcproj", "{8638A3D8-D121-40BF-82E5-127F1B1B2CB2}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "endian_hello_world", "endian_hello_world\endian_hello_world.vcproj", "{1AAEBB4E-501E-417E-9531-04469AF5DD8B}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -25,6 +31,18 @@ Global {A0060A5B-673C-4AD8-BD08-A5C643B1A1CB}.Debug|Win32.Build.0 = Debug|Win32 {A0060A5B-673C-4AD8-BD08-A5C643B1A1CB}.Release|Win32.ActiveCfg = Release|Win32 {A0060A5B-673C-4AD8-BD08-A5C643B1A1CB}.Release|Win32.Build.0 = Release|Win32 + {8420E151-B23B-4651-B526-6AB11EF1E278}.Debug|Win32.ActiveCfg = Debug|Win32 + {8420E151-B23B-4651-B526-6AB11EF1E278}.Debug|Win32.Build.0 = Debug|Win32 + {8420E151-B23B-4651-B526-6AB11EF1E278}.Release|Win32.ActiveCfg = Release|Win32 + {8420E151-B23B-4651-B526-6AB11EF1E278}.Release|Win32.Build.0 = Release|Win32 + {8638A3D8-D121-40BF-82E5-127F1B1B2CB2}.Debug|Win32.ActiveCfg = Debug|Win32 + {8638A3D8-D121-40BF-82E5-127F1B1B2CB2}.Debug|Win32.Build.0 = Debug|Win32 + {8638A3D8-D121-40BF-82E5-127F1B1B2CB2}.Release|Win32.ActiveCfg = Release|Win32 + {8638A3D8-D121-40BF-82E5-127F1B1B2CB2}.Release|Win32.Build.0 = Release|Win32 + {1AAEBB4E-501E-417E-9531-04469AF5DD8B}.Debug|Win32.ActiveCfg = Debug|Win32 + {1AAEBB4E-501E-417E-9531-04469AF5DD8B}.Debug|Win32.Build.0 = Debug|Win32 + {1AAEBB4E-501E-417E-9531-04469AF5DD8B}.Release|Win32.ActiveCfg = Release|Win32 + {1AAEBB4E-501E-417E-9531-04469AF5DD8B}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/libs/integer/test/endian-in-sandbox/endian_example/endian_example.vcproj b/libs/integer/test/endian-in-sandbox/endian_example/endian_example.vcproj new file mode 100644 index 0000000..b89cb61 --- /dev/null +++ b/libs/integer/test/endian-in-sandbox/endian_example/endian_example.vcproj @@ -0,0 +1,195 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libs/integer/test/endian-in-sandbox/endian_hello_world/endian_hello_world.vcproj b/libs/integer/test/endian-in-sandbox/endian_hello_world/endian_hello_world.vcproj new file mode 100644 index 0000000..b8f0336 --- /dev/null +++ b/libs/integer/test/endian-in-sandbox/endian_hello_world/endian_hello_world.vcproj @@ -0,0 +1,195 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libs/integer/test/endian-in-sandbox/scoped_enum_emulation_test/scoped_enum_emulation_test.vcproj b/libs/integer/test/endian-in-sandbox/scoped_enum_emulation_test/scoped_enum_emulation_test.vcproj new file mode 100644 index 0000000..93ecd65 --- /dev/null +++ b/libs/integer/test/endian-in-sandbox/scoped_enum_emulation_test/scoped_enum_emulation_test.vcproj @@ -0,0 +1,195 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libs/integer/test/scoped_enum_emulation_test.cpp b/libs/integer/test/scoped_enum_emulation_test.cpp new file mode 100644 index 0000000..45d59e3 --- /dev/null +++ b/libs/integer/test/scoped_enum_emulation_test.cpp @@ -0,0 +1,42 @@ +// scoped_enum_emulation_test.cpp ----------------------------------------------------// + +// Copyright Beman Dawes, 2009 + +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt + +// See documentation at http://www.boost.org/libs/utility/scoped_enum_emulation.html + +#include +#include + +BOOST_SCOPED_ENUM_START(traffic_light) { red=0, yellow, green }; BOOST_SCOPED_ENUM_END + +BOOST_SCOPED_ENUM_START(algae) { green=0, red, cyan }; BOOST_SCOPED_ENUM_END + +struct color +{ + BOOST_SCOPED_ENUM_START(value_t) { red, green, blue }; BOOST_SCOPED_ENUM_END + BOOST_SCOPED_ENUM(value_t) value; +}; + +void foo( BOOST_SCOPED_ENUM(algae) arg ) +{ + BOOST_ASSERT( arg == algae::cyan ); +} + +int main() +{ + BOOST_SCOPED_ENUM(traffic_light) signal( traffic_light::red ); + BOOST_SCOPED_ENUM(algae) sample( algae::red ); + + BOOST_ASSERT( signal == traffic_light::red ); + BOOST_ASSERT( sample == algae::red ); + + foo( algae::cyan ); + + color tracker; + tracker.value = color::value_t::blue; + + return 0; +}