Questions tagged [cereal]

A C++11 serialization library

cereal is a header-only C++11 serialization library. cereal takes arbitrary data types and reversibly turns them into different representations, such as compact binary encodings, XML, or JSON. cereal was designed to be fast, light-weight, and easy to extend - it has no external dependencies and can be easily bundled with other code or used standalone.

135 questions
19
votes
2 answers

Do cereal and Boost Serialization use zero-copy?

I have done some performance comparison between several serialization protocols, including FlatBuffers, Cap'n Proto, Boost serialization and cereal. All the tests are written in C++. I know that FlatBuffers and Cap'n Proto use zero-copy. With…
B. Clement
  • 298
  • 2
  • 13
11
votes
1 answer

Is there a way to specify a simpler JSON (de-)serialization for std::map using Cereal / C++?

The project I'm working on is a C++ application that manages a large number of custom hardware devices. The app has a socket/port interface for the client (like a GUI). Each device type has its own well-defined JSON schema and we can serialize those…
Lee Jenkins
  • 2,299
  • 3
  • 24
  • 39
10
votes
3 answers

How to detect if a type is shared_ptr at compile time

I want to get a templatized way of finding if a type is a shared_ptr and based on that I want to have a new specialization of a function. Example main function is, template inline void CEREAL_LOAD_FUNCTION_NAME( RelaxedJSONInputArchive &…
Mr.100
  • 141
  • 3
  • 11
7
votes
3 answers

How to serialize a json object without enclosing it in a sub-object using Cereal

Let's say I have a class in C++, like the following: struct Point { int x, y, z; }; I want to use Cereal to serialize that struct to JSON. So I added a serialize function like this: struct Point { int x, y, z; template
Benjamin Lindley
  • 101,917
  • 9
  • 204
  • 274
7
votes
2 answers

Serializing Eigen::Matrix using Cereal library

UPDATED: I managed to get it to work after I googled around and read the doxygen comments in code. Problem was that I missed the cast before using resize() method and also not using std::ios::binary for the streams. If you want to do something…
Nakamp
  • 120
  • 1
  • 8
6
votes
1 answer

Using Cereal to serialize templated polymorphic types in a library

I have a templated base class: template class A { public: T a; template void serialize(Archive & ar) { ar(a); } }; and a templated class that derives from it: template class B :…
addicted2oxygen
  • 391
  • 4
  • 11
6
votes
2 answers

Cereal serialization error

So i'm legit confused. It won't compile for an external serialization function. It gives the error cereal could not find any output serialization functions for the provided type and archive combination. So the code below doesn't…
Chase R Lewis
  • 2,119
  • 1
  • 22
  • 47
6
votes
1 answer
6
votes
1 answer

Cereal does not support raw pointers

Edit: The question title was based on a deep missunderstanding of the compiler error I got. I was (sillyly) assuming the error was, that I tried to deserialize to an object I declared inside of the function. This was utterly wrong. I didn't do…
LukeG
  • 638
  • 10
  • 20
6
votes
1 answer

Cereal JSON output misses closing curly brace

I am using Cereal C++ v1.1.1 and similar to the example given in the documentation I am trying the following: #include #include #include int main() { std::ostringstream os; …
Yan Foto
  • 10,850
  • 6
  • 57
  • 88
5
votes
1 answer

Custom serialization of std::string_view causes unexpected compiler error

I've already asked this question on github (about a month ago), without any answer so I'm asking here now. I'm using Cereal as a serialization library in my project. I've tried to add serialization functionality for std::string_view (which is…
Timo
  • 9,269
  • 2
  • 28
  • 58
5
votes
1 answer

How to serialize a boost::ptr_vector using cereal?

Is it possible to serialize a boost::ptr_vector instance using cereal? If so, how?
Ton van den Heuvel
  • 10,157
  • 6
  • 43
  • 82
5
votes
1 answer

C++ Cereal: serialize C-style array

Can/How do you serialize an array using the cereal library. I.e. void save(Archive & ar, const unsigned int version) const { unsigned int l = g1_size_bin(g,POINT_COMPRESS); uint8_t data[l]; memset(data, 0, l); g1_write_bin(data, l,…
imichaelmiers
  • 3,449
  • 2
  • 19
  • 25
4
votes
0 answers

How to correctly using Cereal with polymorphy and pointers?

I am trying to serialize some data structures using Cereal. The class structure is shown below. I removed everything I deemed irrelevant and marked everything I added to the original file with //added (primarily some default constructors and…
Scholle
  • 1,521
  • 2
  • 23
  • 44
4
votes
1 answer

CEREAL failing to serialise - failed to read from input stream exception

I found a particular 100MB bin file (CarveObj_k5_rgbThreshold10_triangleCameraMatches.bin in minimal example), where cereal fails to load throwing exception "Failed to read 368 bytes from input stream! Read 288" The respective 900MB XML file…
WurmD
  • 1,231
  • 5
  • 21
  • 42
1
2 3
8 9