From 815bdaabcd2b24c6074212c994883458a2e55724 Mon Sep 17 00:00:00 2001 From: bemandawes Date: Sat, 14 Mar 2009 19:32:40 +0000 Subject: [PATCH] Endian: rename endian_io.hpp -> endian_binary_stream.hpp for consistency with binary_stream.hpp git-svn-id: http://svn.boost.org/svn/boost/sandbox/endian@51777 b8fc166d-592f-0410-95f2-cb63ce0dd405 --- boost/integer/endian_binary_stream.hpp | 116 +++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 boost/integer/endian_binary_stream.hpp diff --git a/boost/integer/endian_binary_stream.hpp b/boost/integer/endian_binary_stream.hpp new file mode 100644 index 0000000..4b9cae5 --- /dev/null +++ b/boost/integer/endian_binary_stream.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