← Back to Docs

💿 Binary Formats

Custom binary serialization with GBIN

GBIN Format

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");

Reading Data

format::GbinFormat fmt;
fmt.read("data.gbin");

// Access data
auto data = fmt.get_data();
fmt.set_entry_point(0x1000);

Custom Formats

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;
};

Format Registry

auto& registry = format::FormatRegistry::instance();
registry.register_format("myformat", std::make_shared());