MCPcopy Create free account
hub / github.com/chronoxor/FastBinaryEncoding / main

Function main

examples/serialization_final.cpp:13–40  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11#include <iostream>
12
13int main(int argc, char** argv)
14{
15 // Create a new account with some orders
16 proto::Account account = { 1, "Test", proto::State::good, { "USD", 1000.0 }, std::make_optional<proto::Balance>({ "EUR", 100.0 }), {} };
17 account.orders.emplace_back(1, "EURUSD", proto::OrderSide::buy, proto::OrderType::market, 1.23456, 1000.0);
18 account.orders.emplace_back(2, "EURUSD", proto::OrderSide::sell, proto::OrderType::limit, 1.0, 100.0);
19 account.orders.emplace_back(3, "EURUSD", proto::OrderSide::buy, proto::OrderType::stop, 1.5, 10.0);
20
21 // Serialize the account to the FBE stream
22 FBE::proto::AccountFinalModel writer;
23 writer.serialize(account);
24 assert(writer.verify());
25
26 // Show the serialized FBE size
27 std::cout << "FBE final size: " << writer.buffer().size() << std::endl;
28
29 // Deserialize the account from the FBE stream
30 FBE::proto::AccountFinalModel reader;
31 reader.attach(writer.buffer());
32 assert(reader.verify());
33 reader.deserialize(account);
34
35 // Show account content
36 std::cout << std::endl;
37 std::cout << account;
38
39 return 0;
40}

Callers

nothing calls this directly

Calls 7

emplace_backMethod · 0.80
serializeMethod · 0.45
verifyMethod · 0.45
sizeMethod · 0.45
bufferMethod · 0.45
attachMethod · 0.45
deserializeMethod · 0.45

Tested by

no test coverage detected