sbepp is a zero-overhead C++ implementation of Simple Binary Encoding (SBE). It consists of two parts:
sbeppc
, schema compiler which generates header-only C++ codesbepp
, header-only supporting libraryThis project was created in Ukraine during the invasion of Russian terrorist forces. Please consider donating to the UNITED24 platform to help us withstand.
sbepp
itselfconstexpr
encoding/decoding in C++20get_FieldName()
-like functionsDecoding example:
#include <schema_name/messages/msg1.hpp>
auto m = sbepp::make_view<schema_name::messages:msg1>(dataPtr, dataSize);
// read top-level fields
std::cout << *m.required();
if(m.optional())
{
std::cout << *m.field2();
}
if(m.bitset().A())
{
std::cout << "bitset.A";
}
// read composite field
std::cout << *m.composite().field();
// read group
for(auto entry : m.group())
{
std::cout << sbepp::to_underlying(entry.enum_field());
}
// read data
auto d = m.data();
std::cout.write(d.data(), d.size());
Encoding example:
#include <schema_name/messages/msg1.hpp>
std::array<char, 1024> buf{};
auto m = sbepp::make_view<schema_name::messages:msg1>(buf.data(), buf.size());
sbepp::fill_message_header(m);
// fill top-level fields
m.required(1);
m.optional(2);
m.bitset(schema_name::types::set{}.A(true));
// fill composite field
m.composite().field(1);
// fill group
auto g = m.group();
const auto group_size = 3;
sbepp::fill_group_header(g, group_size);
for(auto entry : g)
{
g.enum_field(schema_name::types::my_enum::A);
}
// fill data
auto d = m.data();
d.assign_string("hi");
const auto msg_size = sbepp::size_bytes(m); // get final message size
send(buf.data(), mgs_size);
See full documentation here.
Feel free to create an issue, send me an email, or contact me on Cpplang slack channel if you have questions or ideas related to this project.
Distributed under the MIT license.