7 #include "helloworld_generated.h"
9 int main(
int argc,
char** argv) {
10 flatbuffers::FlatBufferBuilder fbb;
11 helloworld::MessageT mutable_msg;
13 mutable_msg.head = std::unique_ptr<helloworld::MessageHead>(
new helloworld::MessageHead());
14 mutable_msg.head->mutate_sequence(123);
15 mutable_msg.head->mutate_timestamp(123000000);
17 helloworld::HelloReplyT* reply =
new helloworld::HelloReplyT();
18 reply->message =
"hello";
19 mutable_msg.body.type = helloworld::MessageBody_hello_response;
20 mutable_msg.body.value =
reinterpret_cast<void*
>(reply);
22 auto msg = helloworld::CreateMessage(fbb, &mutable_msg);
25 const helloworld::Message* msg2 = helloworld::GetMessage(fbb.GetBufferPointer());
26 std::cout <<
"head.sequence: " << msg2->head()->sequence() << std::endl;
27 std::cout <<
"head.timestamp: " << msg2->head()->timestamp() << std::endl;
28 std::cout <<
"body.hello_response.message: ";
29 std::cout.write(msg2->body_as_hello_response()->message()->c_str(),
30 msg2->body_as_hello_response()->message()->size());
31 std::cout << std::endl;
int main(int argc, char **argv)