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