os/ossrv/ossrv_pub/boost_apis/boost/archive/text_woarchive.hpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
#ifndef BOOST_ARCHIVE_TEXT_WOARCHIVE_HPP
sl@0
     2
#define BOOST_ARCHIVE_TEXT_WOARCHIVE_HPP
sl@0
     3
sl@0
     4
// MS compatible compilers support #pragma once
sl@0
     5
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
sl@0
     6
# pragma once
sl@0
     7
#endif
sl@0
     8
sl@0
     9
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
sl@0
    10
// text_woarchive.hpp
sl@0
    11
sl@0
    12
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . 
sl@0
    13
// Use, modification and distribution is subject to the Boost Software
sl@0
    14
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
sl@0
    15
// http://www.boost.org/LICENSE_1_0.txt)
sl@0
    16
sl@0
    17
//  See http://www.boost.org for updates, documentation, and revision history.
sl@0
    18
sl@0
    19
#include <boost/config.hpp>
sl@0
    20
sl@0
    21
#ifdef BOOST_NO_STD_WSTREAMBUF
sl@0
    22
#error "wide char i/o not supported on this platform"
sl@0
    23
#else
sl@0
    24
sl@0
    25
#include <ostream>
sl@0
    26
#include <cstddef> // size_t
sl@0
    27
sl@0
    28
#if defined(BOOST_NO_STDC_NAMESPACE)
sl@0
    29
namespace std{ 
sl@0
    30
    using ::size_t; 
sl@0
    31
} // namespace std
sl@0
    32
#endif
sl@0
    33
sl@0
    34
#include <boost/archive/detail/auto_link_warchive.hpp>
sl@0
    35
#include <boost/archive/basic_text_oprimitive.hpp>
sl@0
    36
#include <boost/archive/basic_text_oarchive.hpp>
sl@0
    37
sl@0
    38
#include <boost/archive/detail/abi_prefix.hpp> // must be the last header
sl@0
    39
sl@0
    40
namespace boost { 
sl@0
    41
namespace archive {
sl@0
    42
sl@0
    43
template<class Archive>
sl@0
    44
class text_woarchive_impl : 
sl@0
    45
    public basic_text_oprimitive<std::wostream>,
sl@0
    46
    public basic_text_oarchive<Archive>
sl@0
    47
{
sl@0
    48
#ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
sl@0
    49
public:
sl@0
    50
#else
sl@0
    51
    friend class detail::interface_oarchive<Archive>;
sl@0
    52
    friend class basic_text_oarchive<Archive>;
sl@0
    53
    friend class save_access;
sl@0
    54
protected:
sl@0
    55
#endif
sl@0
    56
    template<class T>
sl@0
    57
    void save(const T & t){
sl@0
    58
        this->newtoken();
sl@0
    59
        basic_text_oprimitive<std::wostream>::save(t);
sl@0
    60
    }
sl@0
    61
    BOOST_WARCHIVE_DECL(void)
sl@0
    62
    save(const char * t);
sl@0
    63
    #ifndef BOOST_NO_INTRINSIC_WCHAR_T
sl@0
    64
    BOOST_WARCHIVE_DECL(void)
sl@0
    65
    save(const wchar_t * t);
sl@0
    66
    #endif
sl@0
    67
    BOOST_WARCHIVE_DECL(void)
sl@0
    68
    save(const std::string &s);
sl@0
    69
    #ifndef BOOST_NO_STD_WSTRING
sl@0
    70
    BOOST_WARCHIVE_DECL(void)
sl@0
    71
    save(const std::wstring &ws);
sl@0
    72
    #endif
sl@0
    73
    text_woarchive_impl(std::wostream & os, unsigned int flags) :
sl@0
    74
        basic_text_oprimitive<std::wostream>(
sl@0
    75
            os, 
sl@0
    76
            0 != (flags & no_codecvt)
sl@0
    77
        ),
sl@0
    78
        basic_text_oarchive<Archive>(flags)
sl@0
    79
    {
sl@0
    80
        if(0 == (flags & no_header))
sl@0
    81
            basic_text_oarchive<Archive>::init();
sl@0
    82
    }
sl@0
    83
public:
sl@0
    84
    void save_binary(const void *address, std::size_t count){
sl@0
    85
        put(L'\n');
sl@0
    86
        this->end_preamble();
sl@0
    87
        #if ! defined(__MWERKS__)
sl@0
    88
        this->basic_text_oprimitive<std::wostream>::save_binary(
sl@0
    89
        #else
sl@0
    90
        this->basic_text_oprimitive::save_binary(
sl@0
    91
        #endif
sl@0
    92
            address, 
sl@0
    93
            count
sl@0
    94
        );
sl@0
    95
        put(L'\n');
sl@0
    96
        this->delimiter = this->none;
sl@0
    97
    }
sl@0
    98
sl@0
    99
};
sl@0
   100
sl@0
   101
// we use the following because we can't use
sl@0
   102
// typedef text_oarchive_impl<text_oarchive_impl<...> > text_oarchive;
sl@0
   103
sl@0
   104
// do not derive from this class.  If you want to extend this functionality
sl@0
   105
// via inhertance, derived from text_oarchive_impl instead.  This will
sl@0
   106
// preserve correct static polymorphism.
sl@0
   107
class text_woarchive : 
sl@0
   108
    public text_woarchive_impl<text_woarchive>
sl@0
   109
{
sl@0
   110
public:
sl@0
   111
    text_woarchive(std::wostream & os, unsigned int flags = 0) :
sl@0
   112
        text_woarchive_impl<text_woarchive>(os, flags)
sl@0
   113
    {}
sl@0
   114
    ~text_woarchive(){}
sl@0
   115
};
sl@0
   116
sl@0
   117
} // namespace archive
sl@0
   118
} // namespace boost
sl@0
   119
sl@0
   120
// required by smart_cast for compilers not implementing 
sl@0
   121
// partial template specialization
sl@0
   122
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(boost::archive::text_woarchive)
sl@0
   123
sl@0
   124
#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
sl@0
   125
sl@0
   126
#endif // BOOST_NO_STD_WSTREAMBUF
sl@0
   127
#endif // BOOST_ARCHIVE_TEXT_WOARCHIVE_HPP