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
2 answers

How to use boost::serialization for std::stack?

I know we can use boost::serialization for std::vector , list ,map etc as long as I include the corresponding boost header file like: #include But how could I use boost::serialization for std::stack ? Thanks
RoundPi
  • 5,819
  • 7
  • 49
  • 75
0
votes
1 answer

How to serialize MFC collections using boost

I'm trying to use Boost serialization in my MFC based project so far I had no luck whatsoever but getting error likes that serialize is not a member of CArray or serialize is not a member of CMap . I cannot figure out how to serialize MFC collection…
BikAs
  • 23
  • 7
0
votes
2 answers

Compilation error with boost serialization

I created a small sample for testing the boost serialization library, but I have a compilation problem. First of all, here's the code: #include #include #include #include #include…
cpl
  • 669
  • 6
  • 23
0
votes
1 answer

How to link boost library as dynamic library instead of static in vcpkg

I'm using VS 2019 with vcpkg and boost 1.81 I've created a Dynamic Link Library Project (c++) and I've added the boost serialization library headers. when I set vcpkg to use static libraries it builds fine , however if i set the "Use static…
daniel
  • 21
  • 5
0
votes
1 answer

boost::serialization of boost::optional of type with private default constructor

I'm upgrading from boost 1.54 to the latest 1.80 and have a compilation problem with boost serialization. I have a class A with private default constructor. Another class B has a boost::optional field and also is boost::serializable. To allow…
Alex Che
  • 6,659
  • 4
  • 44
  • 53
0
votes
1 answer

Boost ASIO deserialization wrong values

when I try to deserialize a struct on the server, I am receiving incorrect values from initial transmission. I created a struct with member variables of the same type (2 and 1); however, when transmitting receive zeros and unsure why. Does the…
0
votes
0 answers

boost::Serialization on local objects only calling save once

I have a class which has another data member which I can’t serialize as it is. But I need to get some on the fly object which can be serialized. For example: class Object { MObject getMObject{ return data->getMObj();} Data* data; }; class Node…
0
votes
1 answer

serialize a primitive_type class using polymorphic_text_archive in boost

I am trying to test the following sample code which explains how to serialize a user defined primitive type class in boost,it works fine.But if I switch to polymorphic_archive (testing with polymorphic_text_*) which I will have to use in my project,…
P.G.
  • 1
  • 1
0
votes
1 answer

How to get the file name a boost::archive is saving/loading to

I was wondering how I could get the file name string from an archive, inside the serialize function or any other function that has the template syntax. Thanks! =)
Griffin
  • 2,399
  • 7
  • 48
  • 83
0
votes
0 answers

faild to link boost::serialization with Clion and CMAKE

Im trying to link my code with the boost::serialization library but I'm getting undefined reference errors: CMakeFiles/shared_memory.dir/main.cpp.o: In function `void boost::archive::save_access::save_primitive
yaodav
  • 1,126
  • 12
  • 34
0
votes
2 answers

boost::serialization to serialize only the keys of a map

I have a class with a map, and I want to serialize the class using boost serialize. std::map stuff; ComplicatedThing is derivable just by knowing the int. I want to serialize this efficiently. One way (ick, but works) is to…
jma
  • 3,580
  • 6
  • 40
  • 60
0
votes
1 answer

Input stream problem when using std::array

When there is no bool b in struct A, the code works. When bool b is there, ar & mat gives "input stream error" but registering elements of std::array one by one works. What's wrong here? #include #include…
Shibli
  • 5,879
  • 13
  • 62
  • 126
0
votes
1 answer

Check an archive whether it is a binary/text/xml

I created an output text_archive and I restored it using binary archive and obviously, got some issues. Can I know somehow the kind of archive, so that I could possibly use the appropriate code for binary/xml/text archive. class Info { private: //…
0
votes
1 answer

Boost serialization text archive are Cross-language?

Hy...I try to explain better my question... Im using boost serialization text archive before sending data over TCP connection... Now I need to pass the received data to a Java application...so I would know if the serialized stream is composed only…
marco
  • 295
  • 3
  • 13
0
votes
0 answers

runtime issue with boost serialization using different compilers/environments

I have a piece of code that serializes a struct on file. int main(int argn, char* argv[]){ if (argn > 2){ std::cout << "Error! this program requires a single argument.\n"; return 1; } std::string…
Eamon
  • 23
  • 6