comparison DEPENDENCIES/generic/include/boost/archive/basic_text_iprimitive.hpp @ 16:2665513ce2d3

Add boost headers
author Chris Cannam
date Tue, 05 Aug 2014 11:11:38 +0100
parents
children c530137014c0
comparison
equal deleted inserted replaced
15:663ca0da4350 16:2665513ce2d3
1 #ifndef BOOST_ARCHIVE_BASIC_TEXT_IPRIMITIVE_HPP
2 #define BOOST_ARCHIVE_BASIC_TEXT_IPRIMITIVE_HPP
3
4 // MS compatible compilers support #pragma once
5 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
6 # pragma once
7 #endif
8
9 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
10 // basic_text_iprimitive.hpp
11
12 // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
13 // Use, modification and distribution is subject to the Boost Software
14 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
15 // http://www.boost.org/LICENSE_1_0.txt)
16
17 // See http://www.boost.org for updates, documentation, and revision history.
18
19 // archives stored as text - note these are templated on the basic
20 // stream templates to accommodate wide (and other?) kind of characters
21 //
22 // Note the fact that on libraries without wide characters, ostream is
23 // not a specialization of basic_ostream which in fact is not defined
24 // in such cases. So we can't use basic_ostream<IStream::char_type> but rather
25 // use two template parameters
26
27 #include <boost/assert.hpp>
28 #include <locale>
29 #include <cstddef> // size_t
30
31 #include <boost/config.hpp>
32 #if defined(BOOST_NO_STDC_NAMESPACE)
33 namespace std{
34 using ::size_t;
35 #if ! defined(BOOST_DINKUMWARE_STDLIB) && ! defined(__SGI_STL_PORT)
36 using ::locale;
37 #endif
38 } // namespace std
39 #endif
40
41 #include <boost/detail/workaround.hpp>
42 #if BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, == 1)
43 #include <boost/archive/dinkumware.hpp>
44 #endif
45
46 #include <boost/limits.hpp>
47 #include <boost/io/ios_state.hpp>
48 #include <boost/scoped_ptr.hpp>
49 #include <boost/static_assert.hpp>
50
51 #include <boost/serialization/throw_exception.hpp>
52 #include <boost/archive/archive_exception.hpp>
53 #include <boost/archive/basic_streambuf_locale_saver.hpp>
54 #include <boost/archive/detail/abi_prefix.hpp> // must be the last header
55
56 namespace boost {
57 namespace archive {
58
59 /////////////////////////////////////////////////////////////////////////
60 // class basic_text_iarchive - load serialized objects from a input text stream
61 #if defined(_MSC_VER)
62 #pragma warning( push )
63 #pragma warning( disable : 4244 4267 )
64 #endif
65
66 template<class IStream>
67 class basic_text_iprimitive
68 {
69 #ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
70 protected:
71 #else
72 public:
73 #endif
74 IStream &is;
75 io::ios_flags_saver flags_saver;
76 io::ios_precision_saver precision_saver;
77
78 #ifndef BOOST_NO_STD_LOCALE
79 boost::scoped_ptr<std::locale> archive_locale;
80 basic_streambuf_locale_saver<
81 BOOST_DEDUCED_TYPENAME IStream::char_type,
82 BOOST_DEDUCED_TYPENAME IStream::traits_type
83 > locale_saver;
84 #endif
85
86 template<class T>
87 void load(T & t)
88 {
89 if(! is.fail()){
90 is >> t;
91 return;
92 }
93 boost::serialization::throw_exception(
94 archive_exception(archive_exception::input_stream_error)
95 );
96 }
97
98 void load(char & t)
99 {
100 short int i;
101 load(i);
102 t = i;
103 }
104 void load(signed char & t)
105 {
106 short int i;
107 load(i);
108 t = i;
109 }
110 void load(unsigned char & t)
111 {
112 unsigned short int i;
113 load(i);
114 t = i;
115 }
116
117 #ifndef BOOST_NO_INTRINSIC_WCHAR_T
118 void load(wchar_t & t)
119 {
120 BOOST_STATIC_ASSERT(sizeof(wchar_t) <= sizeof(int));
121 int i;
122 load(i);
123 t = i;
124 }
125 #endif
126 BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
127 basic_text_iprimitive(IStream &is, bool no_codecvt);
128 BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
129 ~basic_text_iprimitive();
130 public:
131 BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
132 load_binary(void *address, std::size_t count);
133 };
134
135 #if defined(_MSC_VER)
136 #pragma warning( pop )
137 #endif
138
139 } // namespace archive
140 } // namespace boost
141
142 #include <boost/archive/detail/abi_suffix.hpp> // pop pragmas
143
144 #endif // BOOST_ARCHIVE_BASIC_TEXT_IPRIMITIVE_HPP