mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-28 18:10:00 +00:00
C++: mini_reflect: Add DefaultTypeTable (#4614)
* mini_reflect: Add DefaultTypeTable
Currently it's very easy to make a mistake when it comes to
instantiating the TypeTable to print a buffer because it is not type
safe.
This will allow us to write safer cpp code:
flatbuffers::FlatBufferToString(reinterpret_cast<const uint8_t *>(&t),
decltype(t)::DefaultTypeTable());
* c++: mini_reflect: update generated code
* Ensure types and names are set for mini_reflect
* c++: mini_refelct: update unit tests with new typed TypeTable
* Adding PR feedback of sylte and naming convention
This commit is contained in:
committed by
Wouter van Oortmerssen
parent
daf0a420be
commit
36f8564846
@@ -13,6 +13,10 @@ struct TableInNestedNS;
|
||||
|
||||
struct StructInNestedNS;
|
||||
|
||||
inline flatbuffers::TypeTable *TableInNestedNSTypeTable();
|
||||
|
||||
inline flatbuffers::TypeTable *StructInNestedNSTypeTable();
|
||||
|
||||
enum EnumInNestedNS {
|
||||
EnumInNestedNS_A = 0,
|
||||
EnumInNestedNS_B = 1,
|
||||
@@ -74,6 +78,9 @@ MANUALLY_ALIGNED_STRUCT(4) StructInNestedNS FLATBUFFERS_FINAL_CLASS {
|
||||
STRUCT_END(StructInNestedNS, 8);
|
||||
|
||||
struct TableInNestedNS FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
static flatbuffers::TypeTable *MiniReflectTypeTable() {
|
||||
return TableInNestedNSTypeTable();
|
||||
}
|
||||
enum {
|
||||
VT_FOO = 4
|
||||
};
|
||||
@@ -116,10 +123,6 @@ inline flatbuffers::Offset<TableInNestedNS> CreateTableInNestedNS(
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
inline flatbuffers::TypeTable *TableInNestedNSTypeTable();
|
||||
|
||||
inline flatbuffers::TypeTable *StructInNestedNSTypeTable();
|
||||
|
||||
inline flatbuffers::TypeTable *EnumInNestedNSTypeTable() {
|
||||
static flatbuffers::TypeCode type_codes[] = {
|
||||
{ flatbuffers::ET_CHAR, 0, 0 },
|
||||
|
||||
Reference in New Issue
Block a user