Search code examples
c++arraysactivemq-classicserializationflatbuffers

How to grab byte array after serialization?


I'm using Google's Flatbuffer. I've created a simple schema for C++ that just takes a name and ID as the fields. After creating the auto generated code and running the fields through the CreateDetails() function, how would I get the bytearray to pass into ActiveMQ? I've searched around but couldn't find much about the byte array.

My schema:

table details {
    name:string;
    id: int;
};

root_type details;

My .cpp application:

auto name = builder.CreateString("some text here");
auto id = 25;

auto detail = CreateDetails(builder, name, id);

builder.Finish(detail);

Now, from my understanding, the sample message should be serialized, but I'm not sure how to grab the serialized data as a byte array. I was able to access the root and just go down the tree and look at the data, but I want to grab the entire message as a bytearray.

Please and thank you!


Solution

  • builder.GetBufferPointer()
    builder.GetSize()