fix doc example typo
[boost.git] / boost / archive / xml_oarchive.hpp
blob87dca8deccfd95bd1c9ecf8c239a37c98dd0cfd1
1 #ifndef BOOST_ARCHIVE_XML_OARCHIVE_HPP
2 #define BOOST_ARCHIVE_XML_OARCHIVE_HPP
4 // MS compatible compilers support #pragma once
5 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
6 # pragma once
7 #endif
9 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
10 // xml_oarchive.hpp
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)
17 // See http://www.boost.org for updates, documentation, and revision history.
19 #include <ostream>
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
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>
33 #include <boost/archive/detail/abi_prefix.hpp> // must be the last header
35 namespace boost {
36 namespace archive {
38 template<class Archive>
39 class xml_oarchive_impl :
40 public basic_text_oprimitive<std::ostream>,
41 public basic_xml_oarchive<Archive>
43 #ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
44 public:
45 #else
46 friend class detail::interface_oarchive<Archive>;
47 friend class basic_xml_oarchive<Archive>;
48 friend class save_access;
49 protected:
50 #endif
51 //void end_preamble(){
52 // basic_xml_oarchive<Archive>::end_preamble();
53 //}
54 template<class T>
55 void save(const T & t){
56 basic_text_oprimitive<std::ostream>::save(t);
58 BOOST_ARCHIVE_DECL(void)
59 save(const char * t);
60 #ifndef BOOST_NO_INTRINSIC_WCHAR_T
61 BOOST_ARCHIVE_DECL(void)
62 save(const wchar_t * t);
63 #endif
64 BOOST_ARCHIVE_DECL(void)
65 save(const std::string &s);
66 #ifndef BOOST_NO_STD_WSTRING
67 BOOST_ARCHIVE_DECL(void)
68 save(const std::wstring &ws);
69 #endif
70 BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY())
71 xml_oarchive_impl(std::ostream & os, unsigned int flags);
72 ~xml_oarchive_impl(){}
73 public:
74 void save_binary(const void *address, std::size_t count){
75 this->end_preamble();
76 #if ! defined(__MWERKS__)
77 this->basic_text_oprimitive<std::ostream>::save_binary(
78 #else
79 this->basic_text_oprimitive::save_binary(
80 #endif
81 address,
82 count
84 this->indent_next = true;
88 // we use the following because we can't use
89 // typedef xml_oarchive_impl<xml_oarchive_impl<...> > xml_oarchive;
91 // do not derive from this class. If you want to extend this functionality
92 // via inhertance, derived from xml_oarchive_impl instead. This will
93 // preserve correct static polymorphism.
94 class xml_oarchive :
95 public xml_oarchive_impl<xml_oarchive>
97 public:
98 xml_oarchive(std::ostream & os, unsigned int flags = 0) :
99 xml_oarchive_impl<xml_oarchive>(os, flags)
101 ~xml_oarchive(){}
104 typedef xml_oarchive naked_xml_oarchive;
106 } // namespace archive
107 } // namespace boost
109 // required by export
110 BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::xml_oarchive)
112 #include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
114 #endif // BOOST_ARCHIVE_XML_OARCHIVE_HPP