]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/serialization/example/portable_binary_oarchive.cpp
1 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
2 // portable_binary_oarchive.cpp
4 // (C) Copyright 2002-7 Robert Ramey - http://www.rrsd.com .
5 // Use, modification and distribution is subject to the Boost Software
6 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
9 // See http://www.boost.org for updates, documentation, and revision history.
12 #include <boost/detail/endian.hpp>
13 #include "portable_binary_oarchive.hpp"
16 portable_binary_oarchive::save_impl(
17 const boost::intmax_t l
,
23 this->primitive_base_t::save(size
);
28 bool negative
= (l
< 0);
39 this->primitive_base_t::save(
40 static_cast<char>(negative
? -size
: size
)
47 char * cptr
= reinterpret_cast<char *>(& ll
);
48 #ifdef BOOST_BIG_ENDIAN
49 cptr
+= (sizeof(boost::intmax_t) - size
);
50 if(m_flags
& endian_little
)
51 reverse_bytes(size
, cptr
);
53 if(m_flags
& endian_big
)
54 reverse_bytes(size
, cptr
);
56 this->primitive_base_t::save_binary(cptr
, size
);
60 portable_binary_oarchive::init(unsigned int flags
) {
61 if(m_flags
== (endian_big
| endian_little
)){
62 boost::serialization::throw_exception(
63 portable_binary_oarchive_exception()
66 if(0 == (flags
& boost::archive::no_header
)){
67 // write signature in an archive version independent manner
68 const std::string
file_signature(
69 boost::archive::BOOST_ARCHIVE_SIGNATURE()
71 * this << file_signature
;
72 // write library version
73 const boost::archive::library_version_type
v(
74 boost::archive::BOOST_ARCHIVE_VERSION()
78 save(static_cast<unsigned char>(m_flags
>> CHAR_BIT
));
81 #include <boost/archive/impl/archive_serializer_map.ipp>
82 #include <boost/archive/impl/basic_binary_oprimitive.ipp>
88 template class archive_serializer_map
<portable_binary_oarchive
>;
91 template class basic_binary_oprimitive
<
92 portable_binary_oarchive
,
93 std::ostream::char_type
,
94 std::ostream::traits_type
97 } // namespace archive