Data Type | Implemented? |
---|---|
Booleans | ✅ |
Signed Integers | ✅ |
Unsigned Integers | ✅ |
Floats | ✅ |
Arrays | ✅ |
Strings | ✅ |
Maps | ❌ |
Extension | ❌ |
Nil | ❌ |
Pack provides limited support for serializing (but not necessarily deserializing) standard library containers through concepts.
- Anything convertible to
std::span
can be serialized as an Array (std::vector
, etc) - Anything convertible to
std::string_view
can be serialized as a String (std::string
, null-terminatedconst char *
, etc)
As a header-only library, using Pack is as simple as including the header file in your project. CMake is necessary only for building the unit tests.
The public interface for the library is designed to be familiar for anyone who has utilized the excellent Cereal library. Usage revolves around the Packer
and Unpacker
classes that are constructed with some kind of c++ stream. Note that similarly to Cereal, the stream is not
flushed until the destructor is called:
std::stringstream stream(std::ios::binary | std::ios::out | std::ios::in);
{
pack::Packer packer(stream);
packer.Serialize(data1, data2, ...);
}
// Later...
{
pack::Unpacker unpacker(stream);
unpacker.Deserialize(data1, data2, ...);
}
This project is licensed under the MIT License. See the LICENSE file for details.