123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173 |
- #include <boost/assert.hpp>
- #include <cstddef> // size_t, NULL
- #include <cstring> // memcpy
- #include <boost/config.hpp>
- #if defined(BOOST_NO_STDC_NAMESPACE)
- namespace std{
- using ::size_t;
- using ::memcpy;
- }
- #endif
- #include <boost/serialization/throw_exception.hpp>
- #include <boost/core/no_exceptions_support.hpp>
- #include <boost/archive/archive_exception.hpp>
- #include <boost/archive/basic_binary_iprimitive.hpp>
- namespace boost {
- namespace archive {
- template<class Archive, class Elem, class Tr>
- BOOST_ARCHIVE_OR_WARCHIVE_DECL void
- basic_binary_iprimitive<Archive, Elem, Tr>::init()
- {
-
-
-
- unsigned char size;
- this->This()->load(size);
- if(sizeof(int) != size)
- boost::serialization::throw_exception(
- archive_exception(
- archive_exception::incompatible_native_format,
- "size of int"
- )
- );
- this->This()->load(size);
- if(sizeof(long) != size)
- boost::serialization::throw_exception(
- archive_exception(
- archive_exception::incompatible_native_format,
- "size of long"
- )
- );
- this->This()->load(size);
- if(sizeof(float) != size)
- boost::serialization::throw_exception(
- archive_exception(
- archive_exception::incompatible_native_format,
- "size of float"
- )
- );
- this->This()->load(size);
- if(sizeof(double) != size)
- boost::serialization::throw_exception(
- archive_exception(
- archive_exception::incompatible_native_format,
- "size of double"
- )
- );
-
- int i;
- this->This()->load(i);
- if(1 != i)
- boost::serialization::throw_exception(
- archive_exception(
- archive_exception::incompatible_native_format,
- "endian setting"
- )
- );
- }
- #ifndef BOOST_NO_CWCHAR
- #ifndef BOOST_NO_INTRINSIC_WCHAR_T
- template<class Archive, class Elem, class Tr>
- BOOST_ARCHIVE_OR_WARCHIVE_DECL void
- basic_binary_iprimitive<Archive, Elem, Tr>::load(wchar_t * ws)
- {
- std::size_t l;
- this->This()->load(l);
- load_binary(ws, l * sizeof(wchar_t) / sizeof(char));
- ws[l] = L'\0';
- }
- #endif
- #endif
- template<class Archive, class Elem, class Tr>
- BOOST_ARCHIVE_OR_WARCHIVE_DECL void
- basic_binary_iprimitive<Archive, Elem, Tr>::load(std::string & s)
- {
- std::size_t l;
- this->This()->load(l);
-
- #if BOOST_WORKAROUND(_RWSTD_VER, BOOST_TESTED_AT(20101))
- if(NULL != s.data())
- #endif
- s.resize(l);
-
- if(0 < l)
- load_binary(&(*s.begin()), l);
- }
- template<class Archive, class Elem, class Tr>
- BOOST_ARCHIVE_OR_WARCHIVE_DECL void
- basic_binary_iprimitive<Archive, Elem, Tr>::load(char * s)
- {
- std::size_t l;
- this->This()->load(l);
- load_binary(s, l);
- s[l] = '\0';
- }
- #ifndef BOOST_NO_STD_WSTRING
- template<class Archive, class Elem, class Tr>
- BOOST_ARCHIVE_OR_WARCHIVE_DECL void
- basic_binary_iprimitive<Archive, Elem, Tr>::load(std::wstring & ws)
- {
- std::size_t l;
- this->This()->load(l);
-
- #if BOOST_WORKAROUND(_RWSTD_VER, BOOST_TESTED_AT(20101))
- if(NULL != ws.data())
- #endif
- ws.resize(l);
-
- load_binary(const_cast<wchar_t *>(ws.data()), l * sizeof(wchar_t) / sizeof(char));
- }
- #endif
- template<class Archive, class Elem, class Tr>
- BOOST_ARCHIVE_OR_WARCHIVE_DECL
- basic_binary_iprimitive<Archive, Elem, Tr>::basic_binary_iprimitive(
- std::basic_streambuf<Elem, Tr> & sb,
- bool no_codecvt
- ) :
- #ifndef BOOST_NO_STD_LOCALE
- m_sb(sb),
- codecvt_null_facet(1),
- locale_saver(m_sb),
- archive_locale(sb.getloc(), & codecvt_null_facet)
- {
- if(! no_codecvt){
- m_sb.pubsync();
- m_sb.pubimbue(archive_locale);
- }
- }
- #else
- m_sb(sb)
- {}
- #endif
- template<class Archive, class Elem, class Tr>
- BOOST_ARCHIVE_OR_WARCHIVE_DECL
- basic_binary_iprimitive<Archive, Elem, Tr>::~basic_binary_iprimitive(){}
- }
- }
|