1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
#include "bar_generated.h"
#include <iostream>
using namespace QbsTest;
int main()
{
flatbuffers::FlatBufferBuilder builder;
auto name = builder.CreateString("John Doe");
auto newFoo = QbsTest::CreateFoo(builder, name, 42);
auto newBar = QbsTest::CreateBar(builder, newFoo);
builder.Finish(newBar);
auto bar = GetBar(builder.GetBufferPointer());
assert(bar->foo()->name()->str() == "John Doe");
assert(bar->foo()->count() == 42);
std::cout << "The FlatBuffer was successfully created and accessed!" << std::endl;
return 0;
}
|