• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef BOOST_ARCHIVE_XML_OARCHIVE_HPP
2 #define BOOST_ARCHIVE_XML_OARCHIVE_HPP
3 
4 // MS compatible compilers support #pragma once
5 #if defined(_MSC_VER)
6 # pragma once
7 #endif
8 
9 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
10 // 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 <ostream>
20 
21 #include <cstddef> // size_t
22 #include <boost/config.hpp>
23 #if defined(BOOST_NO_STDC_NAMESPACE)
24 namespace std{
25     using ::size_t;
26 } // namespace std
27 #endif
28 
29 #include <boost/archive/detail/auto_link_archive.hpp>
30 #include <boost/archive/basic_text_oprimitive.hpp>
31 #include <boost/archive/basic_xml_oarchive.hpp>
32 #include <boost/archive/detail/register_archive.hpp>
33 #include <boost/serialization/item_version_type.hpp>
34 
35 #include <boost/archive/detail/abi_prefix.hpp> // must be the last header
36 
37 #ifdef BOOST_MSVC
38 #  pragma warning(push)
39 #  pragma warning(disable : 4511 4512)
40 #endif
41 
42 namespace boost {
43 namespace archive {
44 
45 namespace detail {
46     template<class Archive> class interface_oarchive;
47 } // namespace detail
48 
49 template<class Archive>
50 class BOOST_SYMBOL_VISIBLE xml_oarchive_impl :
51     public basic_text_oprimitive<std::ostream>,
52     public basic_xml_oarchive<Archive>
53 {
54 #ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
55 public:
56 #else
57 protected:
58     friend class detail::interface_oarchive<Archive>;
59     friend class basic_xml_oarchive<Archive>;
60     friend class save_access;
61 #endif
62     template<class T>
save(const T & t)63     void save(const T & t){
64         basic_text_oprimitive<std::ostream>::save(t);
65     }
66     void
save(const version_type & t)67     save(const version_type & t){
68         save(static_cast<unsigned int>(t));
69     }
70     void
save(const boost::serialization::item_version_type & t)71     save(const boost::serialization::item_version_type & t){
72         save(static_cast<unsigned int>(t));
73     }
74     BOOST_ARCHIVE_DECL void
75     save(const char * t);
76     #ifndef BOOST_NO_INTRINSIC_WCHAR_T
77     BOOST_ARCHIVE_DECL void
78     save(const wchar_t * t);
79     #endif
80     BOOST_ARCHIVE_DECL void
81     save(const std::string &s);
82     #ifndef BOOST_NO_STD_WSTRING
83     BOOST_ARCHIVE_DECL void
84     save(const std::wstring &ws);
85     #endif
86     BOOST_ARCHIVE_DECL
87     xml_oarchive_impl(std::ostream & os, unsigned int flags);
88     BOOST_ARCHIVE_DECL
89     ~xml_oarchive_impl() BOOST_OVERRIDE;
90 public:
91     BOOST_ARCHIVE_DECL
92     void save_binary(const void *address, std::size_t count);
93 };
94 
95 } // namespace archive
96 } // namespace boost
97 
98 #ifdef BOOST_MSVC
99 #pragma warning(pop)
100 #endif
101 
102 #include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
103 #ifdef BOOST_MSVC
104 #  pragma warning(push)
105 #  pragma warning(disable : 4511 4512)
106 #endif
107 
108 namespace boost {
109 namespace archive {
110 
111 // we use the following because we can't use
112 // typedef xml_oarchive_impl<xml_oarchive_impl<...> > xml_oarchive;
113 
114 // do not derive from this class.  If you want to extend this functionality
115 // via inheritance, derived from xml_oarchive_impl instead.  This will
116 // preserve correct static polymorphism.
117 class BOOST_SYMBOL_VISIBLE xml_oarchive :
118     public xml_oarchive_impl<xml_oarchive>
119 {
120 public:
xml_oarchive(std::ostream & os,unsigned int flags=0)121     xml_oarchive(std::ostream & os, unsigned int flags = 0) :
122         xml_oarchive_impl<xml_oarchive>(os, flags)
123     {
124         if(0 == (flags & no_header))
125             init();
126     }
~xml_oarchive()127     ~xml_oarchive() BOOST_OVERRIDE {}
128 };
129 
130 } // namespace archive
131 } // namespace boost
132 
133 // required by export
134 BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::xml_oarchive)
135 
136 #ifdef BOOST_MSVC
137 #pragma warning(pop)
138 #endif
139 
140 #endif // BOOST_ARCHIVE_XML_OARCHIVE_HPP
141