]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/serialization/include/boost/archive/impl/text_oarchive_impl.ipp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / serialization / include / boost / archive / impl / text_oarchive_impl.ipp
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)
17 namespace 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
25 namespace std{ using ::wcslen; }
26 #endif
27 #endif
28
29 #include <boost/archive/text_oarchive.hpp>
30
31 namespace boost {
32 namespace archive {
33
34 //////////////////////////////////////////////////////////////////////
35 // implementation of basic_text_oprimitive overrides for the combination
36 // of template parameters used to create a text_oprimitive
37
38 template<class Archive>
39 BOOST_ARCHIVE_DECL void
40 text_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
48 template<class Archive>
49 BOOST_ARCHIVE_DECL void
50 text_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
60 template<class Archive>
61 BOOST_ARCHIVE_DECL void
62 text_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
72 template<class Archive>
73 BOOST_ARCHIVE_DECL void
74 text_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
84 template<class Archive>
85 BOOST_ARCHIVE_DECL
86 text_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 {
96 if(0 == (flags & no_header))
97 #if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3205))
98 this->init();
99 #else
100 this->basic_text_oarchive<Archive>::init();
101 #endif
102 }
103
104 template<class Archive>
105 BOOST_ARCHIVE_DECL void
106 text_oarchive_impl<Archive>::save_binary(const void *address, std::size_t count){
107 put('\n');
108 this->end_preamble();
109 #if ! defined(__MWERKS__)
110 this->basic_text_oprimitive<std::ostream>::save_binary(
111 #else
112 this->basic_text_oprimitive::save_binary(
113 #endif
114 address,
115 count
116 );
117 this->delimiter = this->eol;
118 }
119
120 } // namespace archive
121 } // namespace boost
122