1 | /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
---|
2 | // text_iarchive_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 | //////////////////////////////////////////////////////////////////////
|
---|
12 | // implementation of basic_text_iprimitive overrides for the combination
|
---|
13 | // of template parameters used to implement a text_iprimitive
|
---|
14 |
|
---|
15 | #include <cstddef> // size_t
|
---|
16 | #include <boost/config.hpp>
|
---|
17 | #if defined(BOOST_NO_STDC_NAMESPACE)
|
---|
18 | namespace std{
|
---|
19 | using ::size_t;
|
---|
20 | } // namespace std
|
---|
21 | #endif
|
---|
22 |
|
---|
23 | #include <boost/detail/workaround.hpp> // RogueWave
|
---|
24 |
|
---|
25 | #include <boost/archive/text_iarchive.hpp>
|
---|
26 |
|
---|
27 | namespace boost {
|
---|
28 | namespace archive {
|
---|
29 |
|
---|
30 | template<class Archive>
|
---|
31 | BOOST_ARCHIVE_DECL(void)
|
---|
32 | text_iarchive_impl<Archive>::load(char *s)
|
---|
33 | {
|
---|
34 | std::size_t size;
|
---|
35 | * this->This() >> size;
|
---|
36 | // skip separating space
|
---|
37 | is.get();
|
---|
38 | // Works on all tested platforms
|
---|
39 | is.read(s, size);
|
---|
40 | s[size] = '\0';
|
---|
41 | }
|
---|
42 |
|
---|
43 | template<class Archive>
|
---|
44 | BOOST_ARCHIVE_DECL(void)
|
---|
45 | text_iarchive_impl<Archive>::load(std::string &s)
|
---|
46 | {
|
---|
47 | std::size_t size;
|
---|
48 | * this->This() >> size;
|
---|
49 | // skip separating space
|
---|
50 | is.get();
|
---|
51 | // borland de-allocator fixup
|
---|
52 | #if BOOST_WORKAROUND(_RWSTD_VER, BOOST_TESTED_AT(20101))
|
---|
53 | if(NULL != s.data())
|
---|
54 | #endif
|
---|
55 | s.resize(size);
|
---|
56 | is.read(const_cast<char *>(s.data()), size);
|
---|
57 | }
|
---|
58 |
|
---|
59 | #ifndef BOOST_NO_CWCHAR
|
---|
60 | #ifndef BOOST_NO_INTRINSIC_WCHAR_T
|
---|
61 | template<class Archive>
|
---|
62 | BOOST_ARCHIVE_DECL(void)
|
---|
63 | text_iarchive_impl<Archive>::load(wchar_t *ws)
|
---|
64 | {
|
---|
65 | std::size_t size;
|
---|
66 | * this->This() >> size;
|
---|
67 | // skip separating space
|
---|
68 | is.get();
|
---|
69 | is.read((char *)ws, size * sizeof(wchar_t)/sizeof(char));
|
---|
70 | ws[size] = L'\0';
|
---|
71 | }
|
---|
72 | #endif // BOOST_NO_INTRINSIC_WCHAR_T
|
---|
73 |
|
---|
74 | #ifndef BOOST_NO_STD_WSTRING
|
---|
75 | template<class Archive>
|
---|
76 | BOOST_ARCHIVE_DECL(void)
|
---|
77 | text_iarchive_impl<Archive>::load(std::wstring &ws)
|
---|
78 | {
|
---|
79 | std::size_t size;
|
---|
80 | * this->This() >> size;
|
---|
81 | // borland de-allocator fixup
|
---|
82 | #if BOOST_WORKAROUND(_RWSTD_VER, BOOST_TESTED_AT(20101))
|
---|
83 | if(NULL != ws.data())
|
---|
84 | #endif
|
---|
85 | ws.resize(size);
|
---|
86 | // skip separating space
|
---|
87 | is.get();
|
---|
88 | is.read((char *)ws.data(), size * sizeof(wchar_t)/sizeof(char));
|
---|
89 | }
|
---|
90 |
|
---|
91 | #endif // BOOST_NO_STD_WSTRING
|
---|
92 | #endif // BOOST_NO_CWCHAR
|
---|
93 |
|
---|
94 | template<class Archive>
|
---|
95 | BOOST_ARCHIVE_DECL(void)
|
---|
96 | text_iarchive_impl<Archive>::load_override(class_name_type & t, int){
|
---|
97 | basic_text_iarchive<Archive>::load_override(t, 0);
|
---|
98 | }
|
---|
99 |
|
---|
100 | template<class Archive>
|
---|
101 | BOOST_ARCHIVE_DECL(void)
|
---|
102 | text_iarchive_impl<Archive>::init(){
|
---|
103 | basic_text_iarchive<Archive>::init();
|
---|
104 | }
|
---|
105 |
|
---|
106 | template<class Archive>
|
---|
107 | BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY())
|
---|
108 | text_iarchive_impl<Archive>::text_iarchive_impl(
|
---|
109 | std::istream & is,
|
---|
110 | unsigned int flags
|
---|
111 | ) :
|
---|
112 | basic_text_iprimitive<std::istream>(
|
---|
113 | is,
|
---|
114 | 0 != (flags & no_codecvt)
|
---|
115 | ),
|
---|
116 | basic_text_iarchive<Archive>(flags)
|
---|
117 | {
|
---|
118 | if(0 == (flags & no_header))
|
---|
119 | #if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3205))
|
---|
120 | this->init();
|
---|
121 | #else
|
---|
122 | this->basic_text_iarchive<Archive>::init();
|
---|
123 | #endif
|
---|
124 | }
|
---|
125 |
|
---|
126 | } // namespace archive
|
---|
127 | } // namespace boost
|
---|