Serialization for Real-Time - A high-performance, zero-allocation C++20 binary serialization library using compile-time reflection.
- Zero Allocation: Stack-only buffers with compile-time size computation
- Compile-Time Reflection: Automatic struct analysis via reflect-cpp
- Bounded Containers:
fixed_vector<T,N>,fixed_string<N>,RingBuffer<T,N>with runtime sizes - Compile-Time Strings: Full constexpr support with auto size deduction (
"text"_fs, CTAD, NTTP) - Block-Based Serialization: Optimal memory copying via
StructLayout<T>analysis - Interactive Viewer: HTML-based schema visualization tool
- Simple API:
serialize(obj)/deserialize<T>(data)- zero boilerplate
#include <sertial/sertial.hpp>
struct Position {
float x, y, z;
};
int main() {
Position pos{1.5f, 2.5f, 3.5f};
// Serialize
auto buffer = sertial::serialize(pos);
// Deserialize
auto restored = sertial::deserialize<Position>(buffer.view());
std::cout << "Position: (" << restored->x << ", "
<< restored->y << ", " << restored->z << ")\n";
}- CMake 3.20+
- C++20 compiler (GCC 10+, Clang 12+, MSVC 2019+)
- reflect-cpp
git clone https://github.com/getml/reflect-cpp.git
cd reflect-cpp && mkdir build && cd build
cmake .. && cmake --build . && sudo cmake --install .git clone https://github.com/mattih11/SeRTial.git
cd SeRTial && mkdir build && cd build
cmake .. && cmake --build .sudo cmake --install .Installs to:
/usr/local/include/sertial/- Headers/usr/local/bin/sertial-inspect- CLI tool/usr/local/share/sertial/- HTML viewer
find_package(SeRTial REQUIRED)
target_link_libraries(your_target PRIVATE SeRTial::SeRTial)- API Reference - Auto-generated from source (run
make docsafter building)- Browse:
docs/api/html/index.html - Requires: Doxygen
- Browse:
- User Guide - Getting started, API reference, common patterns
- Container Guide - Working with fixed_vector, fixed_string, RingBuffer
- Examples - Comprehensive code examples
- Schema Viewer - Interactive visualization tool
- Adding Containers - Extend with custom container types
- Container Internals - Implementation deep-dive
- Serialization Mechanism - How block-based serialization works
- Reflector Architecture - Schema generation internals
- Size Calculations - Compile-time size computation
- Template Patterns - Metaprogramming techniques
- Doxygen API Reference - Complete API documentation (auto-generated)
- Local build: Run
make docsin build directory (requires Doxygen)
- CLI Tool README - Terminal-based schema inspection
- Interactive Viewer - Live demo
SeRTial provides bounded containers for real-time safe serialization:
| Container | Purpose | Capacity | Size | Compile-Time |
|---|---|---|---|---|
fixed_vector<T, N> |
Dynamic list | Fixed | Variable | - |
fixed_string<N> |
Text | Fixed | Variable | Full constexpr |
RingBuffer<T, N> |
Circular buffer | Fixed | Variable | - |
static_buffer<N> |
Raw bytes | Fixed | Variable | - |
std::array<T, N> |
Fixed-size array | Fixed | Fixed | Full constexpr |
NEW: fixed_string now supports full compile-time construction:
constexpr fixed_string name{"SeRTial"}; // Auto-deduces fixed_string<7>
using namespace sertial::literals;
auto msg = "RealTime"_fs; // User-defined literalSee: Container Guide for complete reference
Visualize your message layouts interactively:
Generate schemas:
cd build
./schema_example my_schemas.json
# Open viewer.html with my_schemas.jsonSee: Schema Viewer Guide for details
include/sertial/ # Public API headers
├── sertial.hpp # Main entry point
├── containers/ # Bounded containers (fixed_vector, fixed_string, RingBuffer)
├── core/ # Type analysis (StructLayout, traits, concepts)
├── io/ # Serialization API (serialize/deserialize)
├── integration/ # Schema export
└── reflector/ # reflect-cpp integrations
docs/ # Documentation
├── USER_GUIDE.md
├── CONTAINER_GUIDE.md
├── EXAMPLES.md
└── ...
examples/ # Runnable examples
├── serialization_example.cpp
├── schema_example.cpp
└── ring_buffer_example.cpp
test/ # Unit tests
├── test_serialization.cpp
├── test_foundation.cpp
├── test_ring_buffer.cpp
└── ...
tools/sertial-inspect/ # Visualization tools
├── main.cpp # CLI tool
├── viewer.html # Interactive browser viewer
└── README.md
#include <sertial/sertial.hpp>
#include <sertial/containers/fixed_vector.hpp>
struct SensorData {
uint64_t timestamp;
uint32_t sensor_id;
sertial::fixed_vector<float, 100> readings;
};
SensorData data;
data.timestamp = 1234567890;
data.sensor_id = 42;
data.readings.push_back(25.5f);
data.readings.push_back(26.0f);
auto buffer = sertial::serialize(data);
// Size: 8 + 4 + 4 + 2*4 = 24 bytes (not 8 + 4 + 404!)#include <sertial/sertial.hpp>
#include <sertial/containers/fixed_string.hpp>
// CTAD - auto size deduction
constexpr sertial::fixed_string device{"Sensor_42"}; // fixed_string<9>
// User-defined literals
using namespace sertial::literals;
struct Config {
decltype(device) name;
uint32_t rate_hz;
};
Config config{
.name = "Sensor_42"_fs, // Compile-time construction
.rate_hz = 100
};
auto buffer = sertial::serialize(config);See: Examples Guide for more patterns
Version: 2.0.0 (Released February 2026)
Phase 4 Complete (Reflector-Based Introspection):
- Reflector-based schema export (zero boilerplate)
- Interactive HTML viewer (browser-based, zero dependencies)
- C++ CLI tool (replaces Python scripts)
- All Python dependencies removed
- Unified container registration via
SerializableContainerconcept - NEW: Full constexpr support for fixed_string with compile-time string literals
Phase 5 Roadmap:
- Cross-platform serialization (endianness handling)
- Nested container support
- Additional container types
- Performance profiling tools
- ROS 2 adapter (separate repository)
Contributions welcome! Please:
- Fork the repository
- Create a feature branch
- Write tests for new features
- Ensure all tests pass (
ctest) - Submit a pull request
Development guidelines: See .github/copilot-instructions.md
Copyright (C) 2026 Matthias Haase mattihaae@proton.me
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
See LICENSE for full details.
Matthias Haase
Email: mattihaase@proton.me
GitHub: https://github.com/mattih11
- reflect-cpp - Compile-time reflection
