1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/stdapis/boost/archive/basic_text_oprimitive.hpp Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -0,0 +1,167 @@
1.4 +#ifndef BOOST_ARCHIVE_BASIC_TEXT_OPRIMITIVE_HPP
1.5 +#define BOOST_ARCHIVE_BASIC_TEXT_OPRIMITIVE_HPP
1.6 +
1.7 +// MS compatible compilers support #pragma once
1.8 +#if defined(_MSC_VER) && (_MSC_VER >= 1020)
1.9 +# pragma once
1.10 +#endif
1.11 +
1.12 +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
1.13 +// basic_text_oprimitive.hpp
1.14 +
1.15 +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
1.16 +// Use, modification and distribution is subject to the Boost Software
1.17 +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
1.18 +// http://www.boost.org/LICENSE_1_0.txt)
1.19 +
1.20 +// See http://www.boost.org for updates, documentation, and revision history.
1.21 +
1.22 +// archives stored as text - note these ar templated on the basic
1.23 +// stream templates to accommodate wide (and other?) kind of characters
1.24 +//
1.25 +// note the fact that on libraries without wide characters, ostream is
1.26 +// is not a specialization of basic_ostream which in fact is not defined
1.27 +// in such cases. So we can't use basic_ostream<OStream::char_type> but rather
1.28 +// use two template parameters
1.29 +
1.30 +#include <iomanip>
1.31 +#include <locale>
1.32 +#include <cstddef> // size_t
1.33 +#include <cmath> // isnan
1.34 +#include <cassert>
1.35 +
1.36 +#include <boost/config.hpp>
1.37 +#include <boost/detail/workaround.hpp>
1.38 +#if BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, == 1)
1.39 +#include <boost/archive/dinkumware.hpp>
1.40 +#endif
1.41 +
1.42 +#if defined(BOOST_NO_STDC_NAMESPACE)
1.43 +namespace std{
1.44 + using ::size_t;
1.45 + #if ! defined(BOOST_DINKUMWARE_STDLIB) && ! defined(__SGI_STL_PORT)
1.46 + using ::locale;
1.47 + #endif
1.48 +} // namespace std
1.49 +#endif
1.50 +
1.51 +#include <boost/limits.hpp>
1.52 +#include <boost/io/ios_state.hpp>
1.53 +#include <boost/scoped_ptr.hpp>
1.54 +#include <boost/throw_exception.hpp>
1.55 +#include <boost/archive/archive_exception.hpp>
1.56 +
1.57 +#include <boost/archive/detail/abi_prefix.hpp> // must be the last header
1.58 +
1.59 +namespace boost {
1.60 +namespace archive {
1.61 +
1.62 +class save_access;
1.63 +
1.64 +/////////////////////////////////////////////////////////////////////////
1.65 +// class basic_text_oprimitive - output of prmitives to stream
1.66 +template<class OStream>
1.67 +class basic_text_oprimitive
1.68 +{
1.69 +#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
1.70 +protected:
1.71 +#else
1.72 +public:
1.73 +#endif
1.74 + OStream &os;
1.75 + io::ios_flags_saver flags_saver;
1.76 + io::ios_precision_saver precision_saver;
1.77 + boost::scoped_ptr<std::locale> archive_locale;
1.78 + io::basic_ios_locale_saver<
1.79 + BOOST_DEDUCED_TYPENAME OStream::char_type, BOOST_DEDUCED_TYPENAME OStream::traits_type
1.80 + > locale_saver;
1.81 +
1.82 + // default saving of primitives.
1.83 + template<class T>
1.84 + void save(const T &t){
1.85 + if(os.fail())
1.86 + boost::throw_exception(archive_exception(archive_exception::stream_error));
1.87 + os << t;
1.88 + }
1.89 +
1.90 + /////////////////////////////////////////////////////////
1.91 + // fundamental types that need special treatment
1.92 + void save(const bool t){
1.93 + // trap usage of invalid uninitialized boolean which would
1.94 + // otherwise crash on load.
1.95 + int i = t;
1.96 + assert(0 == i || 1 == i);
1.97 + if(os.fail())
1.98 + boost::throw_exception(archive_exception(archive_exception::stream_error));
1.99 + os << t;
1.100 + }
1.101 + void save(const signed char t)
1.102 + {
1.103 + if(os.fail())
1.104 + boost::throw_exception(archive_exception(archive_exception::stream_error));
1.105 + os << static_cast<short int>(t);
1.106 + }
1.107 + void save(const unsigned char t)
1.108 + {
1.109 + if(os.fail())
1.110 + boost::throw_exception(archive_exception(archive_exception::stream_error));
1.111 + os << static_cast<short unsigned int>(t);
1.112 + }
1.113 + void save(const char t)
1.114 + {
1.115 + if(os.fail())
1.116 + boost::throw_exception(archive_exception(archive_exception::stream_error));
1.117 + os << static_cast<short int>(t);
1.118 + }
1.119 + #ifndef BOOST_NO_INTRINSIC_WCHAR_T
1.120 + void save(const wchar_t t)
1.121 + {
1.122 + if(os.fail())
1.123 + boost::throw_exception(archive_exception(archive_exception::stream_error));
1.124 + os << static_cast<int>(t);
1.125 + }
1.126 + #endif
1.127 + void save(const float t)
1.128 + {
1.129 + // must be a user mistake - can't serialize un-initialized data
1.130 + if(os.fail())
1.131 + boost::throw_exception(archive_exception(archive_exception::stream_error));
1.132 + os << std::setprecision(std::numeric_limits<float>::digits10 + 2);
1.133 + os << t;
1.134 + }
1.135 + void save(const double t)
1.136 + {
1.137 + // must be a user mistake - can't serialize un-initialized data
1.138 + if(os.fail())
1.139 + boost::throw_exception(archive_exception(archive_exception::stream_error));
1.140 + os << std::setprecision(std::numeric_limits<double>::digits10 + 2);
1.141 + os << t;
1.142 + }
1.143 + BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
1.144 + basic_text_oprimitive(OStream & os, bool no_codecvt);
1.145 + BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
1.146 + ~basic_text_oprimitive();
1.147 +public:
1.148 + // unformatted append of one character
1.149 + void put(int c){
1.150 + if(os.fail())
1.151 + boost::throw_exception(archive_exception(archive_exception::stream_error));
1.152 + os.put(c);
1.153 + }
1.154 + // unformatted append of null terminated string
1.155 + void put(const char * s){
1.156 + if(os.fail())
1.157 + boost::throw_exception(archive_exception(archive_exception::stream_error));
1.158 + while('\0' != *s)
1.159 + os.put(*s++);
1.160 + }
1.161 + BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
1.162 + save_binary(const void *address, std::size_t count);
1.163 +};
1.164 +
1.165 +} //namespace boost
1.166 +} //namespace archive
1.167 +
1.168 +#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
1.169 +
1.170 +#endif // BOOST_ARCHIVE_BASIC_TEXT_OPRIMITIVE_HPP