22 #ifndef __M2ETIS_MESSAGE_SERIALIZATION_H__
23 #define __M2ETIS_MESSAGE_SERIALIZATION_H__
29 #include "boost/archive/text_iarchive.hpp"
30 #include "boost/archive/text_oarchive.hpp"
32 #ifdef WITH_MESSAGECOMPRESSION
33 #include "boost/iostreams/filtering_streambuf.hpp"
34 #include "boost/iostreams/copy.hpp"
35 #include "boost/iostreams/filter/zlib.hpp"
40 namespace serialization {
42 template<
class NetworkType>
44 std::stringstream objStringStream(msg);
46 #ifdef WITH_MESSAGECOMPRESSION
47 boost::iostreams::filtering_streambuf<boost::iostreams::input> out;
48 out.push(boost::iostreams::zlib_decompressor());
49 out.push(objStringStream);
50 std::stringstream tmp;
51 boost::iostreams::copy(out, tmp);
53 boost::archive::text_iarchive objOArchive(tmp, boost::archive::no_header | boost::archive::no_codecvt | boost::archive::no_xml_tag_checking | boost::archive::archive_flags::no_tracking);
55 boost::archive::text_iarchive objOArchive(objStringStream, boost::archive::no_header | boost::archive::no_codecvt | boost::archive::no_xml_tag_checking | boost::archive::archive_flags::no_tracking);
64 template<
class MessageType>
66 std::stringstream objStringStream;
67 boost::archive::text_oarchive objOArchive(objStringStream, boost::archive::no_header | boost::archive::no_codecvt | boost::archive::no_xml_tag_checking | boost::archive::archive_flags::no_tracking);
70 #ifdef WITH_MESSAGECOMPRESSION
71 boost::iostreams::filtering_streambuf<boost::iostreams::input> out;
72 out.push(boost::iostreams::zlib_compressor());
73 out.push(objStringStream);
74 std::stringstream tmp;
75 boost::iostreams::copy(out, tmp);
79 return objStringStream.str();
std::string serializeNetworkMsg(typename MessageType::Ptr msg)
boost::shared_ptr< NetworkMessage > Ptr
NetworkMessage< NetworkType >::Ptr deserializeNetworkMsg(const std::string &msg)