serilite is designed to be a simple and easy to use serialization library for C++17. You can easily serialize and deserialize your objects with just a few lines of code and without any boilerplate code. For example, you can serialize a simple object like this:
#include <serilite.hpp>
YourObject obj;
auto serialized_res = serilite::serialize(obj);
auto serialized_view = serialized_res.as_string_view();
auto serialized_string = serialized_res.as_string();
// ....
YourObject obj2
serilite::deserialize(serialized_res,obj2);
serilite::deserialize(serialized_view,obj2);
serilite::deserialize(serialized_string,obj2);
No need to write any serialization or deserialization code for your objects or modify them in any way.
srilite supports the most of frequently used types, including:
- Trivially copyable type
- Can be constructed by
std::memcpy
from a byte representation. This includes all scalar types, arrays or vector of trivially copyable types. - Has iterator, which means
T::iterator
andT::value_type
are defined. - Aggregate type with fileds of supported types, and fileds count less than 64.
std::tuple
andstd::pair
of supported types.
C++序列化对象 Counting the number of fields in an aggregate in C++20