4 ms·
Under 500 lines, this probably barely qualifies as a library, but it still allows packing structs and containers to/from binary blobs with as little effort as p
by apankrat 7y ago
Under 500 lines, this probably barely qualifies as a library, but it still allows packing structs and containers to/from binary blobs with as little effort as possible.
It has virtually no dependencies, requires no pre-processing (like ProtoBufs do) and it should be easy to understand and extend. It knows how to handle basic types and std containers and then uses a couple of C++ features to coerce the compiler into auto-generating all needed methods for custom types.
All you need to do is to specify which struct/class members must be serialized and then call store() on an instance to produce a blob. To restore an instance - feed the blob into parse() and that's it.
This was originally written to implement an IPC protocol for a pair of cooperating processes, but it can be readily reused for quickly storing data on disk and other things.
- cygaril 7y agoBeing only five hundred lines doesn't disqualify it from being a library. But being impossible to safely integrate into other projects because of illegal names and polluting the global namespace does. This is at best a rough proof of concept which could at some point be turned into a library.