c++flatbuffers

With FlatBuffer full reflection get the underlying vector type?


Using the FlatBuffer full reflection

Relevant code

const reflection::Schema& schema = *reflection::GetSchema( binary_fbs_file.c_str() );
auto root_table = schema.root_table();

auto fields = root_table->fields();

for (size_t = 0; i < fields->size(); i++)
{
    auto field = fields->Get( i );
    // 14 is the enum number for vector.
    if ( field->type()->base_type() == 14 )
    {
     // How do I check the type of the vector here?
    }
}

Relevant question in the code but how do I check what's the type of the vector? Is it an int32, double, string?


Solution

  • field->type()->element() Is the type of the vector contents.

    See reflection.fbs for details on element.