]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/serialization/include/boost/archive/impl/text_woarchive_impl.ipp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / serialization / include / boost / archive / impl / text_woarchive_impl.ipp
1 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
2 // text_woarchive_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 <boost/config.hpp>
12 #ifndef BOOST_NO_STD_WSTREAMBUF
13
14 #include <cstring>
15 #include <cstddef> // size_t
16 #if defined(BOOST_NO_STDC_NAMESPACE) && ! defined(__LIBCOMO__)
17 namespace std{
18 using ::strlen;
19 using ::size_t;
20 } // namespace std
21 #endif
22
23 #include <ostream>
24
25 #include <boost/archive/text_woarchive.hpp>
26
27 namespace boost {
28 namespace archive {
29
30 //////////////////////////////////////////////////////////////////////
31 // implementation of woarchive functions
32 //
33 template<class Archive>
34 BOOST_WARCHIVE_DECL void
35 text_woarchive_impl<Archive>::save(const char *s)
36 {
37 // note: superfluous local variable fixes borland warning
38 const std::size_t size = std::strlen(s);
39 * this->This() << size;
40 this->This()->newtoken();
41 while(*s != '\0')
42 os.put(os.widen(*s++));
43 }
44
45 template<class Archive>
46 BOOST_WARCHIVE_DECL void
47 text_woarchive_impl<Archive>::save(const std::string &s)
48 {
49 const std::size_t size = s.size();
50 * this->This() << size;
51 this->This()->newtoken();
52 const char * cptr = s.data();
53 for(std::size_t i = size; i-- > 0;)
54 os.put(os.widen(*cptr++));
55 }
56
57 #ifndef BOOST_NO_INTRINSIC_WCHAR_T
58 template<class Archive>
59 BOOST_WARCHIVE_DECL void
60 text_woarchive_impl<Archive>::save(const wchar_t *ws)
61 {
62 const std::size_t size = std::wostream::traits_type::length(ws);
63 * this->This() << size;
64 this->This()->newtoken();
65 os.write(ws, size);
66 }
67 #endif
68
69 #ifndef BOOST_NO_STD_WSTRING
70 template<class Archive>
71 BOOST_WARCHIVE_DECL void
72 text_woarchive_impl<Archive>::save(const std::wstring &ws)
73 {
74 const std::size_t size = ws.length();
75 * this->This() << size;
76 this->This()->newtoken();
77 os.write(ws.data(), size);
78 }
79 #endif
80
81 } // namespace archive
82 } // namespace boost
83
84 #endif
85