Session increase does not work between 32bit and 64bit machine. Any other serialization / compression library?

I am trying to use the boost library to serialize on a 64 bit machine and de-serialize on a 32 bit machine. However, this doesn't seem to work. (I am using 1.57.0).

If I run the following code

boost::asio::streambuf buf;
std::ostream os(&buf);
boost::archive::binary_oarchive oa(os);
printf("Buffer size %d\n",(int)buf.size());

      

The 32-bit machine's output is 37 and the 64-bit machine's output is 41 .

Is there any other good serialization library I can use? How about cereals ?

It's great if the library can do compression too (zlib / gzip, etc.).

+3


source to share


3 answers


He works. It just doesn't create compatible archives. If you'd like to take a look at the archive implementation that EOS did:

You can dump the Boost binary_ [io] archive from it. You don't need to change anything.




PS. Of course, of course, write out your types and regardless of architecture. So uint32_t

, not `` size_t`

+3


source


Binary archives generated by boost :: serialization will not work if you change the machine architecture. Text archives are a good option in this scenario. Boost :: archive :: text_oarchive and boost :: archive :: text_iarchive can be used in exactly the same way, but are architecture and platform safe. The data is written in ascii format instead of binary format, so there are tradeoffs to be made for your purpose.



+1


source


I would recommend using "grain" for this purpose, which could provide JSON / XML serialization.

-1


source







All Articles