]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/serialization/example/demo_portable_archive.cpp
1 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
3 // demo_portable_archive.cpp
5 // (C) Copyright 2002-4 Robert Ramey - http://www.rrsd.com .
6 // Use, modification and distribution is subject to the Boost Software
7 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
8 // http://www.boost.org/LICENSE_1_0.txt)
10 // should pass compilation and execution
12 // note:: this example can only be built with the static library
13 // (at least with MSVC - due to conflicts related to import of library
14 // code and instantiation of templates.
17 #include "portable_binary_oarchive.hpp"
18 #include "portable_binary_iarchive.hpp"
21 #include <boost/config.hpp>
22 #if defined(BOOST_NO_STDC_NAMESPACE)
23 namespace std
{ using ::rand
; }
28 friend class boost::serialization::access
;
32 int i2
; // special tricky case to check sign extension
36 template<class Archive
>
37 void serialize(Archive
& ar
, const unsigned int /* version */){
38 ar
& c
& i
& i2
& ui
& l
& ul
;
41 bool operator==(const A
& rhs
) const {
52 c(0xFF & std::rand()),
57 l(std::rand() * std::rand()),
62 int main( int /* argc */, char* /* argv */[] )
69 portable_binary_oarchive
pboa(ss
);
73 portable_binary_iarchive
pbia(ss
);
81 portable_binary_oarchive
pboa(ss
, endian_big
);
85 portable_binary_iarchive
pbia(ss
, endian_big
);
93 portable_binary_oarchive
pboa(ss
, endian_big
);
97 portable_binary_iarchive
pbia(ss
, endian_big
);