97 #include <boost/version.hpp> 98 #include <boost/utility/enable_if.hpp> 99 #include <boost/archive/basic_binary_oprimitive.hpp> 100 #include <boost/archive/basic_binary_oarchive.hpp> 101 #include <boost/archive/detail/polymorphic_oarchive_route.hpp> 104 #include <boost/endian/conversion.hpp> 107 #if BOOST_VERSION < 106900 108 #include <boost/spirit/home/support/detail/math/fpclassify.hpp> 110 namespace fp = boost::spirit::math;
119 #if !defined(BOOST_MATH_DISABLE_STD_FPCLASSIFY) 120 #error "You must build using -DBOOST_MATH_DISABLE_STD_FPCLASSIFY!" 122 #include <boost/math/special_functions/fpclassify.hpp> 124 namespace fp = boost::math;
127 #ifndef BOOST_NO_STD_WSTRING 129 #include <boost/program_options/config.hpp> 130 #include <boost/program_options/detail/convert.hpp> 134 #include <boost/type_traits/is_integral.hpp> 135 #include <boost/type_traits/is_signed.hpp> 136 #include <boost/type_traits/is_arithmetic.hpp> 137 #include <boost/type_traits/is_floating_point.hpp> 141 namespace boost {
namespace archive {
146 typedef basic_binary_oprimitive <
148 , std::ostream::char_type
149 , std::ostream::traits_type
168 ,
public basic_binary_oarchive<portable_oarchive>
172 template<
int>
struct dummy { dummy(
int) {} };
175 inline void save_signed_char(
const signed char& c)
181 void init(
unsigned flags)
187 if (flags & no_header)
229 void save(
const std::string& s)
234 #ifndef BOOST_NO_STD_WSTRING 247 void save(
const std::wstring& s)
249 save(boost::to_utf8(s));
268 if (b) save_signed_char(
'T');
278 template <
typename T>
279 typename boost::enable_if<boost::is_integral<T> >::type
280 save(
const T & t, dummy<2> = 0)
286 signed char size = 0;
287 do { temp >>= CHAR_BIT; ++size; }
while (temp != 0 && temp != (T)-1);
290 save_signed_char(t > 0 ? size : -size);
291 BOOST_ASSERT(t > 0 || boost::is_signed<T>::value);
295 temp = boost::endian::native_to_little(t);
297 save_binary(&temp, size);
300 else save_signed_char(0);
330 template <
typename T>
331 typename boost::enable_if<boost::is_floating_point<T> >::type
332 save(
const T & t, dummy<3> = 0)
334 typedef typename fp::detail::fp_traits<T>::type traits;
337 if (get_flags() &
no_infnan && !fp::isfinite(t))
346 typename traits::bits bits;
347 BOOST_STATIC_ASSERT(
sizeof(bits) ==
sizeof(T));
348 BOOST_STATIC_ASSERT(std::numeric_limits<T>::is_iec559);
351 switch (fp::fpclassify(t))
354 #if defined(BOOST_MATH_FP_TRAITS_HPP) 356 case FP_NAN: bits = traits::exponent | traits::significand;
break;
358 #if defined(BOOST_SPIRIT_MATH_FP_TRAITS_HPP) 360 case FP_NAN: bits = traits::exponent | traits::mantissa;
break;
363 case FP_INFINITE: bits = traits::exponent | (t < 0) * traits::sign;
break;
364 case FP_SUBNORMAL: assert(std::numeric_limits<T>::has_denorm);
366 case FP_NORMAL: traits::get_bits(t, bits);
break;
375 template <
typename T>
376 typename boost::disable_if<boost::is_arithmetic<T> >::type
384 save((
typename boost::uint_t<
sizeof(T)*CHAR_BIT>::least)(t));
detail::polymorphic_oarchive_route< portable_oarchive > polymorphic_portable_oarchive
Definition: portable_oarchive.hpp:389
const archive_version_type archive_version(BOOST_ARCHIVE_VERSION())
void save(Archive &a_ar, const geomtools::vector_3d &v_, const unsigned int a_version)
Provides error handling and constants.
const signed char magic_byte
Definition: portable_archive_exception.hpp:31
Serialization stuff for CLHEP 'vector_3d'.
Definition: portable_archive_exception.hpp:27
void save(const std::string &s)
Save narrow strings.
Definition: portable_oarchive.hpp:229
Exception being thrown when serialization cannot proceed.
Definition: portable_archive_exception.hpp:56
boost::enable_if< boost::is_floating_point< T > >::type save(const T &t, dummy< 3 >=0)
Save floating point types.
Definition: portable_oarchive.hpp:332
void save(const std::wstring &s)
Save wide strings.
Definition: portable_oarchive.hpp:247
boost::enable_if< boost::is_integral< T > >::type save(const T &t, dummy< 2 >=0)
Save integer types.
Definition: portable_oarchive.hpp:280
basic_binary_oprimitive< portable_oarchive, std::ostream::char_type, std::ostream::traits_type > portable_oprimitive
Definition: portable_oarchive.hpp:144
portable_oarchive(std::streambuf &sb, unsigned flags=0)
Definition: portable_oarchive.hpp:221
void save(const bool &b)
Saving bool type.
Definition: portable_oarchive.hpp:265
const unsigned no_infnan
Definition: portable_archive_exception.hpp:34
boost::disable_if< boost::is_arithmetic< T > >::type save(const T &t, dummy< 4 >=0)
Definition: portable_oarchive.hpp:377
Portable binary output archive using little endian format.
Definition: portable_oarchive.hpp:164
portable_oarchive(std::ostream &os, unsigned flags=0)
Constructor on a stream using ios::binary mode!
Definition: portable_oarchive.hpp:214