Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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

See reflection.fbs for details on element.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading