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> 116 std::streambuf& m_sb;
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));
372 std::streambuf & m_sb;
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));
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&.
RTT_API std::ostream & operator<<(std::ostream &os, FlowStatus fs)
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()
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...