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

Linker error in boost serialization of custom archive

I've tried to implement an own archive type for boost serialization following official boost example to write archives. #include #include #include #include "boost/serialization/vector.hpp" #include…
0
votes
1 answer

How to serialize a 3D array with boost?

Okay, I recently switched to boost and I partitialy understand serializing simple objects or simple classes (the boost tutorial confuses me), but how can I serialize a 3D array which contains class members? I have an array (std::vector) called…
0
votes
0 answers

Boost serialization - the meaning of the content in a .txt file

I would like to save objects from a parent class in a text file and then be able to load the objects. The problem is that all the objects are pointers so only the addresses of the objects could be saved but not the objects themselves. The code below…
mikamul
  • 73
  • 1
  • 7
0
votes
0 answers

What's the easiest way to serialize graphs in C++?

I have 2D 1000:1000 grid of graph nodes which have references to their neighbors. I tried to serialize it with Boost.Serialize, but it fails with Segmentation fault (it works fine when I do it for 100:100 grid only). Also tried libnop but it doesn't…
Slaus
  • 2,086
  • 4
  • 26
  • 41
0
votes
2 answers

Boost 1.65.1 serialization to vector fails with 'Assertion initialized_ failed'

I have the following test case that serializes an int into std:vector. It crashes with the following assertion: serialization_test: /usr/include/boost/iostreams/detail/optional.hpp:55: T& boost::iostreams::detail::optional::operator*() [with T =…
Arne Böckmann
  • 467
  • 2
  • 16
0
votes
1 answer

Serializing a class with member that is vector> with boost::serialization

There is a similarly sounding question, but it is totally different because it relates to a vector of unique_ptr of the class that is serialized. I would like to have a way to serialize member that is a vector. What I have tried and does not…
NoSenseEtAl
  • 28,205
  • 28
  • 128
  • 277
0
votes
1 answer

Why is passing 'this' pointer directly to archive an error, but another pointer of same type is ok?

Passing a this pointer assigned to another one works fine, but passing just it itself directly doesn't as below: table_row* table_row::deserialize_row(std::string src_serialized_row) { std::stringstream ss(src_serialized_row); …
Alan Kałuża
  • 515
  • 5
  • 19
0
votes
0 answers

Serialize STL unordered_map with armadillo matrix as values

I am trying to serialize an instance of typle std::vector> To so, I used the same approach of mlpack (also explained here How to serialize armadillo's vector) and copied the files mat_extra_bones.hpp and…
mariob6
  • 469
  • 1
  • 6
  • 16
0
votes
1 answer

Boost serialization: SIGABRT while deserializing boost::shared_ptr on object containing std::shared_ptr

I am trying to perform serialization and deserialization of boost::shared_ptr on the object containing std::shared_ptr. To do that, I use boost::archive::binary_oarchive and boost::archive::binary_iarchive. Everything is going just fine, but when…
0
votes
0 answers

How to serialize/deserialize a matrix expressed like a pointer to pointer with BOOST C++

I am working with boost and an a two dimensional array of floats expressed like a double pointer (float**). By the moment I am allocating memory two load the value (when deserializing), I don't know and I did not find any information on how to do…
Marc43
  • 491
  • 2
  • 6
  • 15
0
votes
1 answer

customizing the number of digits in exponent in boost multiprecision

We've just migrated to Visual Studio 2017 and due to the change described here the serialized output of a double value using std::scientific does not carry anymore 2 digits in the exponent but only one. BEOFRE: 5.49000000000000000e+002 NOW :…
Abruzzo Forte e Gentile
  • 14,423
  • 28
  • 99
  • 173
0
votes
1 answer

C++ boost serialization of subclass by base class pointer

I perform serialization / deserialization of a subclass object by a pointer to its base class. Everything works Ok, yet I miss one feature: adding a runtime parameter to the constructor of the object being deserialized, example: class Base { …
0
votes
2 answers

Which stream is suitable for serialization over UDP?

I am trying to serialize and recover objects over UDP using the Boost.Serialization and Boost.Asio libraries. The following points sum up what I know so far: The main concept of Boost.Serialization is the archive. An archive is a sequence of bytes…
codeaviator
  • 2,545
  • 17
  • 42
0
votes
1 answer

Serialization of non default constructible and std::reference wrapper alternatives

I tried serialising my (neural) network and am currently stuck-ish. The issue seems to be that you can't serialize a std::reference_wrapper. I am unsure whether I should either change the way the references to the upper nodes are stored or come up…
Gladaed
  • 211
  • 1
  • 8
0
votes
1 answer

Is there a way to serialize iterators using boost serialization?

In my project I have a class containing and std::list and in another class I maintain an iterator pointing to a place in the middle of that list. I can successfully serialize the list, but the iterator member variable is causing problems. Here is a…
Steve
  • 409
  • 1
  • 3
  • 10