1 #ifndef BOOST_ARCHIVE_BASIC_BINARY_OARCHIVE_HPP
2 #define BOOST_ARCHIVE_BASIC_BINARY_OARCHIVE_HPP
4 // MS compatible compilers support #pragma once
5 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
9 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
10 // basic_binary_oarchive.hpp
12 // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
13 // Use, modification and distribution is subject to the Boost Software
14 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
15 // http://www.boost.org/LICENSE_1_0.txt)
17 // See http://www.boost.org for updates, documentation, and revision history.
19 // archives stored as native binary - this should be the fastest way
20 // to archive the state of a group of obects. It makes no attempt to
21 // convert to any canonical form.
23 // IN GENERAL, ARCHIVES CREATED WITH THIS CLASS WILL NOT BE READABLE
24 // ON PLATFORM APART FROM THE ONE THEY ARE CREATE ON
26 #include <boost/config.hpp>
27 #include <boost/serialization/pfto.hpp>
29 #include <boost/detail/workaround.hpp>
30 #include <boost/archive/detail/common_oarchive.hpp>
31 #include <boost/serialization/string.hpp>
32 #include <boost/serialization/collection_size_type.hpp>
37 //////////////////////////////////////////////////////////////////////
38 // class basic_binary_oarchive - write serialized objects to a binary output stream
39 // note: this archive has no pretensions to portability. Archive format
40 // may vary across machine architectures and compilers. About the only
41 // guarentee is that an archive created with this code will be readable
42 // by a program built with the same tools for the same machne. This class
43 // does have the virtue of buiding the smalles archive in the minimum amount
44 // of time. So under some circumstances it may be he right choice.
45 template<class Archive
>
46 class basic_binary_oarchive
:
47 public archive::detail::common_oarchive
<Archive
>
50 #if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
52 #elif defined(BOOST_MSVC)
53 // for some inexplicable reason insertion of "class" generates compile erro
55 friend detail::interface_oarchive
<Archive
>;
57 friend class detail::interface_oarchive
<Archive
>;
59 // any datatype not specifed below will be handled by base class
60 typedef detail::common_oarchive
<Archive
> detail_common_oarchive
;
62 void save_override(const T
& t
, BOOST_PFTO
int version
){
63 this->detail_common_oarchive::save_override(t
, static_cast<int>(version
));
66 // binary files don't include the optional information
67 void save_override(const class_id_optional_type
& /* t */, int){}
69 void save_override(const version_type
& t
, int){
71 // note:t.t resolves borland ambguity
72 const unsigned char x
= t
.t
;
75 void save_override(const class_id_type
& t
, int){
77 const int_least16_t x
= t
.t
;
80 void save_override(const class_id_reference_type
& t
, int){
82 const int_least16_t x
= t
.t
;
85 void save_override(const object_id_type
& t
, int){
87 const uint_least32_t x
= t
.t
;
90 void save_override(const object_reference_type
& t
, int){
92 uint_least32_t x
= t
.t
;
95 void save_override(const tracking_type
& t
, int){
100 // explicitly convert to char * to avoid compile ambiguities
101 void save_override(const class_name_type
& t
, int){
102 const std::string
s(t
);
106 void save_override(const serialization::collection_size_type
& t
, int){
107 // for backward compatibility, 64 bit integer or variable length integer would be preferred
108 unsigned int x
= t
.t
;
112 BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
115 basic_binary_oarchive(unsigned int flags
) :
116 detail::common_oarchive
<Archive
>(flags
)
120 } // namespace archive
123 #endif // BOOST_ARCHIVE_BASIC_BINARY_OARCHIVE_HPP