https://github.com/avakar/seri
A header-only, endian-aware integer serialization library for C++17
https://github.com/avakar/seri
cpp cpp17 serialization
Last synced: about 2 months ago
JSON representation
A header-only, endian-aware integer serialization library for C++17
- Host: GitHub
- URL: https://github.com/avakar/seri
- Owner: avakar
- License: bsl-1.0
- Created: 2019-04-13T03:58:32.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2021-10-04T19:14:07.000Z (over 3 years ago)
- Last Synced: 2025-04-12T19:57:44.804Z (about 2 months ago)
- Topics: cpp, cpp17, serialization
- Language: C++
- Homepage:
- Size: 15.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# seri
A header-only, endian-aware integer serialization library for C++17.
## Introduction
`seri` defines several standard-layout integer-like types with a specified
representation and an alignment of 1. The types have names in the form
`(u|i)(16|32|64)_(le|be)_t`. Signedness is indicated by `u` or `i` prefix
for signed and unsigned, respectively. The suffixes `le` and `be` stand
for little-endian and big-endian.For example, `u32_le_t` represents an unsigned 32-bit integer with
little-endian representation.Each type is implicitly convertible to and from a corresponding type
from ``, e.g. `u32_le_t` is convertible to and from `uint32_t`.
In most situations, you can use `seri` types like built-in integers.You can form structures from `seri` integers to represent on-disk structures.
struct my_file_header_t {
/* 0x00 */ u32_le_t magic;
/* 0x02 */ u16_le_t version;
/* 0x06 */ u32_le_t length;
};Notice that `my_file_header_t::length` is misaligned.
## Getting Started
Add this repo as a subrepo of your project and add the `include` directory
into your include path.If you're using CMake, you can also pull the library
via the FetchContent module.FetchContent_Declare(
avakar_seri
GIT_REPOSITORY https://github.com/avakar/seri.git
GIT_TAG master
)
FetchContent_MakeAvailable(avakar_seri)Then link against `avakar::seri` target and use namespace `avakar::seri`.