Statistics
| Revision:

root / tmp / org.txm.statsengine.r.core.win32 / res / win32 / library / BH / include / boost / archive / impl / basic_text_oprimitive.ipp @ 2486

History | View | Annotate | Download (2.9 kB)

1
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
2
// basic_text_oprimitive.ipp:
3

    
4
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . 
5
// Use, modification and distribution is subject to the Boost Software
6
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
7
// http://www.boost.org/LICENSE_1_0.txt)
8

    
9
//  See http://www.boost.org for updates, documentation, and revision history.
10

    
11
#include <cstddef> // NULL
12
#include <algorithm> // std::copy
13

    
14
#include <boost/archive/basic_text_oprimitive.hpp>
15
#include <boost/archive/codecvt_null.hpp>
16
#include <boost/archive/add_facet.hpp>
17

    
18
#include <boost/archive/iterators/base64_from_binary.hpp>
19
#include <boost/archive/iterators/insert_linebreaks.hpp>
20
#include <boost/archive/iterators/transform_width.hpp>
21
#include <boost/archive/iterators/ostream_iterator.hpp>
22

    
23
namespace boost {
24
namespace archive {
25

    
26
// translate to base64 and copy in to buffer.
27
template<class OStream>
28
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
29
basic_text_oprimitive<OStream>::save_binary(
30
    const void *address, 
31
    std::size_t count
32
){
33
    typedef typename OStream::char_type CharType;
34
    
35
    if(0 == count)
36
        return;
37
    
38
    if(os.fail())
39
        boost::serialization::throw_exception(
40
            archive_exception(archive_exception::output_stream_error)
41
        );
42
        
43
    os.put('\n');
44
    
45
    typedef 
46
        boost::archive::iterators::insert_linebreaks<
47
            boost::archive::iterators::base64_from_binary<
48
                boost::archive::iterators::transform_width<
49
                    const char *,
50
                    6,
51
                    8
52
                >
53
            > 
54
            ,76
55
            ,const char // cwpro8 needs this
56
        > 
57
        base64_text;
58

    
59
    boost::archive::iterators::ostream_iterator<CharType> oi(os);
60
    std::copy(
61
        base64_text(static_cast<const char *>(address)),
62
        base64_text(
63
            static_cast<const char *>(address) + count
64
        ),
65
        oi
66
    );
67
    
68
    std::size_t tail = count % 3;
69
    if(tail > 0){
70
        *oi++ = '=';
71
        if(tail < 2)
72
            *oi = '=';
73
    }
74
}
75

    
76
template<class OStream>
77
BOOST_ARCHIVE_OR_WARCHIVE_DECL
78
basic_text_oprimitive<OStream>::basic_text_oprimitive(
79
    OStream & os_,
80
    bool no_codecvt
81
) : 
82
#ifndef BOOST_NO_STD_LOCALE
83
    os(os_),
84
    flags_saver(os_),
85
    precision_saver(os_),
86
    locale_saver(* os_.rdbuf())
87
{
88
    if(! no_codecvt){
89
        archive_locale.reset(
90
            add_facet(
91
                std::locale::classic(),
92
                new boost::archive::codecvt_null<typename OStream::char_type>
93
            )
94
        );
95
        //os.imbue(* archive_locale);
96
    }
97
    os << std::noboolalpha;
98
}
99
#else
100
    os(os_),
101
    flags_saver(os_),
102
    precision_saver(os_)
103
{}
104
#endif
105

    
106
template<class OStream>
107
BOOST_ARCHIVE_OR_WARCHIVE_DECL
108
basic_text_oprimitive<OStream>::~basic_text_oprimitive(){
109
    os << std::endl;
110
}
111

    
112
} //namespace boost 
113
} //namespace archive