flatbuffers icon indicating copy to clipboard operation
flatbuffers copied to clipboard

Feature/add typename method

Open pablogm opened this issue 1 year ago • 2 comments

Summary

This pull request adds a new feature to the FlatBuffers compiler (flatc) to generate a TypeName() method in each C++ table and struct. This method returns the fully qualified type name (including namespace) as a string.

Changes Introduced

  • Introduced a new utility function, MakeFullyQualifiedName, to construct fully qualified names using namespaces and type names.
  • Updated the GenTable method in idl_gen_cpp.cpp to include a TypeName() method in generated C++ classes when a custom flag is enabled.
  • Added a new flag (--gen-type-names) to flatc to optionally generate the TypeName() method.

Motivation

The TypeName() method allows developers to access the fully qualified name of a table or struct at runtime, similarly to what Protobuf offers with T::descriptor()->full_name().

Usage

With the --gen-type-names flag, generated C++ code will include a TypeName() method

pablogm avatar Nov 06 '24 00:11 pablogm

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

google-cla[bot] avatar Nov 06 '24 00:11 google-cla[bot]

This pull request is stale because it has been open 6 months with no activity. Please comment or label not-stale, or this will be closed in 14 days.

github-actions[bot] avatar May 23 '25 20:05 github-actions[bot]

This pull request was automatically closed due to no activity for 6 months plus the 14 day notice period.

github-actions[bot] avatar Jun 06 '25 20:06 github-actions[bot]