41 #ifndef BINARY_DATA_ARCHIVE_HPP_ 42 #define BINARY_DATA_ARCHIVE_HPP_ 73 #include <boost/version.hpp> 74 #if BOOST_VERSION >= 106400 78 # include <boost/serialization/array_wrapper.hpp> 80 # include <boost/serialization/array.hpp> 82 #include <boost/serialization/serialization.hpp> 83 #include <boost/serialization/is_bitwise_serializable.hpp> 84 #include <boost/archive/detail/iserializer.hpp> 85 #include <boost/archive/detail/oserializer.hpp> 86 #include <boost/archive/archive_exception.hpp> 87 #include <boost/config.hpp> 88 #include <boost/mpl/bool.hpp> 91 #include <boost/version.hpp> 92 #if BOOST_VERSION >= 104600 93 #include <boost/serialization/item_version_type.hpp> 136 m_sb(bsb), data_read(0)
145 m_sb(*is.rdbuf()), data_read(0)
173 const boost::archive::detail::basic_pointer_iserializer *
184 const boost::archive::detail::basic_iserializer & bis
195 load_a_type(t, boost::mpl::bool_<boost::serialization::implementation_level<T>::value == boost::serialization::primitive_type>() );
205 void load_override(
const boost::serialization::nvp<boost::serialization::collection_size_type> & t,
int){
208 t.value() = boost::serialization::collection_size_type(x);
223 #if BOOST_VERSION >= 106100 224 void load_override(
const boost::serialization::array_wrapper<T> &t,
int)
226 boost::serialization::array_wrapper<T> tmp(t.address(), t.count());
230 boost::serialization::array<T> tmp(t.address(), t.count());
264 std::streamsize s = count /
sizeof(
Elem);
265 std::streamsize scount = m_sb.sgetn(
266 static_cast<Elem *> (address), s);
267 if (scount != static_cast<std::streamsize> (s))
268 #if BOOST_VERSION >= 104400 269 boost::serialization::throw_exception(
270 boost::archive::archive_exception(
271 boost::archive::archive_exception::input_stream_error));
273 boost::serialization::throw_exception(
274 boost::archive::archive_exception(
275 boost::archive::archive_exception::stream_error));
278 s = count %
sizeof(
Elem);
286 scount = m_sb.sgetn(&t, 1);
288 #if BOOST_VERSION >= 104400 289 boost::serialization::throw_exception(
290 boost::archive::archive_exception(
291 boost::archive::archive_exception::input_stream_error));
293 boost::serialization::throw_exception(
294 boost::archive::archive_exception(
295 boost::archive::archive_exception::stream_error));
297 std::memcpy(static_cast<char*> (address) + (count - s), &t,
321 #if BOOST_VERSION >= 104100 322 boost::archive::detail::load_non_pointer_type<binary_data_iarchive>::load_only::invoke(*
this,t);
324 boost::archive::detail::load_non_pointer_type<binary_data_iarchive,T>::load_only::invoke(*
this,t);
335 #if defined(BOOST_NO_DEPENDENT_NESTED_DERIVATIONS) 337 typedef BOOST_DEDUCED_TYPENAME boost::serialization::is_bitwise_serializable<T>::type type;
340 struct apply :
public boost::serialization::is_bitwise_serializable<T> {};
347 template<
class ValueType>
348 #if BOOST_VERSION >= 106100 349 void load_array(boost::serialization::array_wrapper<ValueType>& a,
356 *
sizeof(ValueType));
395 m_sb(*os.rdbuf()), data_written(0), mdo_save(do_save)
408 m_sb(sb), data_written(0), mdo_save(do_save)
424 const boost::archive::detail::basic_pointer_iserializer *
434 const boost::archive::detail::basic_oserializer & bos
447 return save_a_type(t,boost::mpl::bool_< boost::serialization::implementation_level<T>::value == boost::serialization::primitive_type>() );
468 count = (count +
sizeof(
Elem) - 1) /
sizeof(
Elem);
470 std::streamsize scount = m_sb.sputn(
471 static_cast<const Elem *> (address), count);
472 if (count != static_cast<std::size_t> (scount))
473 #if BOOST_VERSION >= 104400 474 boost::serialization::throw_exception(
475 boost::archive::archive_exception(
476 boost::archive::archive_exception::output_stream_error));
478 boost::serialization::throw_exception(
479 boost::archive::archive_exception(
480 boost::archive::archive_exception::stream_error));
483 data_written += count;
493 save_binary(&t,
sizeof(T));
497 #if BOOST_VERSION >= 104600 498 binary_data_oarchive &save_a_type(
const boost::serialization::version_type & t,boost::mpl::true_){
502 binary_data_oarchive &save_a_type(
const boost::serialization::item_version_type & t,boost::mpl::true_){
515 #if BOOST_VERSION >= 104100 516 boost::archive::detail::save_non_pointer_type<binary_data_oarchive>::save_only::invoke(*
this,t);
518 boost::archive::detail::save_non_pointer_type<binary_data_oarchive,T>::save_only::invoke(*
this,t);
529 #if defined(BOOST_NO_DEPENDENT_NESTED_DERIVATIONS) 531 typedef BOOST_DEDUCED_TYPENAME boost::serialization::is_bitwise_serializable<T>::type type;
534 struct apply :
public boost::serialization::is_bitwise_serializable<T> {};
541 template<
class ValueType>
542 #if BOOST_VERSION >= 106100 543 void save_array(boost::serialization::array_wrapper<ValueType>
const& a,
545 void save_array(boost::serialization::array<ValueType>
const& a,
549 save_binary(a.address(), a.count()
550 *
sizeof(ValueType));
binary_data_iarchive Archive
void save_array(boost::serialization::array< ValueType > const &a, unsigned int)
binary_data_iarchive & load_a_type(T &t, boost::mpl::false_)
binary_data_oarchive & operator&(T const &t)
boost::mpl::bool_< true > is_saving
binary_data_oarchive & save_a_type(T const &t, boost::mpl::false_)
boost::mpl::bool_< false > is_loading
unsigned int get_library_version()
void load_array(boost::serialization::array< ValueType > &a, unsigned int)
binary_data_oarchive(std::ostream &os, bool do_save=true)
void load_override(const boost::serialization::nvp< T > &t, int)
const boost::archive::detail::basic_pointer_iserializer * register_type(T *=NULL)
binary_data_iarchive(std::streambuf &bsb)
binary_data_iarchive & operator&(T &t)
unsigned int get_library_version()
binary_data_iarchive & operator>>(T &t)
binary_data_iarchive & load_a_type(T &t, boost::mpl::true_)
binary_data_oarchive(std::streambuf &sb, bool do_save=true)
binary_data_oarchive & save_a_type(T const &t, boost::mpl::true_)
void delete_created_pointers()
void load_override(const boost::serialization::array< T > &t, int)
std::ostream & operator<<(std::ostream &os, const BufferPolicy &bp)
boost::mpl::bool_< true > is_loading
void reset_object_address(const void *new_address, const void *old_address)
void load_object(void *t, const boost::archive::detail::basic_iserializer &bis)
void save_binary(const void *address, std::size_t count)
boost::mpl::bool_< false > is_saving
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
binary_data_iarchive(std::istream &is)
const boost::archive::detail::basic_pointer_iserializer * register_type(T *=NULL)
void save_object(const void *x, const boost::archive::detail::basic_oserializer &bos)
void load_override(T &t, BOOST_PFTO int)
binary_data_oarchive & operator<<(T const &t)
void load_binary(void *address, std::size_t count)