// file : examples/cxx/tree/binary/boost/boost-archive-insertion.cxx // author : Boris Kolpackov // copyright : not copyrighted - public domain #ifndef BOOST_ARCHIVE_EXTRACTION_HXX #define BOOST_ARCHIVE_EXTRACTION_HXX #include // std::size_t #include #include #include #include namespace xsd { namespace cxx { namespace tree { // as_size // template inline istream& operator>> (istream& s, istream_common::as_size& x) { std::size_t r; s.impl () >> r; x.x_ = static_cast (r); return s; } // 8-bit // template inline istream& operator>> (istream& s, istream_common::as_int8& x) { boost::int8_t r; s.impl () >> r; x.x_ = static_cast (r); return s; } template inline istream& operator>> (istream& s, istream_common::as_uint8& x) { boost::uint8_t r; s.impl () >> r; x.x_ = static_cast (r); return s; } // 16-bit // template inline istream& operator>> (istream& s, istream_common::as_int16& x) { boost::int16_t r; s.impl () >> r; x.x_ = static_cast (r); return s; } template inline istream& operator>> (istream& s, istream_common::as_uint16& x) { boost::uint16_t r; s.impl () >> r; x.x_ = static_cast (r); return s; } // 32-bit // template inline istream& operator>> (istream& s, istream_common::as_int32& x) { boost::int32_t r; s.impl () >> r; x.x_ = static_cast (r); return s; } template inline istream& operator>> (istream& s, istream_common::as_uint32& x) { boost::uint32_t r; s.impl () >> r; x.x_ = static_cast (r); return s; } // 64-bit // template inline istream& operator>> (istream& s, istream_common::as_int64& x) { boost::int64_t r; s.impl () >> r; x.x_ = static_cast (r); return s; } template inline istream& operator>> (istream& s, istream_common::as_uint64& x) { boost::uint64_t r; s.impl () >> r; x.x_ = static_cast (r); return s; } // Boolean // template inline istream& operator>> (istream& s, istream_common::as_bool& x) { bool r; s.impl () >> r; x.x_ = static_cast (r); return s; } // Floating-point // template inline istream& operator>> (istream& s, istream_common::as_float32& x) { float r; s.impl () >> r; x.x_ = static_cast (r); return s; } template inline istream& operator>> (istream& s, istream_common::as_float64& x) { double r; s.impl () >> r; x.x_ = static_cast (r); return s; } // Extraction of std::basic_string. // template inline istream& operator>> (istream& s, std::basic_string& x) { s.impl () >> x; return s; } // Extraction of a binary buffer. // template istream& operator>> (istream& s, buffer& x) { std::size_t size; s.impl () >> size; x.size (size); s.impl ().load_binary (x.data (), size); } } } } #endif // BOOST_ARCHIVE_EXTRACTION_HXX