Chris@16
|
1 #ifndef BOOST_ARCHIVE_BASIC_TEXT_OARCHIVE_HPP
|
Chris@16
|
2 #define BOOST_ARCHIVE_BASIC_TEXT_OARCHIVE_HPP
|
Chris@16
|
3
|
Chris@16
|
4 // MS compatible compilers support #pragma once
|
Chris@101
|
5 #if defined(_MSC_VER)
|
Chris@16
|
6 # pragma once
|
Chris@16
|
7 #endif
|
Chris@16
|
8
|
Chris@16
|
9 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
Chris@16
|
10 // basic_text_oarchive.hpp
|
Chris@16
|
11
|
Chris@16
|
12 // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
|
Chris@16
|
13 // Use, modification and distribution is subject to the Boost Software
|
Chris@16
|
14 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
15 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
16
|
Chris@16
|
17 // See http://www.boost.org for updates, documentation, and revision history.
|
Chris@16
|
18
|
Chris@16
|
19 // archives stored as text - note these ar templated on the basic
|
Chris@16
|
20 // stream templates to accommodate wide (and other?) kind of characters
|
Chris@16
|
21 //
|
Chris@16
|
22 // note the fact that on libraries without wide characters, ostream is
|
Chris@16
|
23 // is not a specialization of basic_ostream which in fact is not defined
|
Chris@16
|
24 // in such cases. So we can't use basic_ostream<OStream::char_type> but rather
|
Chris@16
|
25 // use two template parameters
|
Chris@16
|
26
|
Chris@16
|
27 #include <boost/config.hpp>
|
Chris@16
|
28 #include <boost/serialization/pfto.hpp>
|
Chris@16
|
29 #include <boost/detail/workaround.hpp>
|
Chris@16
|
30 #include <boost/archive/detail/common_oarchive.hpp>
|
Chris@16
|
31 #include <boost/serialization/string.hpp>
|
Chris@16
|
32
|
Chris@16
|
33 #include <boost/archive/detail/abi_prefix.hpp> // must be the last header
|
Chris@16
|
34
|
Chris@16
|
35 #ifdef BOOST_MSVC
|
Chris@16
|
36 # pragma warning(push)
|
Chris@16
|
37 # pragma warning(disable : 4511 4512)
|
Chris@16
|
38 #endif
|
Chris@16
|
39
|
Chris@16
|
40 namespace boost {
|
Chris@16
|
41 namespace archive {
|
Chris@16
|
42
|
Chris@101
|
43 namespace detail {
|
Chris@101
|
44 template<class Archive> class interface_oarchive;
|
Chris@101
|
45 } // namespace detail
|
Chris@101
|
46
|
Chris@16
|
47 /////////////////////////////////////////////////////////////////////////
|
Chris@16
|
48 // class basic_text_oarchive
|
Chris@16
|
49 template<class Archive>
|
Chris@16
|
50 class basic_text_oarchive :
|
Chris@16
|
51 public detail::common_oarchive<Archive>
|
Chris@16
|
52 {
|
Chris@101
|
53 #ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
|
Chris@101
|
54 public:
|
Chris@101
|
55 #else
|
Chris@16
|
56 protected:
|
Chris@101
|
57 #if BOOST_WORKAROUND(BOOST_MSVC, < 1500)
|
Chris@101
|
58 // for some inexplicable reason insertion of "class" generates compile erro
|
Chris@101
|
59 // on msvc 7.1
|
Chris@101
|
60 friend detail::interface_oarchive<Archive>;
|
Chris@101
|
61 #else
|
Chris@101
|
62 friend class detail::interface_oarchive<Archive>;
|
Chris@101
|
63 #endif
|
Chris@16
|
64 #endif
|
Chris@101
|
65
|
Chris@16
|
66 enum {
|
Chris@16
|
67 none,
|
Chris@16
|
68 eol,
|
Chris@16
|
69 space
|
Chris@16
|
70 } delimiter;
|
Chris@16
|
71
|
Chris@16
|
72 BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
Chris@16
|
73 newtoken();
|
Chris@16
|
74
|
Chris@16
|
75 void newline(){
|
Chris@16
|
76 delimiter = eol;
|
Chris@16
|
77 }
|
Chris@16
|
78
|
Chris@16
|
79 // default processing - kick back to base class. Note the
|
Chris@16
|
80 // extra stuff to get it passed borland compilers
|
Chris@16
|
81 typedef detail::common_oarchive<Archive> detail_common_oarchive;
|
Chris@16
|
82 template<class T>
|
Chris@16
|
83 void save_override(T & t, BOOST_PFTO int){
|
Chris@16
|
84 this->detail_common_oarchive::save_override(t, 0);
|
Chris@16
|
85 }
|
Chris@16
|
86
|
Chris@16
|
87 // start new objects on a new line
|
Chris@16
|
88 void save_override(const object_id_type & t, int){
|
Chris@16
|
89 this->This()->newline();
|
Chris@16
|
90 this->detail_common_oarchive::save_override(t, 0);
|
Chris@16
|
91 }
|
Chris@16
|
92
|
Chris@16
|
93 // text file don't include the optional information
|
Chris@16
|
94 void save_override(const class_id_optional_type & /* t */, int){}
|
Chris@16
|
95
|
Chris@16
|
96 void save_override(const class_name_type & t, int){
|
Chris@16
|
97 const std::string s(t);
|
Chris@16
|
98 * this->This() << s;
|
Chris@16
|
99 }
|
Chris@16
|
100
|
Chris@16
|
101 BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
Chris@16
|
102 init();
|
Chris@16
|
103
|
Chris@16
|
104 basic_text_oarchive(unsigned int flags) :
|
Chris@16
|
105 detail::common_oarchive<Archive>(flags),
|
Chris@16
|
106 delimiter(none)
|
Chris@16
|
107 {}
|
Chris@16
|
108 ~basic_text_oarchive(){}
|
Chris@16
|
109 };
|
Chris@16
|
110
|
Chris@16
|
111 } // namespace archive
|
Chris@16
|
112 } // namespace boost
|
Chris@16
|
113
|
Chris@16
|
114 #ifdef BOOST_MSVC
|
Chris@16
|
115 #pragma warning(pop)
|
Chris@16
|
116 #endif
|
Chris@16
|
117
|
Chris@16
|
118 #include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
|
Chris@16
|
119
|
Chris@16
|
120 #endif // BOOST_ARCHIVE_BASIC_TEXT_OARCHIVE_HPP
|