boost-serialization

Serialize Polymorph Interface

*爱你&永不变心* 提交于 2019-12-10 11:44:53
问题 I am looking to serialize a polymorphed class from its associated interface. Here is what I have found this question, which seems to do what I need to: How to create a interface for serialization in Boost Serialization? However the serialization is done from the class itself and not the interface. What I have got so far: INetworkMessage.hpp using PolyArchive = boost::variant< boost::archive::polymorphic_oarchive &, boost::archive::polymorphic_iarchive&>; class INetworkMessage { public:

Serializing binary data in boost fails with `invalid signature' error

时光总嘲笑我的痴心妄想 提交于 2019-12-10 11:42:52
问题 I'm having difficulties figuring out correct way of using boost serialization/asio to send objects over network. The message class is as simple as possible. It's not C++ friendly nor suitable for my needs, I just keep it simple temporarily to test asio/ser: class message { friend class boost::serialization::access; public: message(){} int type; int sender; int assignment; int nogood; template<class Archive> void serialize(Archive & ar, const unsigned int version) { ar & type; ar & sender; ar

boost::serialization: object with private default constructor works in a vector, but not in a map

一世执手 提交于 2019-12-10 10:08:45
问题 Consider the following code: #include <boost/serialization/nvp.hpp> #include <boost/archive/xml_iarchive.hpp> #include <boost/archive/xml_oarchive.hpp> class Foo{ friend class boost::serialization::access; template<class Archive> void serialize(Archive & ar, const unsigned int) { ar & BOOST_SERIALIZATION_NVP(i); } int i; Foo():i(0){} public: Foo(int k):i(k){} }; int main(int argc, char *argv[]) { std::vector< Foo> f; f.push_back(Foo(12)); std::ofstream os("path"); boost::archive::xml_oarchive

boost serialization and doubles

落花浮王杯 提交于 2019-12-10 03:09:00
问题 I am trying to serialize a class to a string using the boost serialization library and included in my class are several double member variables. Below is the code I'm using to serialize: #include <boost/archive/text_oarchive.hpp> #include <boost/archive/text_iarchive.hpp> #include <boost/serialization/string.hpp> std::stringstream ss; boost::archive::text_oarchive oa(ss); oa << mPoint; Here is the serialiation method within my Point class: friend class boost::serialization::access; template

Serialize Polymorph Interface

北城以北 提交于 2019-12-08 18:58:27
I am looking to serialize a polymorphed class from its associated interface. Here is what I have found this question, which seems to do what I need to: How to create a interface for serialization in Boost Serialization? However the serialization is done from the class itself and not the interface. What I have got so far: INetworkMessage.hpp using PolyArchive = boost::variant< boost::archive::polymorphic_oarchive &, boost::archive::polymorphic_iarchive&>; class INetworkMessage { public: INetworkMessage() = default; virtual ~INetworkMessage() = default; virtual void serialize(PolyArchive ar,

Does boost support serialization of c++11's std::tuple?

∥☆過路亽.° 提交于 2019-12-08 14:53:54
问题 Does boost support serialization of c++11's std::tuple? I couldn't find a tuple.hpp header file at /boost/serialization/ I'm using boost 1.52.0 (happy to upgrade if need be, but it seems like the changes in version 1.53 doesn't have anything related to this). 回答1: Out of the box, no. You'll have to write the serializer yourself. Luckily, someone already did: C++0x tuple boost serialization (also in github) 回答2: and here is another implementation: https://github.com/galaxyeye/atlas/blob/master

How do I serialize a class containing pointers to primitives?

 ̄綄美尐妖づ 提交于 2019-12-08 06:56:13
问题 I am trying to use boost's functionality for serializing pointers to primitives (so that I don't have to de-reference and do a deep store myself). However, I get a pile of errors when I try to do it. Here is a simple example of a class that is supposed to contain save and load methods which write and read the class content from a file. This program does not compile: #include <boost/archive/text_iarchive.hpp> #include <boost/archive/text_oarchive.hpp> #include <boost/serialization/shared_ptr

Boost serialization of reference member abstract class

∥☆過路亽.° 提交于 2019-12-08 04:54:49
问题 I'm trying to figure out how to serialize a class that I put together with Boost. I'll get right to the code: #ifndef TEST_H_ #define TEST_H_ #include <iostream> #include <boost/serialization/serialization.hpp> #include <boost/archive/binary_oarchive.hpp> #include <boost/archive/binary_iarchive.hpp> class Parent { public: int test_val = 1234234; int p() { return 13294; } int get_test_val() { std::cout << test_val << std::endl; return test_val; } friend class boost::serialization::access;

Boost Polygon Serialization

喜夏-厌秋 提交于 2019-12-07 11:28:44
问题 I am using boost geometry in my project, and I need to serialize polygons. I have been using boost serialization without problems for many boost data types, but boost geometry seems that currently does not support serialization, as I cannot find any header inside serialization folder. Is there any well known method to achieve this? Thanks. EDIT: Binary Serialization Example in: Boost Polygon Serialization: Ring 回答1: I agree, it is weird that Boost.Geometry does not support Boost.Serialization

Follow up: Boost serialized custom C++ object passed over ZeroMQ pull socket

人盡茶涼 提交于 2019-12-07 06:33:29
问题 This is a follow up problem that I opened up earlier in another thread at Boost: De-serializing a custom C++ object passed over ZeroMQ pull socket. The problem in that thread has been resolved based on the answer provided. Now I have another problem at runtime. Please, see the below description. I am realtively new to C++ realm so I appreciate if you tell me any necessity for improvement in any part of the code provided in addition to what I descibed under problem statment. Description: I