]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/archive/impl/text_oarchive_impl.ipp
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / boost / boost / archive / impl / text_oarchive_impl.ipp
CommitLineData
7c673cae
FG
1/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
2// text_oarchive_impl.ipp:
3
4// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
5// Distributed under the Boost Software License, Version 1.0. (See
6// 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 <string>
12#include <boost/config.hpp>
13#include <cstddef> // size_t
14
15#include <boost/config.hpp>
16#if defined(BOOST_NO_STDC_NAMESPACE)
17namespace std{
18 using ::size_t;
19} // namespace std
20#endif
21
22#ifndef BOOST_NO_CWCHAR
23#include <cwchar>
24#ifdef BOOST_NO_STDC_NAMESPACE
25namespace std{ using ::wcslen; }
26#endif
27#endif
28
29#include <boost/archive/text_oarchive.hpp>
30
31namespace boost {
32namespace archive {
33
34//////////////////////////////////////////////////////////////////////
35// implementation of basic_text_oprimitive overrides for the combination
36// of template parameters used to create a text_oprimitive
37
38template<class Archive>
39BOOST_ARCHIVE_DECL void
40text_oarchive_impl<Archive>::save(const char * s)
41{
42 const std::size_t len = std::ostream::traits_type::length(s);
43 *this->This() << len;
44 this->This()->newtoken();
45 os << s;
46}
47
48template<class Archive>
49BOOST_ARCHIVE_DECL void
50text_oarchive_impl<Archive>::save(const std::string &s)
51{
52 const std::size_t size = s.size();
53 *this->This() << size;
54 this->This()->newtoken();
55 os << s;
56}
57
58#ifndef BOOST_NO_CWCHAR
59#ifndef BOOST_NO_INTRINSIC_WCHAR_T
60template<class Archive>
61BOOST_ARCHIVE_DECL void
62text_oarchive_impl<Archive>::save(const wchar_t * ws)
63{
64 const std::size_t l = std::wcslen(ws);
65 * this->This() << l;
66 this->This()->newtoken();
67 os.write((const char *)ws, l * sizeof(wchar_t)/sizeof(char));
68}
69#endif
70
71#ifndef BOOST_NO_STD_WSTRING
72template<class Archive>
73BOOST_ARCHIVE_DECL void
74text_oarchive_impl<Archive>::save(const std::wstring &ws)
75{
76 const std::size_t l = ws.size();
77 * this->This() << l;
78 this->This()->newtoken();
79 os.write((const char *)(ws.data()), l * sizeof(wchar_t)/sizeof(char));
80}
81#endif
82#endif // BOOST_NO_CWCHAR
83
84template<class Archive>
85BOOST_ARCHIVE_DECL
86text_oarchive_impl<Archive>::text_oarchive_impl(
87 std::ostream & os,
88 unsigned int flags
89) :
90 basic_text_oprimitive<std::ostream>(
91 os,
92 0 != (flags & no_codecvt)
93 ),
94 basic_text_oarchive<Archive>(flags)
95{
7c673cae
FG
96}
97
98template<class Archive>
99BOOST_ARCHIVE_DECL void
100text_oarchive_impl<Archive>::save_binary(const void *address, std::size_t count){
101 put('\n');
102 this->end_preamble();
103 #if ! defined(__MWERKS__)
104 this->basic_text_oprimitive<std::ostream>::save_binary(
105 #else
106 this->basic_text_oprimitive::save_binary(
107 #endif
108 address,
109 count
110 );
111 this->delimiter = this->eol;
112}
113
114} // namespace archive
115} // namespace boost
116