fix doc example typo
[boost.git] / boost / archive / basic_archive.hpp
blobac4c62b769429bc6eea0aba34cd78380c4ccc868
1 #ifndef BOOST_ARCHIVE_BASIC_ARCHIVE_HPP
2 #define BOOST_ARCHIVE_BASIC_ARCHIVE_HPP
4 // MS compatible compilers support #pragma once
5 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
6 # pragma once
7 #endif
9 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
10 // basic_archive.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 #include <boost/config.hpp>
20 #include <boost/serialization/strong_typedef.hpp>
21 #include <boost/noncopyable.hpp>
23 #include <boost/archive/detail/auto_link_archive.hpp>
24 #include <boost/archive/detail/abi_prefix.hpp> // must be the last header
26 namespace boost {
27 namespace archive {
29 BOOST_STRONG_TYPEDEF(unsigned int, version_type)
30 BOOST_STRONG_TYPEDEF(int, class_id_type)
31 BOOST_STRONG_TYPEDEF(int, class_id_optional_type)
32 BOOST_STRONG_TYPEDEF(int, class_id_reference_type)
33 BOOST_STRONG_TYPEDEF(unsigned int, object_id_type)
34 BOOST_STRONG_TYPEDEF(unsigned int, object_reference_type)
36 struct tracking_type {
37 typedef bool value_type;
38 bool t;
39 explicit tracking_type(const bool t_ = false)
40 : t(t_)
41 {};
42 tracking_type(const tracking_type & t_)
43 : t(t_.t)
45 operator bool () const {
46 return t;
48 operator bool & () {
49 return t;
51 tracking_type & operator=(const bool t_){
52 t = t_;
53 return *this;
55 bool operator==(const tracking_type & rhs) const {
56 return t == rhs.t;
58 bool operator==(const bool & rhs) const {
59 return t == rhs;
61 tracking_type & operator=(const tracking_type & rhs){
62 t = rhs.t;
63 return *this;
67 struct class_name_type : private boost::noncopyable {
68 char *t;
69 operator const char * & () const {
70 return const_cast<const char * &>(t);
72 operator char * () {
73 return t;
75 explicit class_name_type(const char *key_)
76 : t(const_cast<char *>(key_)){}
77 explicit class_name_type(char *key_)
78 : t(key_){}
79 class_name_type & operator=(const class_name_type & rhs){
80 t = rhs.t;
81 return *this;
85 enum archive_flags {
86 no_header = 1, // suppress archive header info
87 no_codecvt = 2, // suppress alteration of codecvt facet
88 no_xml_tag_checking = 4, // suppress checking of xml tags
89 no_tracking = 8, // suppress ALL tracking
90 flags_last = 8
93 #define NULL_POINTER_TAG class_id_type(-1)
95 BOOST_ARCHIVE_DECL(const char *)
96 BOOST_ARCHIVE_SIGNATURE();
98 BOOST_ARCHIVE_DECL(unsigned char)
99 BOOST_ARCHIVE_VERSION();
101 }// namespace archive
102 }// namespace boost
104 #include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
106 #include <boost/serialization/level.hpp>
108 // set implementation level to primitive for all types
109 // used internally by the serialization library
111 BOOST_CLASS_IMPLEMENTATION(boost::archive::version_type, primitive_type)
112 BOOST_CLASS_IMPLEMENTATION(boost::archive::class_id_type, primitive_type)
113 BOOST_CLASS_IMPLEMENTATION(boost::archive::class_id_reference_type, primitive_type)
114 BOOST_CLASS_IMPLEMENTATION(boost::archive::class_id_optional_type, primitive_type)
115 BOOST_CLASS_IMPLEMENTATION(boost::archive::class_name_type, primitive_type)
116 BOOST_CLASS_IMPLEMENTATION(boost::archive::object_id_type, primitive_type)
117 BOOST_CLASS_IMPLEMENTATION(boost::archive::object_reference_type, primitive_type)
118 BOOST_CLASS_IMPLEMENTATION(boost::archive::tracking_type, primitive_type)
120 #endif //BOOST_ARCHIVE_BASIC_ARCHIVE_HPP