mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-03 04:21:13 +00:00
merge
This commit is contained in:
@@ -754,7 +754,7 @@ class FlatBufferBuilder FLATBUFFERS_FINAL_CLASS {
|
||||
}
|
||||
|
||||
template<typename T> Offset<Vector<Offset<T>>> CreateVectorOfSortedTables(
|
||||
std::vector<T> *v) {
|
||||
std::vector<Offset<T>> *v) {
|
||||
return CreateVectorOfSortedTables(v->data(), v->size());
|
||||
}
|
||||
|
||||
@@ -1017,6 +1017,8 @@ class Table {
|
||||
return true;
|
||||
}
|
||||
|
||||
uint8_t *GetVTable() { return data_ - ReadScalar<soffset_t>(data_); }
|
||||
|
||||
bool CheckField(voffset_t field) const {
|
||||
return GetOptionalFieldOffset(field) != 0;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
|
||||
#include "flatbuffers/flatbuffers.h"
|
||||
#include "flatbuffers/hash.h"
|
||||
#include "flatbuffers/reflection.h"
|
||||
|
||||
// This file defines the data types representing a parsed IDL (Interface
|
||||
// Definition Language) / schema file.
|
||||
@@ -126,6 +127,8 @@ struct Type {
|
||||
|
||||
Type VectorType() const { return Type(element, struct_def, enum_def); }
|
||||
|
||||
Offset<reflection::Type> Serialize(FlatBufferBuilder *builder) const;
|
||||
|
||||
BaseType base_type;
|
||||
BaseType element; // only set if t == BASE_TYPE_VECTOR
|
||||
StructDef *struct_def; // only set if t or element == BASE_TYPE_STRUCT
|
||||
@@ -179,7 +182,8 @@ struct Namespace {
|
||||
|
||||
// Base class for all definition types (fields, structs_, enums_).
|
||||
struct Definition {
|
||||
Definition() : generated(false), defined_namespace(nullptr) {}
|
||||
Definition() : generated(false), defined_namespace(nullptr),
|
||||
serialized_location(0), index(-1) {}
|
||||
|
||||
std::string name;
|
||||
std::string file;
|
||||
@@ -187,12 +191,19 @@ struct Definition {
|
||||
SymbolTable<Value> attributes;
|
||||
bool generated; // did we already output code for this definition?
|
||||
Namespace *defined_namespace; // Where it was defined.
|
||||
|
||||
// For use with Serialize()
|
||||
uoffset_t serialized_location;
|
||||
int index; // Inside the vector it is stored.
|
||||
};
|
||||
|
||||
struct FieldDef : public Definition {
|
||||
FieldDef() : deprecated(false), required(false), key(false), padding(0),
|
||||
used(false) {}
|
||||
|
||||
Offset<reflection::Field> Serialize(FlatBufferBuilder *builder, uint16_t id)
|
||||
const;
|
||||
|
||||
Value value;
|
||||
bool deprecated; // Field is allowed to be present in old data, but can't be
|
||||
// written in new data nor accessed in new code.
|
||||
@@ -218,6 +229,8 @@ struct StructDef : public Definition {
|
||||
if (fields.vec.size()) fields.vec.back()->padding = padding;
|
||||
}
|
||||
|
||||
Offset<reflection::Object> Serialize(FlatBufferBuilder *builder) const;
|
||||
|
||||
SymbolTable<FieldDef> fields;
|
||||
bool fixed; // If it's struct, not a table.
|
||||
bool predecl; // If it's used before it was defined.
|
||||
@@ -243,6 +256,8 @@ struct EnumVal {
|
||||
EnumVal(const std::string &_name, int64_t _val)
|
||||
: name(_name), value(_val), struct_def(nullptr) {}
|
||||
|
||||
Offset<reflection::EnumVal> Serialize(FlatBufferBuilder *builder) const;
|
||||
|
||||
std::string name;
|
||||
std::vector<std::string> doc_comment;
|
||||
int64_t value;
|
||||
@@ -263,6 +278,8 @@ struct EnumDef : public Definition {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Offset<reflection::Enum> Serialize(FlatBufferBuilder *builder) const;
|
||||
|
||||
SymbolTable<EnumVal> vals;
|
||||
bool is_union;
|
||||
Type underlying_type;
|
||||
@@ -271,7 +288,7 @@ struct EnumDef : public Definition {
|
||||
class Parser {
|
||||
public:
|
||||
Parser(bool strict_json = false, bool proto_mode = false)
|
||||
: root_struct_def(nullptr),
|
||||
: root_struct_def_(nullptr),
|
||||
source_(nullptr),
|
||||
cursor_(nullptr),
|
||||
line_(1),
|
||||
@@ -325,6 +342,10 @@ class Parser {
|
||||
std::set<std::string> GetIncludedFilesRecursive(
|
||||
const std::string &file_name) const;
|
||||
|
||||
// Fills builder_ with a binary version of the schema parsed.
|
||||
// See reflection/reflection.fbs
|
||||
void Serialize();
|
||||
|
||||
private:
|
||||
int64_t ParseHexNum(int nibbles);
|
||||
void Next();
|
||||
@@ -363,7 +384,7 @@ class Parser {
|
||||
std::string error_; // User readable error_ if Parse() == false
|
||||
|
||||
FlatBufferBuilder builder_; // any data contained in the file
|
||||
StructDef *root_struct_def;
|
||||
StructDef *root_struct_def_;
|
||||
std::string file_identifier_;
|
||||
std::string file_extension_;
|
||||
|
||||
@@ -417,7 +438,7 @@ struct GeneratorOptions {
|
||||
output_default_scalars_in_json(false),
|
||||
indent_step(2),
|
||||
output_enum_identifiers(true), prefixed_enums(true),
|
||||
include_dependence_headers(false),
|
||||
include_dependence_headers(true),
|
||||
mutable_buffer(false),
|
||||
one_file(false),
|
||||
lang(GeneratorOptions::kJava) {}
|
||||
|
||||
393
include/flatbuffers/reflection.h
Normal file
393
include/flatbuffers/reflection.h
Normal file
@@ -0,0 +1,393 @@
|
||||
/*
|
||||
* Copyright 2015 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef FLATBUFFERS_REFLECTION_H_
|
||||
#define FLATBUFFERS_REFLECTION_H_
|
||||
|
||||
#include "flatbuffers/util.h"
|
||||
|
||||
// This is somewhat of a circular dependency because flatc (and thus this
|
||||
// file) is needed to generate this header in the first place.
|
||||
// Should normally not be a problem since it can be generated by the
|
||||
// previous version of flatc whenever this code needs to change.
|
||||
// See reflection/generate_code.sh
|
||||
#include "flatbuffers/reflection_generated.h"
|
||||
|
||||
// Helper functionality for reflection.
|
||||
|
||||
namespace flatbuffers {
|
||||
|
||||
inline size_t GetTypeSize(reflection::BaseType base_type) {
|
||||
// This needs to correspond to the BaseType enum.
|
||||
static size_t sizes[] = { 0, 1, 1, 1, 1, 2, 2, 4, 4, 8, 8, 4, 8, 4, 4, 4, 4 };
|
||||
return sizes[base_type];
|
||||
}
|
||||
|
||||
// Get the root, regardless of what type it is.
|
||||
inline Table *GetAnyRoot(uint8_t *flatbuf) {
|
||||
return GetMutableRoot<Table>(flatbuf);
|
||||
}
|
||||
inline const Table *GetAnyRoot(const uint8_t *flatbuf) {
|
||||
return GetRoot<Table>(flatbuf);
|
||||
}
|
||||
|
||||
// Get a field, if you know it's an integer, and its exact type.
|
||||
template<typename T> T GetFieldI(const Table *table,
|
||||
const reflection::Field *field) {
|
||||
assert(sizeof(T) == GetTypeSize(field->type()->base_type()));
|
||||
return table->GetField<T>(field->offset(),
|
||||
static_cast<T>(field->default_integer()));
|
||||
}
|
||||
|
||||
// Get a field, if you know it's floating point and its exact type.
|
||||
template<typename T> T GetFieldF(const Table *table,
|
||||
const reflection::Field *field) {
|
||||
assert(sizeof(T) == GetTypeSize(field->type()->base_type()));
|
||||
return table->GetField<T>(field->offset(),
|
||||
static_cast<T>(field->default_real()));
|
||||
}
|
||||
|
||||
// Get a field, if you know it's a string.
|
||||
inline const String *GetFieldS(const Table *table,
|
||||
const reflection::Field *field) {
|
||||
assert(field->type()->base_type() == reflection::String);
|
||||
return table->GetPointer<const String *>(field->offset());
|
||||
}
|
||||
|
||||
// Get a field, if you know it's a vector.
|
||||
template<typename T> const Vector<T> *GetFieldV(const Table *table,
|
||||
const reflection::Field *field) {
|
||||
assert(field->type()->base_type() == reflection::Vector &&
|
||||
sizeof(T) == GetTypeSize(field->type()->element()));
|
||||
return table->GetPointer<const Vector<T> *>(field->offset());
|
||||
}
|
||||
|
||||
// Get any field as a 64bit int, regardless of what it is (bool/int/float/str).
|
||||
inline int64_t GetAnyFieldI(const Table *table,
|
||||
const reflection::Field *field) {
|
||||
# define FLATBUFFERS_GET(C, T) \
|
||||
static_cast<int64_t>(GetField##C<T>(table, field))
|
||||
switch (field->type()->base_type()) {
|
||||
case reflection::UType:
|
||||
case reflection::Bool:
|
||||
case reflection::UByte: return FLATBUFFERS_GET(I, uint8_t);
|
||||
case reflection::Byte: return FLATBUFFERS_GET(I, int8_t);
|
||||
case reflection::Short: return FLATBUFFERS_GET(I, int16_t);
|
||||
case reflection::UShort: return FLATBUFFERS_GET(I, uint16_t);
|
||||
case reflection::Int: return FLATBUFFERS_GET(I, int32_t);
|
||||
case reflection::UInt: return FLATBUFFERS_GET(I, uint32_t);
|
||||
case reflection::Long: return FLATBUFFERS_GET(I, int64_t);
|
||||
case reflection::ULong: return FLATBUFFERS_GET(I, uint64_t);
|
||||
case reflection::Float: return FLATBUFFERS_GET(F, float);
|
||||
case reflection::Double: return FLATBUFFERS_GET(F, double);
|
||||
case reflection::String: return StringToInt(
|
||||
GetFieldS(table, field)->c_str());
|
||||
default: return 0;
|
||||
}
|
||||
# undef FLATBUFFERS_GET
|
||||
}
|
||||
|
||||
// Get any field as a double, regardless of what it is (bool/int/float/str).
|
||||
inline double GetAnyFieldF(const Table *table,
|
||||
const reflection::Field *field) {
|
||||
switch (field->type()->base_type()) {
|
||||
case reflection::Float: return GetFieldF<float>(table, field);
|
||||
case reflection::Double: return GetFieldF<double>(table, field);
|
||||
case reflection::String: return strtod(GetFieldS(table, field)->c_str(),
|
||||
nullptr);
|
||||
default: return static_cast<double>(GetAnyFieldI(table, field));
|
||||
}
|
||||
}
|
||||
|
||||
// Get any field as a string, regardless of what it is (bool/int/float/str).
|
||||
inline std::string GetAnyFieldS(const Table *table,
|
||||
const reflection::Field *field) {
|
||||
switch (field->type()->base_type()) {
|
||||
case reflection::Float:
|
||||
case reflection::Double: return NumToString(GetAnyFieldF(table, field));
|
||||
case reflection::String: return GetFieldS(table, field)->c_str();
|
||||
// TODO: could return vector/table etc as JSON string.
|
||||
default: return NumToString(GetAnyFieldI(table, field));
|
||||
}
|
||||
}
|
||||
|
||||
// Set any scalar field, if you know its exact type.
|
||||
template<typename T> bool SetField(Table *table, const reflection::Field *field,
|
||||
T val) {
|
||||
assert(sizeof(T) == GetTypeSize(field->type()->base_type()));
|
||||
return table->SetField(field->offset(), val);
|
||||
}
|
||||
|
||||
// Set any field as a 64bit int, regardless of what it is (bool/int/float/str).
|
||||
inline void SetAnyFieldI(Table *table, const reflection::Field *field,
|
||||
int64_t val) {
|
||||
# define FLATBUFFERS_SET(T) SetField<T>(table, field, static_cast<T>(val))
|
||||
switch (field->type()->base_type()) {
|
||||
case reflection::UType:
|
||||
case reflection::Bool:
|
||||
case reflection::UByte: FLATBUFFERS_SET(uint8_t ); break;
|
||||
case reflection::Byte: FLATBUFFERS_SET(int8_t ); break;
|
||||
case reflection::Short: FLATBUFFERS_SET(int16_t ); break;
|
||||
case reflection::UShort: FLATBUFFERS_SET(uint16_t ); break;
|
||||
case reflection::Int: FLATBUFFERS_SET(int32_t ); break;
|
||||
case reflection::UInt: FLATBUFFERS_SET(uint32_t ); break;
|
||||
case reflection::Long: FLATBUFFERS_SET(int64_t ); break;
|
||||
case reflection::ULong: FLATBUFFERS_SET(uint64_t ); break;
|
||||
case reflection::Float: FLATBUFFERS_SET(float ); break;
|
||||
case reflection::Double: FLATBUFFERS_SET(double ); break;
|
||||
// TODO: support strings
|
||||
default: break;
|
||||
}
|
||||
# undef FLATBUFFERS_SET
|
||||
}
|
||||
|
||||
// Set any field as a double, regardless of what it is (bool/int/float/str).
|
||||
inline void SetAnyFieldF(Table *table, const reflection::Field *field,
|
||||
double val) {
|
||||
switch (field->type()->base_type()) {
|
||||
case reflection::Float: SetField<float> (table, field,
|
||||
static_cast<float>(val)); break;
|
||||
case reflection::Double: SetField<double>(table, field, val); break;
|
||||
// TODO: support strings.
|
||||
default: SetAnyFieldI(table, field, static_cast<int64_t>(val)); break;
|
||||
}
|
||||
}
|
||||
|
||||
// Set any field as a string, regardless of what it is (bool/int/float/str).
|
||||
inline void SetAnyFieldS(Table *table, const reflection::Field *field,
|
||||
const char *val) {
|
||||
switch (field->type()->base_type()) {
|
||||
case reflection::Float:
|
||||
case reflection::Double: SetAnyFieldF(table, field, strtod(val, nullptr));
|
||||
// TODO: support strings.
|
||||
default: SetAnyFieldI(table, field, StringToInt(val)); break;
|
||||
}
|
||||
}
|
||||
|
||||
// "smart" pointer for use with resizing vectors: turns a pointer inside
|
||||
// a vector into a relative offset, such that it is not affected by resizes.
|
||||
template<typename T, typename U> class pointer_inside_vector {
|
||||
public:
|
||||
pointer_inside_vector(const T *ptr, const std::vector<U> &vec)
|
||||
: offset_(reinterpret_cast<const uint8_t *>(ptr) -
|
||||
reinterpret_cast<const uint8_t *>(vec.data())),
|
||||
vec_(vec) {}
|
||||
|
||||
const T *operator*() const {
|
||||
return reinterpret_cast<const T *>(
|
||||
reinterpret_cast<const uint8_t *>(vec_.data()) + offset_);
|
||||
}
|
||||
const T *operator->() const {
|
||||
return operator*();
|
||||
}
|
||||
void operator=(const pointer_inside_vector &piv);
|
||||
private:
|
||||
size_t offset_;
|
||||
const std::vector<U> &vec_;
|
||||
};
|
||||
|
||||
// Helper to create the above easily without specifying template args.
|
||||
template<typename T, typename U> pointer_inside_vector<T, U> piv(
|
||||
const T *ptr, const std::vector<U> &vec) {
|
||||
return pointer_inside_vector<T, U>(ptr, vec);
|
||||
}
|
||||
|
||||
// Resize a FlatBuffer in-place by iterating through all offsets in the buffer
|
||||
// and adjusting them by "delta" if they straddle the start offset.
|
||||
// Once that is done, bytes can now be inserted/deleted safely.
|
||||
// "delta" may be negative (shrinking).
|
||||
// Unless "delta" is a multiple of the largest alignment, you'll create a small
|
||||
// amount of garbage space in the buffer.
|
||||
class ResizeContext {
|
||||
public:
|
||||
ResizeContext(const reflection::Schema &schema, uoffset_t start, int delta,
|
||||
std::vector<uint8_t> *flatbuf)
|
||||
: schema_(schema), startptr_(flatbuf->data() + start),
|
||||
delta_(delta), buf_(*flatbuf),
|
||||
dag_check_(flatbuf->size() / sizeof(uoffset_t), false) {
|
||||
auto mask = sizeof(largest_scalar_t) - 1;
|
||||
delta_ = (delta_ + mask) & ~mask;
|
||||
if (!delta_) return; // We can't shrink by less than largest_scalar_t.
|
||||
// Now change all the offsets by delta_.
|
||||
auto root = GetAnyRoot(buf_.data());
|
||||
Straddle<uoffset_t, 1>(buf_.data(), root, buf_.data());
|
||||
ResizeTable(schema.root_table(), root);
|
||||
// We can now add or remove bytes at start.
|
||||
if (delta_ > 0) buf_.insert(buf_.begin() + start, delta_, 0);
|
||||
else buf_.erase(buf_.begin() + start, buf_.begin() + start - delta_);
|
||||
}
|
||||
|
||||
// Check if the range between first (lower address) and second straddles
|
||||
// the insertion point. If it does, change the offset at offsetloc (of
|
||||
// type T, with direction D).
|
||||
template<typename T, int D> void Straddle(void *first, void *second,
|
||||
void *offsetloc) {
|
||||
if (first <= startptr_ && second >= startptr_) {
|
||||
WriteScalar<T>(offsetloc, ReadScalar<T>(offsetloc) + delta_ * D);
|
||||
DagCheck(offsetloc) = true;
|
||||
}
|
||||
}
|
||||
|
||||
// This returns a boolean that records if the corresponding offset location
|
||||
// has been modified already. If so, we can't even read the corresponding
|
||||
// offset, since it is pointing to a location that is illegal until the
|
||||
// resize actually happens.
|
||||
// This must be checked for every offset, since we can't know which offsets
|
||||
// will straddle and which won't.
|
||||
uint8_t &DagCheck(void *offsetloc) {
|
||||
auto dag_idx = reinterpret_cast<uoffset_t *>(offsetloc) -
|
||||
reinterpret_cast<uoffset_t *>(buf_.data());
|
||||
return dag_check_[dag_idx];
|
||||
}
|
||||
|
||||
void ResizeTable(const reflection::Object *objectdef, Table *table) {
|
||||
if (DagCheck(table))
|
||||
return; // Table already visited.
|
||||
auto vtable = table->GetVTable();
|
||||
// Check if the vtable offset points beyond the insertion point.
|
||||
Straddle<soffset_t, -1>(table, vtable, table);
|
||||
// This direction shouldn't happen because vtables that sit before tables
|
||||
// are always directly adjacent, but check just in case we ever change the
|
||||
// way flatbuffers are built.
|
||||
Straddle<soffset_t, -1>(vtable, table, table);
|
||||
// Early out: since all fields inside the table must point forwards in
|
||||
// memory, if the insertion point is before the table we can stop here.
|
||||
auto tableloc = reinterpret_cast<uint8_t *>(table);
|
||||
if (startptr_ <= tableloc) return;
|
||||
// Check each field.
|
||||
auto fielddefs = objectdef->fields();
|
||||
for (auto it = fielddefs->begin(); it != fielddefs->end(); ++it) {
|
||||
auto fielddef = *it;
|
||||
auto base_type = fielddef->type()->base_type();
|
||||
// Ignore scalars.
|
||||
if (base_type <= reflection::Double) continue;
|
||||
// Ignore fields that are not stored.
|
||||
auto offset = table->GetOptionalFieldOffset(fielddef->offset());
|
||||
if (!offset) continue;
|
||||
// Ignore structs.
|
||||
auto subobjectdef = base_type == reflection::Obj ?
|
||||
schema_.objects()->Get(fielddef->type()->index()) : nullptr;
|
||||
if (subobjectdef && subobjectdef->is_struct()) continue;
|
||||
// Get this fields' offset, and read it if safe.
|
||||
auto offsetloc = tableloc + offset;
|
||||
if (DagCheck(offsetloc))
|
||||
continue; // This offset already visited.
|
||||
auto ref = offsetloc + ReadScalar<uoffset_t>(offsetloc);
|
||||
Straddle<uoffset_t, 1>(offsetloc, ref, offsetloc);
|
||||
// Recurse.
|
||||
switch (base_type) {
|
||||
case reflection::Obj: {
|
||||
ResizeTable(subobjectdef, reinterpret_cast<Table *>(ref));
|
||||
break;
|
||||
}
|
||||
case reflection::Vector: {
|
||||
if (fielddef->type()->element() != reflection::Obj) break;
|
||||
auto vec = reinterpret_cast<Vector<uoffset_t> *>(ref);
|
||||
auto elemobjectdef =
|
||||
schema_.objects()->Get(fielddef->type()->index());
|
||||
if (elemobjectdef->is_struct()) break;
|
||||
for (uoffset_t i = 0; i < vec->size(); i++) {
|
||||
auto loc = vec->Data() + i * sizeof(uoffset_t);
|
||||
if (DagCheck(loc))
|
||||
continue; // This offset already visited.
|
||||
auto dest = loc + vec->Get(i);
|
||||
Straddle<uoffset_t, 1>(loc, dest ,loc);
|
||||
ResizeTable(elemobjectdef, reinterpret_cast<Table *>(dest));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case reflection::Union: {
|
||||
auto enumdef = schema_.enums()->Get(fielddef->type()->index());
|
||||
// TODO: this is clumsy and slow, but no other way to find it?
|
||||
auto type_field = fielddefs->LookupByKey(
|
||||
(fielddef->name()->c_str() + std::string("_type")).c_str());
|
||||
assert(type_field);
|
||||
auto union_type = GetFieldI<uint8_t>(table, type_field);
|
||||
auto enumval = enumdef->values()->LookupByKey(union_type);
|
||||
ResizeTable(enumval->object(), reinterpret_cast<Table *>(ref));
|
||||
break;
|
||||
}
|
||||
case reflection::String:
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void operator=(const ResizeContext &rc);
|
||||
|
||||
private:
|
||||
const reflection::Schema &schema_;
|
||||
uint8_t *startptr_;
|
||||
int delta_;
|
||||
std::vector<uint8_t> &buf_;
|
||||
std::vector<uint8_t> dag_check_;
|
||||
};
|
||||
|
||||
// Changes the contents of a string inside a FlatBuffer. FlatBuffer must
|
||||
// live inside a std::vector so we can resize the buffer if needed.
|
||||
// "str" must live inside "flatbuf" and may be invalidated after this call.
|
||||
inline void SetString(const reflection::Schema &schema, const std::string &val,
|
||||
const String *str, std::vector<uint8_t> *flatbuf) {
|
||||
auto delta = static_cast<int>(val.size()) - static_cast<int>(str->Length());
|
||||
auto start = static_cast<uoffset_t>(reinterpret_cast<const uint8_t *>(str) -
|
||||
flatbuf->data() +
|
||||
sizeof(uoffset_t));
|
||||
if (delta) {
|
||||
// Different size, we must expand (or contract).
|
||||
ResizeContext(schema, start, delta, flatbuf);
|
||||
if (delta < 0) {
|
||||
// Clear the old string, since we don't want parts of it remaining.
|
||||
memset(flatbuf->data() + start, 0, str->Length());
|
||||
}
|
||||
}
|
||||
// Copy new data. Safe because we created the right amount of space.
|
||||
memcpy(flatbuf->data() + start, val.c_str(), val.size() + 1);
|
||||
}
|
||||
|
||||
// Resizes a flatbuffers::Vector inside a FlatBuffer. FlatBuffer must
|
||||
// live inside a std::vector so we can resize the buffer if needed.
|
||||
// "vec" must live inside "flatbuf" and may be invalidated after this call.
|
||||
template<typename T> void ResizeVector(const reflection::Schema &schema,
|
||||
uoffset_t newsize, T val,
|
||||
const Vector<T> *vec,
|
||||
std::vector<uint8_t> *flatbuf) {
|
||||
auto delta_elem = static_cast<int>(newsize) - static_cast<int>(vec->size());
|
||||
auto delta_bytes = delta_elem * static_cast<int>(sizeof(T));
|
||||
auto vec_start = reinterpret_cast<const uint8_t *>(vec) - flatbuf->data();
|
||||
auto start = static_cast<uoffset_t>(vec_start + sizeof(uoffset_t) +
|
||||
sizeof(T) * vec->size());
|
||||
if (delta_bytes) {
|
||||
ResizeContext(schema, start, delta_bytes, flatbuf);
|
||||
WriteScalar(flatbuf->data() + vec_start, newsize); // Length field.
|
||||
// Set new elements to "val".
|
||||
for (int i = 0; i < delta_elem; i++) {
|
||||
auto loc = flatbuf->data() + start + i * sizeof(T);
|
||||
auto is_scalar = std::is_scalar<T>::value;
|
||||
if (is_scalar) {
|
||||
WriteScalar(loc, val);
|
||||
} else { // struct
|
||||
*reinterpret_cast<T *>(loc) = val;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace flatbuffers
|
||||
|
||||
#endif // FLATBUFFERS_REFLECTION_H_
|
||||
368
include/flatbuffers/reflection_generated.h
Normal file
368
include/flatbuffers/reflection_generated.h
Normal file
@@ -0,0 +1,368 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
#ifndef FLATBUFFERS_GENERATED_REFLECTION_REFLECTION_H_
|
||||
#define FLATBUFFERS_GENERATED_REFLECTION_REFLECTION_H_
|
||||
|
||||
#include "flatbuffers/flatbuffers.h"
|
||||
|
||||
|
||||
namespace reflection {
|
||||
|
||||
struct Type;
|
||||
struct EnumVal;
|
||||
struct Enum;
|
||||
struct Field;
|
||||
struct Object;
|
||||
struct Schema;
|
||||
|
||||
enum BaseType {
|
||||
None = 0,
|
||||
UType = 1,
|
||||
Bool = 2,
|
||||
Byte = 3,
|
||||
UByte = 4,
|
||||
Short = 5,
|
||||
UShort = 6,
|
||||
Int = 7,
|
||||
UInt = 8,
|
||||
Long = 9,
|
||||
ULong = 10,
|
||||
Float = 11,
|
||||
Double = 12,
|
||||
String = 13,
|
||||
Vector = 14,
|
||||
Obj = 15,
|
||||
Union = 16
|
||||
};
|
||||
|
||||
inline const char **EnumNamesBaseType() {
|
||||
static const char *names[] = { "None", "UType", "Bool", "Byte", "UByte", "Short", "UShort", "Int", "UInt", "Long", "ULong", "Float", "Double", "String", "Vector", "Obj", "Union", nullptr };
|
||||
return names;
|
||||
}
|
||||
|
||||
inline const char *EnumNameBaseType(BaseType e) { return EnumNamesBaseType()[e]; }
|
||||
|
||||
struct Type FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
BaseType base_type() const { return static_cast<BaseType>(GetField<int8_t>(4, 0)); }
|
||||
BaseType element() const { return static_cast<BaseType>(GetField<int8_t>(6, 0)); }
|
||||
int32_t index() const { return GetField<int32_t>(8, -1); }
|
||||
bool Verify(flatbuffers::Verifier &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyField<int8_t>(verifier, 4 /* base_type */) &&
|
||||
VerifyField<int8_t>(verifier, 6 /* element */) &&
|
||||
VerifyField<int32_t>(verifier, 8 /* index */) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
|
||||
struct TypeBuilder {
|
||||
flatbuffers::FlatBufferBuilder &fbb_;
|
||||
flatbuffers::uoffset_t start_;
|
||||
void add_base_type(BaseType base_type) { fbb_.AddElement<int8_t>(4, static_cast<int8_t>(base_type), 0); }
|
||||
void add_element(BaseType element) { fbb_.AddElement<int8_t>(6, static_cast<int8_t>(element), 0); }
|
||||
void add_index(int32_t index) { fbb_.AddElement<int32_t>(8, index, -1); }
|
||||
TypeBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
|
||||
TypeBuilder &operator=(const TypeBuilder &);
|
||||
flatbuffers::Offset<Type> Finish() {
|
||||
auto o = flatbuffers::Offset<Type>(fbb_.EndTable(start_, 3));
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline flatbuffers::Offset<Type> CreateType(flatbuffers::FlatBufferBuilder &_fbb,
|
||||
BaseType base_type = None,
|
||||
BaseType element = None,
|
||||
int32_t index = -1) {
|
||||
TypeBuilder builder_(_fbb);
|
||||
builder_.add_index(index);
|
||||
builder_.add_element(element);
|
||||
builder_.add_base_type(base_type);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
struct EnumVal FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
const flatbuffers::String *name() const { return GetPointer<const flatbuffers::String *>(4); }
|
||||
int64_t value() const { return GetField<int64_t>(6, 0); }
|
||||
bool KeyCompareLessThan(const EnumVal *o) const { return value() < o->value(); }
|
||||
int KeyCompareWithValue(int64_t val) const { return value() < val ? -1 : value() > val; }
|
||||
const Object *object() const { return GetPointer<const Object *>(8); }
|
||||
bool Verify(flatbuffers::Verifier &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyFieldRequired<flatbuffers::uoffset_t>(verifier, 4 /* name */) &&
|
||||
verifier.Verify(name()) &&
|
||||
VerifyField<int64_t>(verifier, 6 /* value */) &&
|
||||
VerifyField<flatbuffers::uoffset_t>(verifier, 8 /* object */) &&
|
||||
verifier.VerifyTable(object()) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
|
||||
struct EnumValBuilder {
|
||||
flatbuffers::FlatBufferBuilder &fbb_;
|
||||
flatbuffers::uoffset_t start_;
|
||||
void add_name(flatbuffers::Offset<flatbuffers::String> name) { fbb_.AddOffset(4, name); }
|
||||
void add_value(int64_t value) { fbb_.AddElement<int64_t>(6, value, 0); }
|
||||
void add_object(flatbuffers::Offset<Object> object) { fbb_.AddOffset(8, object); }
|
||||
EnumValBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
|
||||
EnumValBuilder &operator=(const EnumValBuilder &);
|
||||
flatbuffers::Offset<EnumVal> Finish() {
|
||||
auto o = flatbuffers::Offset<EnumVal>(fbb_.EndTable(start_, 3));
|
||||
fbb_.Required(o, 4); // name
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline flatbuffers::Offset<EnumVal> CreateEnumVal(flatbuffers::FlatBufferBuilder &_fbb,
|
||||
flatbuffers::Offset<flatbuffers::String> name = 0,
|
||||
int64_t value = 0,
|
||||
flatbuffers::Offset<Object> object = 0) {
|
||||
EnumValBuilder builder_(_fbb);
|
||||
builder_.add_value(value);
|
||||
builder_.add_object(object);
|
||||
builder_.add_name(name);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
struct Enum FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
const flatbuffers::String *name() const { return GetPointer<const flatbuffers::String *>(4); }
|
||||
bool KeyCompareLessThan(const Enum *o) const { return *name() < *o->name(); }
|
||||
int KeyCompareWithValue(const char *val) const { return strcmp(name()->c_str(), val); }
|
||||
const flatbuffers::Vector<flatbuffers::Offset<EnumVal>> *values() const { return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<EnumVal>> *>(6); }
|
||||
uint8_t is_union() const { return GetField<uint8_t>(8, 0); }
|
||||
const Type *underlying_type() const { return GetPointer<const Type *>(10); }
|
||||
bool Verify(flatbuffers::Verifier &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyFieldRequired<flatbuffers::uoffset_t>(verifier, 4 /* name */) &&
|
||||
verifier.Verify(name()) &&
|
||||
VerifyFieldRequired<flatbuffers::uoffset_t>(verifier, 6 /* values */) &&
|
||||
verifier.Verify(values()) &&
|
||||
verifier.VerifyVectorOfTables(values()) &&
|
||||
VerifyField<uint8_t>(verifier, 8 /* is_union */) &&
|
||||
VerifyFieldRequired<flatbuffers::uoffset_t>(verifier, 10 /* underlying_type */) &&
|
||||
verifier.VerifyTable(underlying_type()) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
|
||||
struct EnumBuilder {
|
||||
flatbuffers::FlatBufferBuilder &fbb_;
|
||||
flatbuffers::uoffset_t start_;
|
||||
void add_name(flatbuffers::Offset<flatbuffers::String> name) { fbb_.AddOffset(4, name); }
|
||||
void add_values(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<EnumVal>>> values) { fbb_.AddOffset(6, values); }
|
||||
void add_is_union(uint8_t is_union) { fbb_.AddElement<uint8_t>(8, is_union, 0); }
|
||||
void add_underlying_type(flatbuffers::Offset<Type> underlying_type) { fbb_.AddOffset(10, underlying_type); }
|
||||
EnumBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
|
||||
EnumBuilder &operator=(const EnumBuilder &);
|
||||
flatbuffers::Offset<Enum> Finish() {
|
||||
auto o = flatbuffers::Offset<Enum>(fbb_.EndTable(start_, 4));
|
||||
fbb_.Required(o, 4); // name
|
||||
fbb_.Required(o, 6); // values
|
||||
fbb_.Required(o, 10); // underlying_type
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline flatbuffers::Offset<Enum> CreateEnum(flatbuffers::FlatBufferBuilder &_fbb,
|
||||
flatbuffers::Offset<flatbuffers::String> name = 0,
|
||||
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<EnumVal>>> values = 0,
|
||||
uint8_t is_union = 0,
|
||||
flatbuffers::Offset<Type> underlying_type = 0) {
|
||||
EnumBuilder builder_(_fbb);
|
||||
builder_.add_underlying_type(underlying_type);
|
||||
builder_.add_values(values);
|
||||
builder_.add_name(name);
|
||||
builder_.add_is_union(is_union);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
struct Field FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
const flatbuffers::String *name() const { return GetPointer<const flatbuffers::String *>(4); }
|
||||
bool KeyCompareLessThan(const Field *o) const { return *name() < *o->name(); }
|
||||
int KeyCompareWithValue(const char *val) const { return strcmp(name()->c_str(), val); }
|
||||
const Type *type() const { return GetPointer<const Type *>(6); }
|
||||
uint16_t id() const { return GetField<uint16_t>(8, 0); }
|
||||
uint16_t offset() const { return GetField<uint16_t>(10, 0); }
|
||||
int64_t default_integer() const { return GetField<int64_t>(12, 0); }
|
||||
double default_real() const { return GetField<double>(14, 0.0); }
|
||||
uint8_t deprecated() const { return GetField<uint8_t>(16, 0); }
|
||||
uint8_t required() const { return GetField<uint8_t>(18, 0); }
|
||||
uint8_t key() const { return GetField<uint8_t>(20, 0); }
|
||||
bool Verify(flatbuffers::Verifier &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyFieldRequired<flatbuffers::uoffset_t>(verifier, 4 /* name */) &&
|
||||
verifier.Verify(name()) &&
|
||||
VerifyFieldRequired<flatbuffers::uoffset_t>(verifier, 6 /* type */) &&
|
||||
verifier.VerifyTable(type()) &&
|
||||
VerifyField<uint16_t>(verifier, 8 /* id */) &&
|
||||
VerifyField<uint16_t>(verifier, 10 /* offset */) &&
|
||||
VerifyField<int64_t>(verifier, 12 /* default_integer */) &&
|
||||
VerifyField<double>(verifier, 14 /* default_real */) &&
|
||||
VerifyField<uint8_t>(verifier, 16 /* deprecated */) &&
|
||||
VerifyField<uint8_t>(verifier, 18 /* required */) &&
|
||||
VerifyField<uint8_t>(verifier, 20 /* key */) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
|
||||
struct FieldBuilder {
|
||||
flatbuffers::FlatBufferBuilder &fbb_;
|
||||
flatbuffers::uoffset_t start_;
|
||||
void add_name(flatbuffers::Offset<flatbuffers::String> name) { fbb_.AddOffset(4, name); }
|
||||
void add_type(flatbuffers::Offset<Type> type) { fbb_.AddOffset(6, type); }
|
||||
void add_id(uint16_t id) { fbb_.AddElement<uint16_t>(8, id, 0); }
|
||||
void add_offset(uint16_t offset) { fbb_.AddElement<uint16_t>(10, offset, 0); }
|
||||
void add_default_integer(int64_t default_integer) { fbb_.AddElement<int64_t>(12, default_integer, 0); }
|
||||
void add_default_real(double default_real) { fbb_.AddElement<double>(14, default_real, 0.0); }
|
||||
void add_deprecated(uint8_t deprecated) { fbb_.AddElement<uint8_t>(16, deprecated, 0); }
|
||||
void add_required(uint8_t required) { fbb_.AddElement<uint8_t>(18, required, 0); }
|
||||
void add_key(uint8_t key) { fbb_.AddElement<uint8_t>(20, key, 0); }
|
||||
FieldBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
|
||||
FieldBuilder &operator=(const FieldBuilder &);
|
||||
flatbuffers::Offset<Field> Finish() {
|
||||
auto o = flatbuffers::Offset<Field>(fbb_.EndTable(start_, 9));
|
||||
fbb_.Required(o, 4); // name
|
||||
fbb_.Required(o, 6); // type
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline flatbuffers::Offset<Field> CreateField(flatbuffers::FlatBufferBuilder &_fbb,
|
||||
flatbuffers::Offset<flatbuffers::String> name = 0,
|
||||
flatbuffers::Offset<Type> type = 0,
|
||||
uint16_t id = 0,
|
||||
uint16_t offset = 0,
|
||||
int64_t default_integer = 0,
|
||||
double default_real = 0.0,
|
||||
uint8_t deprecated = 0,
|
||||
uint8_t required = 0,
|
||||
uint8_t key = 0) {
|
||||
FieldBuilder builder_(_fbb);
|
||||
builder_.add_default_real(default_real);
|
||||
builder_.add_default_integer(default_integer);
|
||||
builder_.add_type(type);
|
||||
builder_.add_name(name);
|
||||
builder_.add_offset(offset);
|
||||
builder_.add_id(id);
|
||||
builder_.add_key(key);
|
||||
builder_.add_required(required);
|
||||
builder_.add_deprecated(deprecated);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
struct Object FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
const flatbuffers::String *name() const { return GetPointer<const flatbuffers::String *>(4); }
|
||||
bool KeyCompareLessThan(const Object *o) const { return *name() < *o->name(); }
|
||||
int KeyCompareWithValue(const char *val) const { return strcmp(name()->c_str(), val); }
|
||||
const flatbuffers::Vector<flatbuffers::Offset<Field>> *fields() const { return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<Field>> *>(6); }
|
||||
uint8_t is_struct() const { return GetField<uint8_t>(8, 0); }
|
||||
bool Verify(flatbuffers::Verifier &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyFieldRequired<flatbuffers::uoffset_t>(verifier, 4 /* name */) &&
|
||||
verifier.Verify(name()) &&
|
||||
VerifyFieldRequired<flatbuffers::uoffset_t>(verifier, 6 /* fields */) &&
|
||||
verifier.Verify(fields()) &&
|
||||
verifier.VerifyVectorOfTables(fields()) &&
|
||||
VerifyField<uint8_t>(verifier, 8 /* is_struct */) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
|
||||
struct ObjectBuilder {
|
||||
flatbuffers::FlatBufferBuilder &fbb_;
|
||||
flatbuffers::uoffset_t start_;
|
||||
void add_name(flatbuffers::Offset<flatbuffers::String> name) { fbb_.AddOffset(4, name); }
|
||||
void add_fields(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<Field>>> fields) { fbb_.AddOffset(6, fields); }
|
||||
void add_is_struct(uint8_t is_struct) { fbb_.AddElement<uint8_t>(8, is_struct, 0); }
|
||||
ObjectBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
|
||||
ObjectBuilder &operator=(const ObjectBuilder &);
|
||||
flatbuffers::Offset<Object> Finish() {
|
||||
auto o = flatbuffers::Offset<Object>(fbb_.EndTable(start_, 3));
|
||||
fbb_.Required(o, 4); // name
|
||||
fbb_.Required(o, 6); // fields
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline flatbuffers::Offset<Object> CreateObject(flatbuffers::FlatBufferBuilder &_fbb,
|
||||
flatbuffers::Offset<flatbuffers::String> name = 0,
|
||||
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<Field>>> fields = 0,
|
||||
uint8_t is_struct = 0) {
|
||||
ObjectBuilder builder_(_fbb);
|
||||
builder_.add_fields(fields);
|
||||
builder_.add_name(name);
|
||||
builder_.add_is_struct(is_struct);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
struct Schema FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
const flatbuffers::Vector<flatbuffers::Offset<Object>> *objects() const { return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<Object>> *>(4); }
|
||||
const flatbuffers::Vector<flatbuffers::Offset<Enum>> *enums() const { return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<Enum>> *>(6); }
|
||||
const flatbuffers::String *file_ident() const { return GetPointer<const flatbuffers::String *>(8); }
|
||||
const flatbuffers::String *file_ext() const { return GetPointer<const flatbuffers::String *>(10); }
|
||||
const Object *root_table() const { return GetPointer<const Object *>(12); }
|
||||
bool Verify(flatbuffers::Verifier &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyFieldRequired<flatbuffers::uoffset_t>(verifier, 4 /* objects */) &&
|
||||
verifier.Verify(objects()) &&
|
||||
verifier.VerifyVectorOfTables(objects()) &&
|
||||
VerifyFieldRequired<flatbuffers::uoffset_t>(verifier, 6 /* enums */) &&
|
||||
verifier.Verify(enums()) &&
|
||||
verifier.VerifyVectorOfTables(enums()) &&
|
||||
VerifyField<flatbuffers::uoffset_t>(verifier, 8 /* file_ident */) &&
|
||||
verifier.Verify(file_ident()) &&
|
||||
VerifyField<flatbuffers::uoffset_t>(verifier, 10 /* file_ext */) &&
|
||||
verifier.Verify(file_ext()) &&
|
||||
VerifyField<flatbuffers::uoffset_t>(verifier, 12 /* root_table */) &&
|
||||
verifier.VerifyTable(root_table()) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
|
||||
struct SchemaBuilder {
|
||||
flatbuffers::FlatBufferBuilder &fbb_;
|
||||
flatbuffers::uoffset_t start_;
|
||||
void add_objects(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<Object>>> objects) { fbb_.AddOffset(4, objects); }
|
||||
void add_enums(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<Enum>>> enums) { fbb_.AddOffset(6, enums); }
|
||||
void add_file_ident(flatbuffers::Offset<flatbuffers::String> file_ident) { fbb_.AddOffset(8, file_ident); }
|
||||
void add_file_ext(flatbuffers::Offset<flatbuffers::String> file_ext) { fbb_.AddOffset(10, file_ext); }
|
||||
void add_root_table(flatbuffers::Offset<Object> root_table) { fbb_.AddOffset(12, root_table); }
|
||||
SchemaBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
|
||||
SchemaBuilder &operator=(const SchemaBuilder &);
|
||||
flatbuffers::Offset<Schema> Finish() {
|
||||
auto o = flatbuffers::Offset<Schema>(fbb_.EndTable(start_, 5));
|
||||
fbb_.Required(o, 4); // objects
|
||||
fbb_.Required(o, 6); // enums
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline flatbuffers::Offset<Schema> CreateSchema(flatbuffers::FlatBufferBuilder &_fbb,
|
||||
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<Object>>> objects = 0,
|
||||
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<Enum>>> enums = 0,
|
||||
flatbuffers::Offset<flatbuffers::String> file_ident = 0,
|
||||
flatbuffers::Offset<flatbuffers::String> file_ext = 0,
|
||||
flatbuffers::Offset<Object> root_table = 0) {
|
||||
SchemaBuilder builder_(_fbb);
|
||||
builder_.add_root_table(root_table);
|
||||
builder_.add_file_ext(file_ext);
|
||||
builder_.add_file_ident(file_ident);
|
||||
builder_.add_enums(enums);
|
||||
builder_.add_objects(objects);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
inline const reflection::Schema *GetSchema(const void *buf) { return flatbuffers::GetRoot<reflection::Schema>(buf); }
|
||||
|
||||
inline bool VerifySchemaBuffer(flatbuffers::Verifier &verifier) { return verifier.VerifyBuffer<reflection::Schema>(); }
|
||||
|
||||
inline const char *SchemaIdentifier() { return "BFBS"; }
|
||||
|
||||
inline bool SchemaBufferHasIdentifier(const void *buf) { return flatbuffers::BufferHasIdentifier(buf, SchemaIdentifier()); }
|
||||
|
||||
inline const char *SchemaExtension() { return "bfbs"; }
|
||||
|
||||
inline void FinishSchemaBuffer(flatbuffers::FlatBufferBuilder &fbb, flatbuffers::Offset<reflection::Schema> root) { fbb.Finish(root, SchemaIdentifier()); }
|
||||
|
||||
} // namespace reflection
|
||||
|
||||
#endif // FLATBUFFERS_GENERATED_REFLECTION_REFLECTION_H_
|
||||
Reference in New Issue
Block a user