| 23 | namespace flatbuffers { |
| 24 | |
| 25 | int64_t GetAnyValueI(reflection::BaseType type, const uint8_t *data) { |
| 26 | // clang-format off |
| 27 | #define FLATBUFFERS_GET(T) static_cast<int64_t>(ReadScalar<T>(data)) |
| 28 | switch (type) { |
| 29 | case reflection::UType: |
| 30 | case reflection::Bool: |
| 31 | case reflection::UByte: return FLATBUFFERS_GET(uint8_t); |
| 32 | case reflection::Byte: return FLATBUFFERS_GET(int8_t); |
| 33 | case reflection::Short: return FLATBUFFERS_GET(int16_t); |
| 34 | case reflection::UShort: return FLATBUFFERS_GET(uint16_t); |
| 35 | case reflection::Int: return FLATBUFFERS_GET(int32_t); |
| 36 | case reflection::UInt: return FLATBUFFERS_GET(uint32_t); |
| 37 | case reflection::Long: return FLATBUFFERS_GET(int64_t); |
| 38 | case reflection::ULong: return FLATBUFFERS_GET(uint64_t); |
| 39 | case reflection::Float: return FLATBUFFERS_GET(float); |
| 40 | case reflection::Double: return FLATBUFFERS_GET(double); |
| 41 | case reflection::String: { |
| 42 | auto s = reinterpret_cast<const String *>(ReadScalar<uoffset_t>(data) + |
| 43 | data); |
| 44 | return s ? StringToInt(s->c_str()) : 0; |
| 45 | } |
| 46 | default: return 0; // Tables & vectors do not make sense. |
| 47 | } |
| 48 | #undef FLATBUFFERS_GET |
| 49 | // clang-format on |
| 50 | } |
| 51 | |
| 52 | double GetAnyValueF(reflection::BaseType type, const uint8_t *data) { |
| 53 | switch (type) { |
no test coverage detected