boost-serialization

boost serialization and doubles

℡╲_俬逩灬. 提交于 2019-12-05 03:22:44
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<class Archive> void serialize(Archive & ar, const unsigned int version) { if (version > 0) { ar &

Error serializing an abstract class with boost

别说谁变了你拦得住时间么 提交于 2019-12-04 12:31:28
问题 I'm trying to serialize my data structures in order to write them to a tcp socket. So far I found that my problem is the serialization. I even tried to use BOOST_SERIALIZATION_ASSUME_ABSTRACT(T) but I can't find any working example similar to my program and how to implement it correctly. Here are some of the links that I have visited: http://programmers-blog.com/category/c-c http://www.boost.org/doc/libs/1_48_0/libs/serialization/doc/tutorial.html#simplecase http://en.highscore.de/cpp/boost

boost serialization of stl collection of std unique_ptrs

自闭症网瘾萝莉.ら 提交于 2019-12-04 11:03:49
I'd like to be able to serialize stl container of std::unique_ptrs. Can it be done? btw, everything works fine with single std::unique_ptr. Below is the code I'm working on, and the gcc gives the folowing error: use of deleted function ‘std::unique_ptr<_Tp, _Dp>::unique_ptr(const std::unique_ptr<_Tp, _Dp>&) [with _Tp = MyDegrees; _Dp = std::default_delete<MyDegrees>; std::unique_ptr<_Tp, _Dp> = std::unique_ptr<MyDegrees>]’ How can I make the code to work? #include <iostream> #include <memory> #include <fstream> #include <map> #include <vector> #include <boost/serialization/map.hpp> #include

Where to put BOOST_CLASS_EXPORT for boost::serialization?

限于喜欢 提交于 2019-12-04 09:15:30
问题 I'm trying to serialize a pointer to a polymorphic class Shape . So I need to use the BOOST_CLASS_EXPORT macro to define a GUID for each subclass. The problem: where to put it? Let me show a minimal test case first: shapes.hpp #include <boost/serialization/access.hpp> #include <boost/serialization/base_object.hpp> #include <boost/serialization/export.hpp> class Shape { friend class boost::serialization::access; template<typename Archive> void serialize(Archive &ar, unsigned int const version)

Boost serialization polymorphic register(export) not working across files

丶灬走出姿态 提交于 2019-12-04 08:46:08
问题 I am using boost::serialization in my project. The project is large, and serializes my objects in several places. According to the documentation here, I should export my class with two separated step. BOOST_EXPORT_KEY() in .h file, witch contains the declaration. BOOST_EXPOET_IMPLEMENT() in .cpp file, witch contains the instantiation(definition) of the exporting. hier.h the class hierarchy, there are 3 classes in the hierarchy. /* B <---+--- D1 | +--- D2 */ #include <boost/serialization/base

boost serialization vs google protocol buffers? [closed]

£可爱£侵袭症+ 提交于 2019-12-04 07:25:48
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed last year . Does anyone with experience with these libraries have any comment on which one they preferred? Were there any performance differences or difficulties in using? 回答1: I've played around a little with both systems, nothing serious, just some simple hackish stuff, but I felt that

Deserializing constructor hierarchy

依然范特西╮ 提交于 2019-12-04 05:31:58
问题 (This question is very similar to this one, but this time I am calling the Parent deserializing constructor in the Child initialization list). In a case where a Child adds no new data to be serialized, the Parent does not have a default constructor, I want to be able to serialize the Parent object directly as well as the Child , and neither the child nor the parent have default constructors, it seems like we should use the following pattern, where the child deserializing constructor

Set tracking traits of template class in boost serialization to reduce memory consumption

好久不见. 提交于 2019-12-03 21:12:41
As this link stated for defining traits for a template class we should define it manually or we extract our class from the trait class. But I want to make this process automatically, for this reason inspired from BOOST_CLASS_TRACKING I wrote the blow code: #include<boost/preprocessor/tuple/enum.hpp> ... #define FOO_CLASS_TRACKING(E, PARAMETER_TUPLE, ...) \ namespace boost { \ namespace serialization { \ template<BOOST_PP_TUPLE_ENUM(PARAMETER_TUPLE)> \ struct tracking_level< __VA_ARGS__ > \ { \ typedef mpl::integral_c_tag tag; \ typedef mpl::int_< E> type; \ BOOST_STATIC_CONSTANT( \ int, \

calling a template function of a derived class

穿精又带淫゛_ 提交于 2019-12-03 14:48:48
问题 I'm having a problem in C++ with calling a function of a derived class while having a pointer to the base class. EDIT: Some answers referred me to CRTP but my point is that I need to have a pointer to the "Base*" class not "Base*" because I'm unaware of the type currently being handled (The current instance is created from some sort of a factory). Classes: class Base { .. template<typename T> func (T arg) { ... }; }; class Derived1 : public Base { ... template<typename T> func (T arg) { ... }

Put the serialization of a class into a DLL

不羁的心 提交于 2019-12-03 13:55:02
I'm looking for a (working) example for externally serializing a class-structure in a DLL. Currently I'm not able to find any examples for that. The Boost documentation is just stating some macros, the forums and newsgroups are just discussing specific problems with their solutions. So I'm asking for an example for (externally) serializing a class-structure like the following. Along with the class-code I added some code of mine for serializing (which does not work, see bottom for error-message). class Foo { public: Foo() { number_ = 0; } virtual ~Foo() {} int getNumber() { return number_; }