Answer the question
In order to leave comments, you need to log in
How to serialize data to binary format?
There is an object. The object contains all sorts of data, from boolean variables to strings. How to serialize this whole economy into an object without an extra overhead? And to change the byte order to big endian.
Here I have a structure:
struct Point {
int x;
int y;
int z;
std::string name;
};
// заполним ее
Point point;
point.x = 5;
point.y = 10;
point.z = 7;
point.name = "test";
std::vector<byte> buff = serializer::to_binary(point);
// мы сериализовали данные в бинарный формат
0x00 0x00 0x00 0x05 0x00 0x00 0x00 0x0A 0x00 0x00 0x00 0x07 0x74 0x65 0x73 0x74 0x00
Answer the question
In order to leave comments, you need to log in
Do not offer any Boost.Serialization.
I somehow had a chance to try this: https://github.com/USCiLab/cereal
It started up easily, stl containers work out of the box, it's easy to extend serialization to your structures and classes.
I remember exactly that it was possible to write in cross-platform-binary and json formats.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question