// file : examples/cxx/tree/binary/boost/boost-archive-insertion.cxx // copyright : not copyrighted - public domain #ifndef BOOST_ARCHIVE_INSERTION_HXX #define BOOST_ARCHIVE_INSERTION_HXX #include // std::size_t #include #include #include #include namespace xsd { namespace cxx { namespace tree { // as_size // template inline ostream& operator<< (ostream& s, ostream_common::as_size x) { std::size_t v (static_cast (x.x_)); s.impl () << v; return s; } // 8-bit // template inline ostream& operator<< (ostream& s, ostream_common::as_int8 x) { boost::int8_t v (static_cast (x.x_)); s.impl () << v; return s; } template inline ostream& operator<< (ostream& s, ostream_common::as_uint8 x) { boost::uint8_t v (static_cast (x.x_)); s.impl () << v; return s; } // 16-bit // template inline ostream& operator<< (ostream& s, ostream_common::as_int16 x) { boost::int16_t v (static_cast (x.x_)); s.impl () << v; return s; } template inline ostream& operator<< (ostream& s, ostream_common::as_uint16 x) { boost::uint16_t v (static_cast (x.x_)); s.impl () << v; return s; } // 32-bit // template inline ostream& operator<< (ostream& s, ostream_common::as_int32 x) { boost::int32_t v (static_cast (x.x_)); s.impl () << v; return s; } template inline ostream& operator<< (ostream& s, ostream_common::as_uint32 x) { boost::uint32_t v (static_cast (x.x_)); s.impl () << v; return s; } // 64-bit // template inline ostream& operator<< (ostream& s, ostream_common::as_int64 x) { boost::int64_t v (static_cast (x.x_)); s.impl () << v; return s; } template inline ostream& operator<< (ostream& s, ostream_common::as_uint64 x) { boost::uint64_t v (static_cast (x.x_)); s.impl () << v; return s; } // Boolean // template inline ostream& operator<< (ostream& s, ostream_common::as_bool x) { bool v (static_cast (x.x_)); s.impl () << v; return s; } // Floating-point // template inline ostream& operator<< (ostream& s, ostream_common::as_float32 x) { float v (static_cast (x.x_)); s.impl () << v; return s; } template inline ostream& operator<< (ostream& s, ostream_common::as_float64 x) { double v (static_cast (x.x_)); s.impl () << v; return s; } // Insertion of std::basic_string. // template inline ostream& operator<< (ostream& s, const std::basic_string& x) { s.impl () << x; return s; } // Insertion of a binary buffer. // template ostream& operator<< (ostream& s, const buffer& x) { // Boost.Serialization needs an lvalue. // std::size_t size (x.size()); s.impl () << size; s.impl ().save_binary (x.data (), x.size ()); return s; } } } } #endif // BOOST_ARCHIVE_INSERTION_HXX