Questions tagged [boost-serialization]

Boost.Serialization is a cross-platform C++ serialization library.

Boost.Serialization is a cross-platform C++ serialization library. Here, we use the term "serialization" to mean the reversible deconstruction of an arbitrary set of C++ data structures to a sequence of bytes. Such a system can be used to reconstitute an equivalent structure in another program context. Depending on the context, this might be used to implement object persistence, remote parameter passing or other facility. In this system we use the term "archive" to refer to a specific rendering of this stream of bytes. This could be a file of binary data, text data, XML, or some other created by the user of this library.

Boost.Serialization goals:

  1. Code portability - depend only on ANSI C++ facilities.
  2. Code economy - exploit features of C++ such as RTTI, templates, and multiple inheritance, etc. where appropriate to make code shorter and simpler to use.
  3. Independent versioning for each class definition. That is, when a class definition changed, older files can still be imported to the new version of the class.
  4. Deep pointer save and restore. That is, save and restore of pointers saves and restores the data pointed to.
  5. Proper restoration of pointers to shared data.
  6. Serialization of STL containers and other commonly used templates.
  7. Data Portability - Streams of bytes created on one platform should be readable on any other.
  8. Orthogonal specification of class serialization and archive format. That is, any file format should be able to store serialization of any arbitrary set of C++ data structures without having to alter the serialization of any class.
  9. Non-intrusive. Permit serialization to be applied to unaltered classes. That is, don't require that classes to be serialized be derived from a specific base class or implement specified member functions. This is necessary to easily permit serialization to be applied to classes from class libraries that we cannot or don't want to have to alter.
  10. The archive interface must be simple enough to easily permit creation of a new type of archive.
  11. The archive interface must be rich enough to permit the creation of an archive that presents serialized data as XML in a useful manner.
448 questions
0
votes
1 answer

boost serialization - polymorphic archives - archive-type-dependent behavior

I'm using boost serialization (v 1.55 and I'm trying to implement serialization behavior for foo that is dependent on archive type (xml or binary). At the same time, I need to use the polymorphic archive types. Here is a trivial example: #include…
chuck1
  • 665
  • 7
  • 22
0
votes
2 answers

boost.serialization and lazy initialization

i need to serialize directory tree. i have no trouble with this type: std::map< std::string, // string(path name) std::vector // string array(file names in the path) > tree; but for the serialization the directory tree with the…
niXman
  • 1,698
  • 3
  • 16
  • 40
0
votes
2 answers

How to serialize/deserialize with boost std::vector of boost::unordered_map

How to serialize/deserialize with boost std::vector of boost::unordered_map like vector *> town; which represents town. All pointers are row on heap created with new. Is possible to deserialize on easy way…
PaolaJ.
  • 10,872
  • 22
  • 73
  • 111
0
votes
1 answer

how do i serialize list variable of type >

I'm really not sure how do i serialize a list variable of type boost::shared_ptr inside a class or struct. Generally, i would go with same method that we generally use like struct A { std::list>…
user1291401
  • 264
  • 1
  • 6
  • 18
0
votes
2 answers

serialization of std::map which has member of boost::shared_ptr type fails

I'm trying to compare two maps after serialization and deserialization of struct type. It gives me error -- "error in "MyExample": check e1_i1->second == e2_i1->second failed". I'm not able to figure out what could be wrong in below code : #include…
sia
  • 1,872
  • 1
  • 23
  • 54
0
votes
1 answer

boost unit test fails with error - std::bad_typeid: Access violation - no RTTI data

I am trying to serialize set of classes (where every class which has virtual destructor) using boost serialization. Test for all classes are passing except 1 which give above error. I even tried setting enabling RTTI in VS 2012 but no use.. still…
sia
  • 1,872
  • 1
  • 23
  • 54
0
votes
1 answer

boost serialization - with load and save method for single data type in different namespace

Below is example code wherein i'm trying to do serialization using boost. For struct my_type serialize method is implementated but how do i serialize my_time and data_type as bcoz they are in different namespace // MyData.hpp namespace X { namespace…
sia
  • 1,872
  • 1
  • 23
  • 54
0
votes
1 answer

How to flush file buffers when using boost::serialization?

I'm saving a file on an USB drive and need to make sure that it's completely written to avoid corruption in case the USB drive is not removed properly. Well I've done some research and it seems this is possible via calling the FlushFileBuffers Win32…
Alex Jenter
  • 4,324
  • 4
  • 36
  • 61
0
votes
2 answers

how could set boost::iarchive's stream to empty stream

Why boost::iarchive constructor need correct strings buffer? i'm trying to init by empty stream, and later fill buffer and deserialization Data. but constructor error occured. could think define archive when have correct buffer, but i need to…
0
votes
0 answers

I'm getting a error when I declare a class as a member of other class. error : a class-key must be used when declaring a friend

I was experimenting with boost serialization and I wanted to see if it works when a class is declared as a member of another class. But when I compile my code I get loads of errors. I tried declaring baseds as a struct but no chnage. My code…
kchetan
  • 4,987
  • 2
  • 18
  • 17
0
votes
1 answer

How to resolve "sizeof" error while using boost:serialization in c++?

I'm using boost::serialization, following is my class and I tried to serialize this class object in the main function. #include #include #include #include #include #include…
BSalunke
  • 11,499
  • 8
  • 34
  • 68
0
votes
3 answers

How to get value from reference in c++

I have a func which returns a const& to an Object. Let say, class Y { private: Id id; public: Id const& GetId() const; } Now this Y Object is part of another class, let say class X, which needs to be serialized by…
Deepti Jain
  • 1,901
  • 4
  • 21
  • 29
0
votes
1 answer

Boost mpl::list variant serialization check_const_loading() compile error

The following uses mpl::list to initialize a boost variant. Then it serialize the variant. It compiles and work fine on save but not load. The compile even failed for load. Does anyone know what the issue is? thanks Attribute.h #include…
surfcode
  • 445
  • 1
  • 5
  • 20
0
votes
0 answers

What are the Chances of getting a map/set iterator not dereferencable with boost serialization

I keep on getting a map/set iterator not dereferencable assertion in my program. I am totally confused as I am having difficulty understanding why this is occuring. While glimpsing over the stack trace which is given below. …
MistyD
  • 16,373
  • 40
  • 138
  • 240
0
votes
1 answer

Changing serialization of STL containers when using Boost.Serialization

I want to extend the Boost Serialization library in such a way that STL collections are saved to XML archives in a different format than the one provided by the Boost Serialization library. If I am correct all STL containers pass the following…
user2436830
  • 439
  • 3
  • 5