24 #ifndef GOBY_MIDDLEWARE_MARSHALLING_BOOST_SERIALIZATION_H
25 #define GOBY_MIDDLEWARE_MARSHALLING_BOOST_SERIALIZATION_H
27 #include <boost/archive/binary_iarchive.hpp>
28 #include <boost/archive/binary_oarchive.hpp>
29 #include <boost/iostreams/device/back_inserter.hpp>
30 #include <boost/iostreams/stream.hpp>
31 #include <boost/serialization/shared_ptr.hpp>
32 #include <boost/serialization/string.hpp>
33 #include <boost/serialization/vector.hpp>
37 #include "goby/middleware/marshalling/interface.h"
51 return T::goby_boost_serialization_type;
58 std::vector<char> data;
59 boost::iostreams::back_insert_device<std::vector<char>> inserter(data);
60 boost::iostreams::stream<boost::iostreams::back_insert_device<std::vector<char>>> stream(
62 boost::archive::binary_oarchive oa(stream);
69 static std::string
type_name(
const T& t = T()) {
return boost_serialization_type_name<T>(); }
71 template <
typename CharIterator>
72 static std::shared_ptr<T>
parse(CharIterator bytes_begin, CharIterator bytes_end,
73 CharIterator& actual_end,
const std::string& type = type_name())
75 std::shared_ptr<T> t = std::make_shared<T>();
77 boost::iostreams::basic_array_source<char> device(&(*bytes_begin), &(*bytes_end));
78 boost::iostreams::stream<boost::iostreams::basic_array_source<char>> stream(device);
79 boost::archive::binary_iarchive ia(stream);
82 actual_end = bytes_end;
89 typename std::enable_if<T::goby_boost_serialization_type != nullptr>::type* =
nullptr>
102 namespace serialization
105 template <
class Archive>
113 template <
class Archive>
129 template <> constexpr
const char* boost_serialization_type_name<netsim::TaggedAudioBuffer>()
131 return "TaggedAudioBuffer";