24#include "flatbuffers/array.h"
25#include "flatbuffers/base.h"
26#include "flatbuffers/buffer.h"
27#include "flatbuffers/buffer_ref.h"
28#include "flatbuffers/detached_buffer.h"
29#include "flatbuffers/flatbuffer_builder.h"
30#include "flatbuffers/stl_emulation.h"
31#include "flatbuffers/string.h"
32#include "flatbuffers/struct.h"
33#include "flatbuffers/table.h"
34#include "flatbuffers/vector.h"
35#include "flatbuffers/vector_downward.h"
36#include "flatbuffers/verifier.h"
38namespace flatbuffers {
44inline const uint8_t *GetBufferStartFromRootPointer(
const void *root) {
45 auto table =
reinterpret_cast<const Table *
>(root);
46 auto vtable = table->GetVTable();
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))
74 FLATBUFFERS_ASSERT(
false);
79inline uoffset_t GetPrefixedSize(
const uint8_t *buf) {
80 return ReadScalar<uoffset_t>(buf);
96typedef uint64_t hash_value_t;
97typedef std::function<void(
void **pointer_adr, hash_value_t hash)>
99typedef std::function<hash_value_t(
void *pointer)> rehasher_function_t;
109bool IsFieldPresent(
const T *table,
typename T::FlatBuffersVTableOffset field) {
111 return reinterpret_cast<const Table *
>(table)->CheckField(
112 static_cast<voffset_t
>(field));
118inline int LookupEnum(
const char **names,
const char *name) {
119 for (
const char **p = names; *p; p++)
120 if (!strcmp(*p, name))
return static_cast<int>(p - names);
136 #define FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(alignment) \
138 struct __declspec(align(alignment))
139 #define FLATBUFFERS_STRUCT_END(name, size) \
141 static_assert(sizeof(name) == size, "compiler breaks packing rules")
142#elif defined(__GNUC__) || defined(__clang__) || defined(__ICCARM__)
143 #define FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(alignment) \
145 struct __attribute__((aligned(alignment)))
146 #define FLATBUFFERS_STRUCT_END(name, size) \
148 static_assert(sizeof(name) == size, "compiler breaks packing rules")
150 #error Unknown compiler, please define structure alignment macros
164enum SequenceType { ST_TABLE, ST_STRUCT, ST_UNION, ST_ENUM };
168#define FLATBUFFERS_GEN_ELEMENTARY_TYPES(ET) \
185 #define FLATBUFFERS_ET(E) E,
186 FLATBUFFERS_GEN_ELEMENTARY_TYPES(FLATBUFFERS_ET)
187 #undef FLATBUFFERS_ET
190inline const char *
const *ElementaryTypeNames() {
191 static const char *
const names[] = {
192 #define FLATBUFFERS_ET(E) #E,
193 FLATBUFFERS_GEN_ELEMENTARY_TYPES(FLATBUFFERS_ET)
194 #undef FLATBUFFERS_ET
206 unsigned short base_type : 4;
208 unsigned short is_repeating : 1;
210 signed short sequence_ref : 11;
213static_assert(
sizeof(
TypeCode) == 2,
"TypeCode");
218typedef const TypeTable *(*TypeFunction)();
224 const TypeFunction *type_refs;
225 const int16_t *array_sizes;
226 const int64_t *values;
227 const char *
const *names;
231inline const char *flatbuffers_version_string() {
232 return "FlatBuffers " FLATBUFFERS_STRING(FLATBUFFERS_VERSION_MAJOR)
"."
233 FLATBUFFERS_STRING(FLATBUFFERS_VERSION_MINOR)
"."
234 FLATBUFFERS_STRING(FLATBUFFERS_VERSION_REVISION);
238#define FLATBUFFERS_DEFINE_BITMASK_OPERATORS(E, T)\
239 inline E operator | (E lhs, E rhs){\
240 return E(T(lhs) | T(rhs));\
242 inline E operator & (E lhs, E rhs){\
243 return E(T(lhs) & T(rhs));\
245 inline E operator ^ (E lhs, E rhs){\
246 return E(T(lhs) ^ T(rhs));\
248 inline E operator ~ (E lhs){\
251 inline E operator |= (E &lhs, E rhs){\
255 inline E operator &= (E &lhs, E rhs){\
259 inline E operator ^= (E &lhs, E rhs){\
263 inline bool operator !(E rhs) \
265 return !bool(T(rhs)); \
Definition: flatbuffers.h:86
Definition: flatbuffers.h:204
Definition: flatbuffers.h:220