blob: 6683f528c036ed117ff7e2a19c1f6e218ca93c93 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// text_woarchive_impl.ipp:
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for updates, documentation, and revision history.
#include <boost/config.hpp>
#ifndef BOOST_NO_STD_WSTREAMBUF
#include <cstring>
#include <cstddef> // size_t
#if defined(BOOST_NO_STDC_NAMESPACE) && ! defined(__LIBCOMO__)
namespace std{
using ::strlen;
using ::size_t;
} // namespace std
#endif
#include <ostream>
#include <boost/archive/text_woarchive.hpp>
namespace boost {
namespace archive {
//////////////////////////////////////////////////////////////////////
// implementation of woarchive functions
//
template<class Archive>
BOOST_WARCHIVE_DECL(void)
text_woarchive_impl<Archive>::save(const char *s)
{
// note: superfluous local variable fixes borland warning
const std::size_t size = std::strlen(s);
* this->This() << size;
this->This()->newtoken();
while(*s != '\0')
os.put(os.widen(*s++));
}
template<class Archive>
BOOST_WARCHIVE_DECL(void)
text_woarchive_impl<Archive>::save(const std::string &s)
{
const std::size_t size = s.size();
* this->This() << size;
this->This()->newtoken();
const char * cptr = s.data();
for(std::size_t i = size; i-- > 0;)
os.put(os.widen(*cptr++));
}
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
template<class Archive>
BOOST_WARCHIVE_DECL(void)
text_woarchive_impl<Archive>::save(const wchar_t *ws)
{
const std::size_t size = std::wostream::traits_type::length(ws);
* this->This() << size;
this->This()->newtoken();
os.write(ws, size);
}
#endif
#ifndef BOOST_NO_STD_WSTRING
template<class Archive>
BOOST_WARCHIVE_DECL(void)
text_woarchive_impl<Archive>::save(const std::wstring &ws)
{
const std::size_t size = ws.length();
* this->This() << size;
this->This()->newtoken();
os.write(ws.data(), size);
}
#endif
} // namespace archive
} // namespace boost
#endif
|