source: NonGTP/Boost/boost/archive/text_woarchive.hpp @ 857

Revision 857, 3.7 KB checked in by igarcia, 19 years ago (diff)
Line 
1#ifndef BOOST_ARCHIVE_TEXT_WOARCHIVE_HPP
2#define BOOST_ARCHIVE_TEXT_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// text_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
21#ifdef BOOST_NO_STD_WSTREAMBUF
22#error "wide char i/o not supported on this platform"
23#else
24
25#include <ostream>
26#include <cstddef> // size_t
27
28#if defined(BOOST_NO_STDC_NAMESPACE)
29namespace std{
30    using ::size_t;
31} // namespace std
32#endif
33
34#include <boost/archive/detail/auto_link_warchive.hpp>
35#include <boost/archive/basic_text_oprimitive.hpp>
36#include <boost/archive/basic_text_oarchive.hpp>
37
38#include <boost/archive/detail/abi_prefix.hpp> // must be the last header
39
40namespace boost {
41namespace archive {
42
43template<class Archive>
44class text_woarchive_impl :
45    public basic_text_oprimitive<std::wostream>,
46    public basic_text_oarchive<Archive>
47{
48#ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
49public:
50#else
51    friend class detail::interface_oarchive<Archive>;
52    friend class basic_text_oarchive<Archive>;
53    friend class save_access;
54protected:
55#endif
56    template<class T>
57    void save(const T & t){
58        this->newtoken();
59        basic_text_oprimitive<std::wostream>::save(t);
60    }
61    BOOST_WARCHIVE_DECL(void)
62    save(const char * t);
63    #ifndef BOOST_NO_INTRINSIC_WCHAR_T
64    BOOST_WARCHIVE_DECL(void)
65    save(const wchar_t * t);
66    #endif
67    BOOST_WARCHIVE_DECL(void)
68    save(const std::string &s);
69    #ifndef BOOST_NO_STD_WSTRING
70    BOOST_WARCHIVE_DECL(void)
71    save(const std::wstring &ws);
72    #endif
73    text_woarchive_impl(std::wostream & os, unsigned int flags) :
74        basic_text_oprimitive<std::wostream>(
75            os,
76            0 != (flags & no_codecvt)
77        ),
78        basic_text_oarchive<Archive>(flags)
79    {
80        if(0 == (flags & no_header))
81            basic_text_oarchive<Archive>::init();
82    }
83public:
84    void save_binary(const void *address, std::size_t count){
85        put(L'\n');
86        this->end_preamble();
87        #if ! defined(__MWERKS__)
88        this->basic_text_oprimitive<std::wostream>::save_binary(
89        #else
90        this->basic_text_oprimitive::save_binary(
91        #endif
92            address,
93            count
94        );
95        put(L'\n');
96        this->delimiter = this->none;
97    }
98
99};
100
101// we use the following because we can't use
102// typedef text_oarchive_impl<text_oarchive_impl<...> > text_oarchive;
103
104// do not derive from this class.  If you want to extend this functionality
105// via inhertance, derived from text_oarchive_impl instead.  This will
106// preserve correct static polymorphism.
107class text_woarchive :
108    public text_woarchive_impl<text_woarchive>
109{
110public:
111    text_woarchive(std::wostream & os, unsigned int flags = 0) :
112        text_woarchive_impl<text_woarchive>(os, flags)
113    {}
114    ~text_woarchive(){}
115};
116
117} // namespace archive
118} // namespace boost
119
120// required by smart_cast for compilers not implementing
121// partial template specialization
122BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(boost::archive::text_woarchive)
123
124#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
125
126#endif // BOOST_NO_STD_WSTREAMBUF
127#endif // BOOST_ARCHIVE_TEXT_WOARCHIVE_HPP
Note: See TracBrowser for help on using the repository browser.