Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/boost/archive/basic_xml_oarchive.hpp @ 29

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

updated boost from 1_33_1 to 1_34_1

File size: 4.2 KB
Line 
1#ifndef BOOST_ARCHIVE_BASIC_XML_OARCHIVE_HPP
2#define BOOST_ARCHIVE_BASIC_XML_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_xml_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#include <boost/config.hpp>
20
21#include <boost/archive/detail/common_oarchive.hpp>
22
23#include <boost/serialization/nvp.hpp>
24#include <boost/serialization/tracking.hpp>
25#include <boost/serialization/string.hpp>
26
27#include <boost/archive/detail/abi_prefix.hpp> // must be the last header
28
29namespace boost { 
30namespace archive {
31       
32//////////////////////////////////////////////////////////////////////
33// class basic_xml_oarchive - write serialized objects to a xml output stream
34template<class Archive>
35class basic_xml_oarchive : 
36    public detail::common_oarchive<Archive>
37{
38protected:
39#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
40public:
41#elif defined(BOOST_MSVC)
42    // for some inexplicable reason insertion of "class" generates compile erro
43    // on msvc 7.1
44    friend detail::interface_oarchive<Archive>;
45#else
46    friend class detail::interface_oarchive<Archive>;
47#endif
48    // special stuff for xml output
49    unsigned int depth;
50    bool indent_next;
51    bool pending_preamble;
52    BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
53    indent();
54    BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
55    init();
56    BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
57    write_attribute(
58        const char *attribute_name, 
59        int t,
60        const char *conjunction = "=\""
61    );
62    BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
63    write_attribute(
64        const char *attribute_name, 
65        const char *key
66    );
67    // helpers used below
68    BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
69    save_start(const char *name);
70    BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
71    save_end(const char *name);
72    BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
73    end_preamble();
74
75    // Anything not an attribute and not a name-value pair is an
76    // error and should be trapped here.
77    template<class T>
78    void save_override(T & t, BOOST_PFTO int)
79    {
80        // If your program fails to compile here, its most likely due to
81        // not specifying an nvp wrapper around the variable to
82        // be serialized.
83        BOOST_STATIC_ASSERT(0 == sizeof(T));
84    }
85
86   // special treatment for name-value pairs.
87    typedef detail::common_oarchive<Archive> detail_common_oarchive;
88    template<class T>
89    void save_override(
90        #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
91        const
92        #endif
93        ::boost::serialization::nvp<T> & t, 
94        int
95    ){
96        save_start(t.name());
97        this->detail_common_oarchive::save_override(t.const_value(), 0);
98        save_end(t.name());
99    }
100
101    // specific overrides for attributes - not name value pairs so we
102    // want to trap them before the above "fall through"
103    BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
104    save_override(const object_id_type & t, int);
105    BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
106    save_override(const object_reference_type & t, int);
107    BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
108    save_override(const version_type & t, int);
109    BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
110    save_override(const class_id_type & t, int);
111    BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
112    save_override(const class_id_optional_type & t, int);
113    BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
114    save_override(const class_id_reference_type & t, int);
115    BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
116    save_override(const class_name_type & t, int);
117    BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
118    save_override(const tracking_type & t, int);
119
120    BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY()) 
121    basic_xml_oarchive(unsigned int flags);
122    BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY()) 
123    ~basic_xml_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_XML_OARCHIVE_HPP
Note: See TracBrowser for help on using the repository browser.