/*!\file serialization_final.cpp\brief Fast Binary Encoding serialization (final protocol) example\author Ivan Shynkarenka\date 09.07.2018\copyright MIT License*/#include "../proto/proto_final_models.h"#include <iostream>int main(int argc, char** argv){// Create a new account with some ordersproto::Account account = { 1, "Test", proto::State::good, { "USD", 1000.0 }, std::make_optional<proto::Balance>({ "EUR", 100.0 }), {} };account.orders.emplace_back(1, "EURUSD", proto::OrderSide::buy, proto::OrderType::market, 1.23456, 1000.0);account.orders.emplace_back(2, "EURUSD", proto::OrderSide::sell, proto::OrderType::limit, 1.0, 100.0);account.orders.emplace_back(3, "EURUSD", proto::OrderSide::buy, proto::OrderType::stop, 1.5, 10.0);// Serialize the account to the FBE streamFBE::proto::AccountFinalModel writer;writer.serialize(account);assert(writer.verify());// Show the serialized FBE sizestd::cout << "FBE final size: " << writer.buffer().size() << std::endl;// Deserialize the account from the FBE streamFBE::proto::AccountFinalModel reader;reader.attach(writer.buffer());assert(reader.verify());reader.deserialize(account);// Show account contentstd::cout << std::endl;std::cout << account;return 0;}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。