45 auto table =
reinterpret_cast<const Table *
>(root);
48 auto start = (std::min)(vtable,
reinterpret_cast<const uint8_t *
>(root));
50 start =
reinterpret_cast<const uint8_t *
>(
reinterpret_cast<uintptr_t
>(start) &
51 ~(
sizeof(uoffset_t) - 1));
61 static_assert(flatbuffers::kFileIdentifierLength ==
sizeof(uoffset_t),
62 "file_identifier is assumed to be the same size as uoffset_t");
63 for (
auto possible_roots = FLATBUFFERS_MAX_ALIGNMENT /
sizeof(uoffset_t) + 1;
64 possible_roots; possible_roots--) {
65 start -=
sizeof(uoffset_t);
66 if (ReadScalar<uoffset_t>(start) + start ==
67 reinterpret_cast<const uint8_t *
>(root))
79template<
typename SizeT = uoffset_t>
81 return ReadScalar<SizeT>(buf);
90template<
typename SizeT = uoffset_t>
92 return ReadScalar<SizeT>(buf) +
sizeof(SizeT);
109typedef std::function<void(
void **pointer_adr,
hash_value_t hash)>
123 return reinterpret_cast<const Table *
>(table)->CheckField(
124 static_cast<voffset_t
>(field));
131 for (
const char **
p = names; *
p;
p++)
132 if (!strcmp(*
p, name))
return static_cast<int>(
p - names);
148 #define FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(alignment) \
150 struct __declspec(align(alignment))
151 #define FLATBUFFERS_STRUCT_END(name, size) \
153 static_assert(sizeof(name) == size, "compiler breaks packing rules")
154#elif defined(__GNUC__) || defined(__clang__) || defined(__ICCARM__)
155 #define FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(alignment) \
157 struct __attribute__((aligned(alignment)))
158 #define FLATBUFFERS_STRUCT_END(name, size) \
160 static_assert(sizeof(name) == size, "compiler breaks packing rules")
162 #error Unknown compiler, please define structure alignment macros
180#define FLATBUFFERS_GEN_ELEMENTARY_TYPES(ET) \
197 #define FLATBUFFERS_ET(E) E,
199 #undef FLATBUFFERS_ET
203 static const char *
const names[] = {
204 #define FLATBUFFERS_ET(E) #E,
206 #undef FLATBUFFERS_ET
225static_assert(
sizeof(
TypeCode) == 2,
"TypeCode");
244 return "FlatBuffers " FLATBUFFERS_STRING(FLATBUFFERS_VERSION_MAJOR)
"."
245 FLATBUFFERS_STRING(FLATBUFFERS_VERSION_MINOR)
"."
246 FLATBUFFERS_STRING(FLATBUFFERS_VERSION_REVISION);
250#define FLATBUFFERS_DEFINE_BITMASK_OPERATORS(E, T)\
251 inline E operator | (E lhs, E rhs){\
252 return E(T(lhs) | T(rhs));\
254 inline E operator & (E lhs, E rhs){\
255 return E(T(lhs) & T(rhs));\
257 inline E operator ^ (E lhs, E rhs){\
258 return E(T(lhs) ^ T(rhs));\
260 inline E operator ~ (E lhs){\
263 inline E operator |= (E &lhs, E rhs){\
267 inline E operator &= (E &lhs, E rhs){\
271 inline E operator ^= (E &lhs, E rhs){\
275 inline bool operator !(E rhs) \
277 return !bool(T(rhs)); \
#define FLATBUFFERS_ASSERT
const uint8_t * GetVTable() const
#define FLATBUFFERS_GEN_ELEMENTARY_TYPES(ET)
#define FLATBUFFERS_ET(E)
std::function< hash_value_t(void *pointer)> rehasher_function_t
const char *const * ElementaryTypeNames()
uint64_t hash_value_t
Function types to be used with resolving hashes into objects and back again. The resolver gets a poin...
const TypeTable *(* TypeFunction)()
bool IsFieldPresent(const T *table, typename T::FlatBuffersVTableOffset field)
SizeT GetPrefixedSize(const uint8_t *buf)
This return the prefixed size of a FlatBuffer.
int LookupEnum(const char **names, const char *name)
const uint8_t * GetBufferStartFromRootPointer(const void *root)
This can compute the start of a FlatBuffer from a root pointer, i.e. it is the opposite transformatio...
const char * flatbuffers_version_string()
std::function< void(void **pointer_adr, hash_value_t hash)> resolver_function_t
SizeT GetSizePrefixedBufferLength(const uint8_t *const buf)
signed short sequence_ref
unsigned short is_repeating
const char *const * names
const int16_t * array_sizes
const TypeFunction * type_refs
const TypeCode * type_codes