mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-09 22:56:27 +00:00
VerifySizePrefixed (reflection::Schema) and GetAnySizePrefixedRoot added (#7181)
* Typo in flatc options (warning-as-errors instead of warnings-as-errors) * VerifySizePrefixed (reflection::Schema) and GetAnySizePrefixedRoot added * some review comments * more review comments
This commit is contained in:
@@ -88,13 +88,22 @@ inline size_t GetTypeSizeInline(reflection::BaseType base_type, int type_index,
|
||||
}
|
||||
|
||||
// Get the root, regardless of what type it is.
|
||||
inline Table *GetAnyRoot(uint8_t *flatbuf) {
|
||||
inline Table *GetAnyRoot(uint8_t *const flatbuf) {
|
||||
return GetMutableRoot<Table>(flatbuf);
|
||||
}
|
||||
inline const Table *GetAnyRoot(const uint8_t *flatbuf) {
|
||||
|
||||
inline const Table *GetAnyRoot(const uint8_t *const flatbuf) {
|
||||
return GetRoot<Table>(flatbuf);
|
||||
}
|
||||
|
||||
inline Table *GetAnySizePrefixedRoot(uint8_t *const flatbuf) {
|
||||
return GetMutableSizePrefixedRoot<Table>(flatbuf);
|
||||
}
|
||||
|
||||
inline const Table *GetAnySizePrefixedRoot(const uint8_t *const flatbuf) {
|
||||
return GetSizePrefixedRoot<Table>(flatbuf);
|
||||
}
|
||||
|
||||
// Get a field's default, if you know it's an integer, and its exact type.
|
||||
template<typename T> T GetFieldDefaultI(const reflection::Field &field) {
|
||||
FLATBUFFERS_ASSERT(sizeof(T) == GetTypeSize(field.type()->base_type()));
|
||||
@@ -503,6 +512,11 @@ bool Verify(const reflection::Schema &schema, const reflection::Object &root,
|
||||
const uint8_t *buf, size_t length, uoffset_t max_depth = 64,
|
||||
uoffset_t max_tables = 1000000);
|
||||
|
||||
bool VerifySizePrefixed(const reflection::Schema &schema,
|
||||
const reflection::Object &root, const uint8_t *buf,
|
||||
size_t length, uoffset_t max_depth = 64,
|
||||
uoffset_t max_tables = 1000000);
|
||||
|
||||
} // namespace flatbuffers
|
||||
|
||||
#endif // FLATBUFFERS_REFLECTION_H_
|
||||
|
||||
Reference in New Issue
Block a user