File indexing completed on 2025-01-18 09:28:29
0001 #ifndef BOOST_ARCHIVE_BASIC_TEXT_IPRIMITIVE_HPP
0002 #define BOOST_ARCHIVE_BASIC_TEXT_IPRIMITIVE_HPP
0003
0004
0005 #if defined(_MSC_VER)
0006 # pragma once
0007 #endif
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027 #include <locale>
0028 #include <cstddef> // size_t
0029
0030 #include <boost/config.hpp>
0031 #if defined(BOOST_NO_STDC_NAMESPACE)
0032 namespace std{
0033 using ::size_t;
0034 #if ! defined(BOOST_DINKUMWARE_STDLIB) && ! defined(__SGI_STL_PORT)
0035 using ::locale;
0036 #endif
0037 }
0038 #endif
0039
0040 #include <boost/io/ios_state.hpp>
0041 #include <boost/static_assert.hpp>
0042
0043 #include <boost/detail/workaround.hpp>
0044 #if BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, == 1)
0045 #include <boost/archive/dinkumware.hpp>
0046 #endif
0047 #include <boost/serialization/throw_exception.hpp>
0048 #include <boost/archive/codecvt_null.hpp>
0049 #include <boost/archive/archive_exception.hpp>
0050 #include <boost/archive/basic_streambuf_locale_saver.hpp>
0051 #include <boost/archive/detail/abi_prefix.hpp> // must be the last header
0052
0053 namespace boost {
0054 namespace archive {
0055
0056
0057
0058 #if defined(_MSC_VER)
0059 #pragma warning( push )
0060 #pragma warning( disable : 4244 4267 )
0061 #endif
0062
0063 template<class IStream>
0064 class BOOST_SYMBOL_VISIBLE basic_text_iprimitive {
0065 protected:
0066 IStream &is;
0067 io::ios_flags_saver flags_saver;
0068 io::ios_precision_saver precision_saver;
0069
0070 #ifndef BOOST_NO_STD_LOCALE
0071
0072
0073
0074
0075
0076
0077
0078 boost::archive::codecvt_null<typename IStream::char_type> codecvt_null_facet;
0079 std::locale archive_locale;
0080 basic_istream_locale_saver<
0081 typename IStream::char_type,
0082 typename IStream::traits_type
0083 > locale_saver;
0084 #endif
0085
0086 template<class T>
0087 void load(T & t)
0088 {
0089 if(is >> t)
0090 return;
0091 boost::serialization::throw_exception(
0092 archive_exception(archive_exception::input_stream_error)
0093 );
0094 }
0095
0096 void load(char & t)
0097 {
0098 short int i;
0099 load(i);
0100 t = i;
0101 }
0102 void load(signed char & t)
0103 {
0104 short int i;
0105 load(i);
0106 t = i;
0107 }
0108 void load(unsigned char & t)
0109 {
0110 unsigned short int i;
0111 load(i);
0112 t = i;
0113 }
0114
0115 #ifndef BOOST_NO_INTRINSIC_WCHAR_T
0116 void load(wchar_t & t)
0117 {
0118 BOOST_STATIC_ASSERT(sizeof(wchar_t) <= sizeof(int));
0119 int i;
0120 load(i);
0121 t = i;
0122 }
0123 #endif
0124 BOOST_ARCHIVE_OR_WARCHIVE_DECL
0125 basic_text_iprimitive(IStream &is, bool no_codecvt);
0126 BOOST_ARCHIVE_OR_WARCHIVE_DECL
0127 ~basic_text_iprimitive();
0128 public:
0129 BOOST_ARCHIVE_OR_WARCHIVE_DECL void
0130 load_binary(void *address, std::size_t count);
0131 };
0132
0133 #if defined(_MSC_VER)
0134 #pragma warning( pop )
0135 #endif
0136
0137 }
0138 }
0139
0140 #include <boost/archive/detail/abi_suffix.hpp> // pop pragmas
0141
0142 #endif