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