|
Boost Users : |
Subject: Re: [Boost-users] Extend boost binary serialization with varints encoding
From: Bjorn Reese (breese_at_[hidden])
Date: 2015-11-24 04:49:22
On 11/23/2015 08:21 PM, Ernest Zaslavsky wrote:
> Ok, I came up with quite ugly solution (see on coliru http://coliru.stacked-crooked.com/a/ba39b5a242e5c69b). but it works, however it is ugly in the way that it is up to user to apply encode/decode on members. Moreover it is the only way to encode value. I was aiming to something broader, for example, in array or vector the size is stored in archive, it is size_t and it occupies 64 bit, in case of small data chunks it is complete waste of storage. Is there a way to force all primitive types of choice to use my serialization instead of standard one? I mean is there a way to encode this aforementioned size_t in array serialization without rewriting its implementation?
I was assuming that by "varint" you wanted an integral type of
arbitrary length, yet your example only uses the built-in integral
types. If you only require the latter, and you do not care particularly
about which binary format is used, then I suggest that you try the
transenc serialization archives from:
https://github.com/breese/trial.protocol
This will select the shortest integral encoding based on the value.
Documentation can be found below, although the transenc part has
not been documented yet:
http://breese.github.io/trial/protocol/index.html
You can find plenty of examples in the test suites:
https://github.com/breese/trial.protocol/blob/develop/test/transenc/oarchive_suite.cpp
https://github.com/breese/trial.protocol/blob/develop/test/transenc/iarchive_suite.cpp
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net