Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/boost/archive/basic_text_oarchive.hpp @ 46

Last change on this file since 46 was 29, checked in by landauf, 17 years ago

updated boost from 1_33_1 to 1_34_1

File size: 4.1 KB
Line 
1#ifndef BOOST_ARCHIVE_BASIC_TEXT_OARCHIVE_HPP
2#define BOOST_ARCHIVE_BASIC_TEXT_OARCHIVE_HPP
3
4// MS compatible compilers support #pragma once
5#if defined(_MSC_VER) && (_MSC_VER >= 1020)
6# pragma once
7#endif
8
9/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
10// basic_text_oarchive.hpp
11
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)
16
17//  See http://www.boost.org for updates, documentation, and revision history.
18
19// archives stored as text - note these ar templated on the basic
20// stream templates to accommodate wide (and other?) kind of characters
21//
22// note the fact that on libraries without wide characters, ostream is
23// is not a specialization of basic_ostream which in fact is not defined
24// in such cases.   So we can't use basic_ostream<OStream::char_type> but rather
25// use two template parameters
26
27#include <cassert>
28#include <boost/config.hpp>
29#include <boost/pfto.hpp>
30#include <boost/detail/workaround.hpp>
31
32#include <boost/archive/detail/common_oarchive.hpp>
33#include <boost/serialization/string.hpp>
34
35#include <boost/archive/detail/abi_prefix.hpp> // must be the last header
36
37namespace boost {
38namespace archive {
39
40/////////////////////////////////////////////////////////////////////////
41// class basic_text_iarchive - read serialized objects from a input text stream
42template<class Archive>
43class basic_text_oarchive : 
44    public detail::common_oarchive<Archive>
45{
46protected:
47#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) \
48|| BOOST_WORKAROUND(__BORLANDC__,BOOST_TESTED_AT(0x560))
49public:
50#elif defined(BOOST_MSVC)
51    // for some inexplicable reason insertion of "class" generates compile erro
52    // on msvc 7.1
53    friend detail::interface_oarchive<Archive>;
54#else
55    friend class detail::interface_oarchive<Archive>;
56#endif
57    enum {
58        none,
59        eol,
60        space
61    } delimiter;
62
63    BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
64    newtoken();
65
66    void newline(){
67        delimiter = eol;
68    }
69
70    // default processing - kick back to base class.  Note the
71    // extra stuff to get it passed borland compilers
72    typedef detail::common_oarchive<Archive> detail_common_oarchive;
73    template<class T>
74    void save_override(T & t, BOOST_PFTO int){
75        this->detail_common_oarchive::save_override(t, 0);
76    }
77
78    // start new objects on a new line
79    void save_override(const object_id_type & t, int){
80        this->This()->newline();
81        // and and invoke prmitive to underlying value
82        this->This()->save(t.t);
83    }
84
85    void save_override(const object_reference_type & t, int){
86        this->This()->newline();
87        // and and invoke prmitive to underlying value
88        this->This()->save(t.t);
89    }
90
91    // text file don't include the optional information
92    void save_override(const class_id_optional_type & /* t */, int){}
93
94    // note the following four overrides are necessary for some borland
95    // compilers which don't handle BOOST_STRONG_TYPE properly.
96    void save_override(const version_type & t, int){
97        // note:t.t resolves borland ambguity
98        unsigned int x = t.t;
99        * this->This() << x;
100    }
101    void save_override(const class_id_type & t, int){
102        // note:t.t resolves borland ambguity
103        int x = t.t;
104        * this->This() << x;
105    }
106    void save_override(const class_id_reference_type & t, int){
107        // note:t.t resolves borland ambguity
108        int x = t.t;
109        * this->This() << x;
110    }
111    void save_override(const class_name_type & t, int){
112        const std::string s(t);
113        * this->This() << s;
114    }
115
116    BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
117    init();
118
119    basic_text_oarchive(unsigned int flags) :
120        detail::common_oarchive<Archive>(flags),
121        delimiter(none)
122    {}
123    ~basic_text_oarchive(){}
124};
125
126} // namespace archive
127} // namespace boost
128
129#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
130
131#endif // BOOST_ARCHIVE_BASIC_TEXT_OARCHIVE_HPP
Note: See TracBrowser for help on using the repository browser.