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

source code of boost/libs/serialization/include/boost/archive/xml_woarchive.hpp