Custom binary serialization with GBIN
Guardian Binary Format — simple, fast, extensible.
format::GbinFormat fmt;
// Write data
fmt.push_byte(0x42);
fmt.push_int(42);
fmt.push_float(3.14);
fmt.push_string("Hello, World!");
// Serialize
auto data = fmt.serialize();
// Save to file
fmt.write("data.gbin");
format::GbinFormat fmt;
fmt.read("data.gbin");
// Access data
auto data = fmt.get_data();
fmt.set_entry_point(0x1000);
Extend the Format class to create your own binary format:
class MyFormat : public Format {
public:
std::vector serialize() override;
bool deserialize(const std::vector& data) override;
};
auto& registry = format::FormatRegistry::instance();
registry.register_format("myformat", std::make_shared());