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:
Alexander Gallego
2018-02-15 17:58:06 -05:00
committed by Wouter van Oortmerssen
parent daf0a420be
commit 36f8564846
7 changed files with 119 additions and 68 deletions

View File

@@ -819,7 +819,7 @@ void ReflectionTest(uint8_t *flatbuf, size_t length) {
}
void MiniReflectFlatBuffersTest(uint8_t *flatbuf) {
auto s = flatbuffers::FlatBufferToString(flatbuf, MonsterTypeTable());
auto s = flatbuffers::FlatBufferToString(flatbuf, Monster::MiniReflectTypeTable());
TEST_EQ_STR(
s.c_str(),
"{ "