41 #ifndef BINARY_DATA_ARCHIVE_HPP_ 42 #define BINARY_DATA_ARCHIVE_HPP_ 73 #include <boost/version.hpp> 74 #include <boost/serialization/serialization.hpp> 75 #include <boost/serialization/is_bitwise_serializable.hpp> 76 #include <boost/archive/detail/iserializer.hpp> 77 #include <boost/archive/detail/oserializer.hpp> 78 #include <boost/archive/archive_exception.hpp> 79 #include <boost/config.hpp> 80 #include <boost/mpl/bool.hpp> 83 #include <boost/version.hpp> 84 #if BOOST_VERSION >= 104600 85 #include <boost/serialization/item_version_type.hpp> 108 std::streambuf& m_sb;
128 m_sb(bsb), data_read(0)
137 m_sb(*is.rdbuf()), data_read(0)
165 const boost::archive::detail::basic_pointer_iserializer *
176 const boost::archive::detail::basic_iserializer & bis
187 load_a_type(t, boost::mpl::bool_<boost::serialization::implementation_level<T>::value == boost::serialization::primitive_type>() );
197 void load_override(
const boost::serialization::nvp<boost::serialization::collection_size_type> & t,
int){
200 t.value() = boost::serialization::collection_size_type(x);
215 #if BOOST_VERSION >= 106100 216 void load_override(
const boost::serialization::array_wrapper<T> &t,
int)
218 boost::serialization::array_wrapper<T> tmp(t.address(), t.count());
222 boost::serialization::array<T> tmp(t.address(), t.count());
256 std::streamsize s = count /
sizeof(
Elem);
257 std::streamsize scount = m_sb.sgetn(
258 static_cast<Elem *> (address), s);
259 if (scount != static_cast<std::streamsize> (s))
260 #if BOOST_VERSION >= 104400 261 boost::serialization::throw_exception(
262 boost::archive::archive_exception(
263 boost::archive::archive_exception::input_stream_error));
265 boost::serialization::throw_exception(
266 boost::archive::archive_exception(
267 boost::archive::archive_exception::stream_error));
270 s = count %
sizeof(
Elem);
278 scount = m_sb.sgetn(&t, 1);
280 #if BOOST_VERSION >= 104400 281 boost::serialization::throw_exception(
282 boost::archive::archive_exception(
283 boost::archive::archive_exception::input_stream_error));
285 boost::serialization::throw_exception(
286 boost::archive::archive_exception(
287 boost::archive::archive_exception::stream_error));
289 std::memcpy(static_cast<char*> (address) + (count - s), &t,
313 #if BOOST_VERSION >= 104100 314 boost::archive::detail::load_non_pointer_type<binary_data_iarchive>::load_only::invoke(*
this,t);
316 boost::archive::detail::load_non_pointer_type<binary_data_iarchive,T>::load_only::invoke(*
this,t);
327 #if defined(BOOST_NO_DEPENDENT_NESTED_DERIVATIONS) 329 typedef BOOST_DEDUCED_TYPENAME boost::serialization::is_bitwise_serializable<T>::type type;
332 struct apply :
public boost::serialization::is_bitwise_serializable<T> {};
339 template<
class ValueType>
340 #if BOOST_VERSION >= 106100 341 void load_array(boost::serialization::array_wrapper<ValueType>& a,
348 *
sizeof(ValueType));
364 std::streambuf & m_sb;
387 m_sb(*os.rdbuf()), data_written(0), mdo_save(do_save)
400 m_sb(sb), data_written(0), mdo_save(do_save)
416 const boost::archive::detail::basic_pointer_iserializer *
426 const boost::archive::detail::basic_oserializer & bos
439 return save_a_type(t,boost::mpl::bool_< boost::serialization::implementation_level<T>::value == boost::serialization::primitive_type>() );
460 count = (count +
sizeof(
Elem) - 1) /
sizeof(
Elem);
462 std::streamsize scount = m_sb.sputn(
463 static_cast<const Elem *> (address), count);
464 if (count != static_cast<std::size_t> (scount))
465 #if BOOST_VERSION >= 104400 466 boost::serialization::throw_exception(
467 boost::archive::archive_exception(
468 boost::archive::archive_exception::output_stream_error));
470 boost::serialization::throw_exception(
471 boost::archive::archive_exception(
472 boost::archive::archive_exception::stream_error));
475 data_written += count;
485 save_binary(&t,
sizeof(T));
489 #if BOOST_VERSION >= 104600 490 binary_data_oarchive &save_a_type(
const boost::serialization::version_type & t,boost::mpl::true_){
494 binary_data_oarchive &save_a_type(
const boost::serialization::item_version_type & t,boost::mpl::true_){
507 #if BOOST_VERSION >= 104100 508 boost::archive::detail::save_non_pointer_type<binary_data_oarchive>::save_only::invoke(*
this,t);
510 boost::archive::detail::save_non_pointer_type<binary_data_oarchive,T>::save_only::invoke(*
this,t);
521 #if defined(BOOST_NO_DEPENDENT_NESTED_DERIVATIONS) 523 typedef BOOST_DEDUCED_TYPENAME boost::serialization::is_bitwise_serializable<T>::type type;
526 struct apply :
public boost::serialization::is_bitwise_serializable<T> {};
533 template<
class ValueType>
534 #if BOOST_VERSION >= 106100 535 void save_array(boost::serialization::array_wrapper<ValueType>
const& a,
537 void save_array(boost::serialization::array<ValueType>
const& a,
541 save_binary(a.address(), a.count()
542 *
sizeof(ValueType));
This archive is capable of saving objects of serialization level 1 and 2 in a binary, non-portable format.
binary_data_iarchive Archive
void save_array(boost::serialization::array< ValueType > const &a, unsigned int)
The optimized save_array dispatches to save_binary.
binary_data_iarchive & load_a_type(T &t, boost::mpl::false_)
Specialisation for writing out composite types (objects).
binary_data_oarchive & operator&(T const &t)
Saving Archive Concept::operator&.
boost::mpl::bool_< true > is_saving
Saving Archive Concept::is_saving.
binary_data_oarchive & save_a_type(T const &t, boost::mpl::false_)
Specialisation for writing out composite types (objects).
boost::mpl::bool_< false > is_loading
Saving Archive Concept::is_loading.
This archive is capable of loading objects of serialization level 1 and 2 from a binary, non-portable format.
unsigned int get_library_version()
Saving Archive Concept::get_library_version()
void load_array(boost::serialization::array< ValueType > &a, unsigned int)
The optimized save_array dispatches to save_binary.
binary_data_oarchive(std::ostream &os, bool do_save=true)
Constructor from a standard output stream.
int getArchiveSize()
Helper method to say how much we read.
void load_override(const boost::serialization::nvp< T > &t, int)
These load_override functions are required to handle the nvt<T> cases in the serialization code...
const boost::archive::detail::basic_pointer_iserializer * register_type(T *=NULL)
Loading Archive Concept::register_type<T>() and ::register_type(u)
binary_data_iarchive(std::streambuf &bsb)
Constructor from a standard output stream.
binary_data_iarchive & operator&(T &t)
Loading Archive Concept::operator&.
unsigned int get_library_version()
Loading Archive Concept::get_library_version()
binary_data_iarchive & operator>>(T &t)
Loading Archive Concept::operator>>
binary_data_iarchive & load_a_type(T &t, boost::mpl::true_)
Specialisation for writing out primitive types.
binary_data_oarchive(std::streambuf &sb, bool do_save=true)
Constructor from a standard stream buffer.
binary_data_oarchive & save_a_type(T const &t, boost::mpl::true_)
Specialisation for writing out primitive types.
int getArchiveSize()
Helper method to say how much we wrote.
void delete_created_pointers()
Loading Archive Concept::delete_created_pointers()
void load_override(const boost::serialization::array< T > &t, int)
Specialisation that covers a boost serialization array created with make_array()
std::ostream & operator<<(std::ostream &os, const BufferPolicy &bp)
boost::mpl::bool_< true > is_loading
Loading Archive Concept::is_loading.
We provide an optimized load for all fundamental types typedef serialization::is_bitwise_serializable...
void reset_object_address(const void *new_address, const void *old_address)
Loading Archive Concept::reset_object_address(v,u)
void load_object(void *t, const boost::archive::detail::basic_iserializer &bis)
Note: not in LoadArchive concept but required when we use archive::load ! This function is only used ...
void save_binary(const void *address, std::size_t count)
Saving Archive Concept::save_binary(u, count)
boost::mpl::bool_< false > is_saving
Loading Archive Concept::is_saving.
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
binary_data_iarchive(std::istream &is)
Constructor from a standard stream buffer.
const boost::archive::detail::basic_pointer_iserializer * register_type(T *=NULL)
Saving Archive Concept::register_type<T>() and ::register_type(u)
void save_object(const void *x, const boost::archive::detail::basic_oserializer &bos)
Note: not in LoadArchive concept but required when we use archive::save !
void load_override(T &t, BOOST_PFTO int)
The standard type loading function.
binary_data_oarchive & operator<<(T const &t)
Saving Archive Concept::operator<<.
void load_binary(void *address, std::size_t count)
Loading Archive Concept::load_binary(u, count)
We provide an optimized load for all fundamental types typedef serialization::is_bitwise_serializable...