[29] | 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) && (_MSC_VER >= 1020) |
---|
| 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 | |
---|
| 24 | #include <cstddef> // size_t |
---|
| 25 | #if defined(BOOST_NO_STDC_NAMESPACE) |
---|
| 26 | namespace std{ |
---|
| 27 | using ::size_t; |
---|
| 28 | } // namespace std |
---|
| 29 | #endif |
---|
| 30 | |
---|
| 31 | #include <ostream> |
---|
| 32 | |
---|
| 33 | #include <boost/archive/detail/auto_link_warchive.hpp> |
---|
| 34 | #include <boost/archive/basic_text_oprimitive.hpp> |
---|
| 35 | #include <boost/archive/basic_xml_oarchive.hpp> |
---|
| 36 | |
---|
| 37 | #include <boost/archive/detail/abi_prefix.hpp> // must be the last header |
---|
| 38 | |
---|
| 39 | namespace boost { |
---|
| 40 | namespace archive { |
---|
| 41 | |
---|
| 42 | BOOST_WARCHIVE_DECL(std::wostream &) |
---|
| 43 | operator<<(std::wostream &os, const char *t); |
---|
| 44 | |
---|
| 45 | BOOST_WARCHIVE_DECL(std::wostream &) |
---|
| 46 | operator<<(std::wostream &os, const char t); |
---|
| 47 | |
---|
| 48 | template<class Archive> |
---|
| 49 | class xml_woarchive_impl : |
---|
| 50 | public basic_text_oprimitive<std::wostream>, |
---|
| 51 | public basic_xml_oarchive<Archive> |
---|
| 52 | { |
---|
| 53 | #ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS |
---|
| 54 | public: |
---|
| 55 | #else |
---|
| 56 | friend class detail::interface_oarchive<Archive>; |
---|
| 57 | friend class basic_xml_oarchive<Archive>; |
---|
| 58 | friend class save_access; |
---|
| 59 | protected: |
---|
| 60 | #endif |
---|
| 61 | void end_preamble(){ |
---|
| 62 | basic_xml_oarchive<Archive>::end_preamble(); |
---|
| 63 | } |
---|
| 64 | template<class T> |
---|
| 65 | void |
---|
| 66 | save(const T & t){ |
---|
| 67 | basic_text_oprimitive<std::wostream>::save(t); |
---|
| 68 | } |
---|
| 69 | BOOST_WARCHIVE_DECL(void) |
---|
| 70 | save(const char * t); |
---|
| 71 | #ifndef BOOST_NO_INTRINSIC_WCHAR_T |
---|
| 72 | BOOST_WARCHIVE_DECL(void) |
---|
| 73 | save(const wchar_t * t); |
---|
| 74 | #endif |
---|
| 75 | BOOST_WARCHIVE_DECL(void) |
---|
| 76 | save(const std::string &s); |
---|
| 77 | #ifndef BOOST_NO_STD_WSTRING |
---|
| 78 | BOOST_WARCHIVE_DECL(void) |
---|
| 79 | save(const std::wstring &ws); |
---|
| 80 | #endif |
---|
| 81 | BOOST_WARCHIVE_DECL(BOOST_PP_EMPTY()) |
---|
| 82 | xml_woarchive_impl(std::wostream & os, unsigned int flags); |
---|
| 83 | ~xml_woarchive_impl(){} |
---|
| 84 | public: |
---|
| 85 | void |
---|
| 86 | save_binary(const void *address, std::size_t count){ |
---|
| 87 | this->end_preamble(); |
---|
| 88 | #if ! defined(__MWERKS__) |
---|
| 89 | this->basic_text_oprimitive<std::wostream>::save_binary( |
---|
| 90 | #else |
---|
| 91 | this->basic_text_oprimitive::save_binary( |
---|
| 92 | #endif |
---|
| 93 | address, |
---|
| 94 | count |
---|
| 95 | ); |
---|
| 96 | this->indent_next = true; |
---|
| 97 | } |
---|
| 98 | }; |
---|
| 99 | |
---|
| 100 | // we use the following because we can't use |
---|
| 101 | // typedef xml_woarchive_impl<xml_woarchive_impl<...> > xml_woarchive; |
---|
| 102 | |
---|
| 103 | // do not derive from this class. If you want to extend this functionality |
---|
| 104 | // via inhertance, derived from xml_woarchive_impl instead. This will |
---|
| 105 | // preserve correct static polymorphism. |
---|
| 106 | class xml_woarchive : |
---|
| 107 | public xml_woarchive_impl<xml_woarchive> |
---|
| 108 | { |
---|
| 109 | public: |
---|
| 110 | xml_woarchive(std::wostream & os, unsigned int flags = 0) : |
---|
| 111 | xml_woarchive_impl<xml_woarchive>(os, flags) |
---|
| 112 | {} |
---|
| 113 | ~xml_woarchive(){} |
---|
| 114 | }; |
---|
| 115 | |
---|
| 116 | } // namespace archive |
---|
| 117 | } // namespace boost |
---|
| 118 | |
---|
| 119 | // required by smart_cast for compilers not implementing |
---|
| 120 | // partial template specialization |
---|
| 121 | BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(boost::archive::xml_woarchive) |
---|
| 122 | |
---|
| 123 | #include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas |
---|
| 124 | |
---|
| 125 | #endif // BOOST_NO_STD_WSTREAMBUF |
---|
| 126 | #endif // BOOST_ARCHIVE_XML_OARCHIVE_HPP |
---|