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 2486 sjacqu01
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
2 2486 sjacqu01
// basic_text_oprimitive.ipp:
3 2486 sjacqu01
4 2486 sjacqu01
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
5 2486 sjacqu01
// Use, modification and distribution is subject to the Boost Software
6 2486 sjacqu01
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
7 2486 sjacqu01
// http://www.boost.org/LICENSE_1_0.txt)
8 2486 sjacqu01
9 2486 sjacqu01
//  See http://www.boost.org for updates, documentation, and revision history.
10 2486 sjacqu01
11 2486 sjacqu01
#include <cstddef> // NULL
12 2486 sjacqu01
#include <algorithm> // std::copy
13 2486 sjacqu01
14 2486 sjacqu01
#include <boost/archive/basic_text_oprimitive.hpp>
15 2486 sjacqu01
#include <boost/archive/codecvt_null.hpp>
16 2486 sjacqu01
#include <boost/archive/add_facet.hpp>
17 2486 sjacqu01
18 2486 sjacqu01
#include <boost/archive/iterators/base64_from_binary.hpp>
19 2486 sjacqu01
#include <boost/archive/iterators/insert_linebreaks.hpp>
20 2486 sjacqu01
#include <boost/archive/iterators/transform_width.hpp>
21 2486 sjacqu01
#include <boost/archive/iterators/ostream_iterator.hpp>
22 2486 sjacqu01
23 2486 sjacqu01
namespace boost {
24 2486 sjacqu01
namespace archive {
25 2486 sjacqu01
26 2486 sjacqu01
// translate to base64 and copy in to buffer.
27 2486 sjacqu01
template<class OStream>
28 2486 sjacqu01
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
29 2486 sjacqu01
basic_text_oprimitive<OStream>::save_binary(
30 2486 sjacqu01
    const void *address,
31 2486 sjacqu01
    std::size_t count
32 2486 sjacqu01
){
33 2486 sjacqu01
    typedef typename OStream::char_type CharType;
34 2486 sjacqu01
35 2486 sjacqu01
    if(0 == count)
36 2486 sjacqu01
        return;
37 2486 sjacqu01
38 2486 sjacqu01
    if(os.fail())
39 2486 sjacqu01
        boost::serialization::throw_exception(
40 2486 sjacqu01
            archive_exception(archive_exception::output_stream_error)
41 2486 sjacqu01
        );
42 2486 sjacqu01
43 2486 sjacqu01
    os.put('\n');
44 2486 sjacqu01
45 2486 sjacqu01
    typedef
46 2486 sjacqu01
        boost::archive::iterators::insert_linebreaks<
47 2486 sjacqu01
            boost::archive::iterators::base64_from_binary<
48 2486 sjacqu01
                boost::archive::iterators::transform_width<
49 2486 sjacqu01
                    const char *,
50 2486 sjacqu01
                    6,
51 2486 sjacqu01
                    8
52 2486 sjacqu01
                >
53 2486 sjacqu01
            >
54 2486 sjacqu01
            ,76
55 2486 sjacqu01
            ,const char // cwpro8 needs this
56 2486 sjacqu01
        >
57 2486 sjacqu01
        base64_text;
58 2486 sjacqu01
59 2486 sjacqu01
    boost::archive::iterators::ostream_iterator<CharType> oi(os);
60 2486 sjacqu01
    std::copy(
61 2486 sjacqu01
        base64_text(static_cast<const char *>(address)),
62 2486 sjacqu01
        base64_text(
63 2486 sjacqu01
            static_cast<const char *>(address) + count
64 2486 sjacqu01
        ),
65 2486 sjacqu01
        oi
66 2486 sjacqu01
    );
67 2486 sjacqu01
68 2486 sjacqu01
    std::size_t tail = count % 3;
69 2486 sjacqu01
    if(tail > 0){
70 2486 sjacqu01
        *oi++ = '=';
71 2486 sjacqu01
        if(tail < 2)
72 2486 sjacqu01
            *oi = '=';
73 2486 sjacqu01
    }
74 2486 sjacqu01
}
75 2486 sjacqu01
76 2486 sjacqu01
template<class OStream>
77 2486 sjacqu01
BOOST_ARCHIVE_OR_WARCHIVE_DECL
78 2486 sjacqu01
basic_text_oprimitive<OStream>::basic_text_oprimitive(
79 2486 sjacqu01
    OStream & os_,
80 2486 sjacqu01
    bool no_codecvt
81 2486 sjacqu01
) :
82 2486 sjacqu01
#ifndef BOOST_NO_STD_LOCALE
83 2486 sjacqu01
    os(os_),
84 2486 sjacqu01
    flags_saver(os_),
85 2486 sjacqu01
    precision_saver(os_),
86 2486 sjacqu01
    locale_saver(* os_.rdbuf())
87 2486 sjacqu01
{
88 2486 sjacqu01
    if(! no_codecvt){
89 2486 sjacqu01
        archive_locale.reset(
90 2486 sjacqu01
            add_facet(
91 2486 sjacqu01
                std::locale::classic(),
92 2486 sjacqu01
                new boost::archive::codecvt_null<typename OStream::char_type>
93 2486 sjacqu01
            )
94 2486 sjacqu01
        );
95 2486 sjacqu01
        //os.imbue(* archive_locale);
96 2486 sjacqu01
    }
97 2486 sjacqu01
    os << std::noboolalpha;
98 2486 sjacqu01
}
99 2486 sjacqu01
#else
100 2486 sjacqu01
    os(os_),
101 2486 sjacqu01
    flags_saver(os_),
102 2486 sjacqu01
    precision_saver(os_)
103 2486 sjacqu01
{}
104 2486 sjacqu01
#endif
105 2486 sjacqu01
106 2486 sjacqu01
template<class OStream>
107 2486 sjacqu01
BOOST_ARCHIVE_OR_WARCHIVE_DECL
108 2486 sjacqu01
basic_text_oprimitive<OStream>::~basic_text_oprimitive(){
109 2486 sjacqu01
    os << std::endl;
110 2486 sjacqu01
}
111 2486 sjacqu01
112 2486 sjacqu01
} //namespace boost
113 2486 sjacqu01
} //namespace archive