Back to home page

EIC code displayed by LXR

 
 

    


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 // MS compatible compilers support #pragma once
0005 #if defined(_MSC_VER)
0006 # pragma once
0007 #endif
0008 
0009 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
0010 // basic_text_iprimitive.hpp
0011 
0012 // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
0013 // Use, modification and distribution is subject to the Boost Software
0014 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0015 // http://www.boost.org/LICENSE_1_0.txt)
0016 
0017 //  See http://www.boost.org for updates, documentation, and revision history.
0018 
0019 // archives stored as text - note these are templated on the basic
0020 // stream templates to accommodate wide (and other?) kind of characters
0021 //
0022 // Note the fact that on libraries without wide characters, ostream is
0023 // not a specialization of basic_ostream which in fact is not defined
0024 // in such cases.   So we can't use basic_ostream<IStream::char_type> but rather
0025 // use two template parameters
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 } // namespace std
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 // class basic_text_iarchive - load serialized objects from a input text stream
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     // note order! - if you change this, libstd++ will fail!
0072     // a) create new locale with new codecvt facet
0073     // b) save current locale
0074     // c) change locale to new one
0075     // d) use stream buffer
0076     // e) change locale back to original
0077     // f) destroy new codecvt facet
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 } // namespace archive
0138 } // namespace boost
0139 
0140 #include <boost/archive/detail/abi_suffix.hpp> // pop pragmas
0141 
0142 #endif // BOOST_ARCHIVE_BASIC_TEXT_IPRIMITIVE_HPP