diff --git a/include/flatbuffers/reflection.h b/include/flatbuffers/reflection.h
index 776a9c258..e445d792e 100644
--- a/include/flatbuffers/reflection.h
+++ b/include/flatbuffers/reflection.h
@@ -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
(flatbuf);
}
-inline const Table *GetAnyRoot(const uint8_t *flatbuf) {
+
+inline const Table *GetAnyRoot(const uint8_t *const flatbuf) {
return GetRoot(flatbuf);
}
+inline Table *GetAnySizePrefixedRoot(uint8_t *const flatbuf) {
+ return GetMutableSizePrefixedRoot(flatbuf);
+}
+
+inline const Table *GetAnySizePrefixedRoot(const uint8_t *const flatbuf) {
+ return GetSizePrefixedRoot(flatbuf);
+}
+
// Get a field's default, if you know it's an integer, and its exact type.
template 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_
diff --git a/src/reflection.cpp b/src/reflection.cpp
index 1d0f1d6b5..01efd86bd 100644
--- a/src/reflection.cpp
+++ b/src/reflection.cpp
@@ -736,10 +736,20 @@ bool VerifyObject(flatbuffers::Verifier &v, const reflection::Schema &schema,
}
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*/) {
+ const uint8_t *const buf, const size_t length,
+ const uoffset_t max_depth, const uoffset_t max_tables) {
Verifier v(buf, length, max_depth, max_tables);
- return VerifyObject(v, schema, root, flatbuffers::GetAnyRoot(buf), true);
+ return VerifyObject(v, schema, root, flatbuffers::GetAnyRoot(buf),
+ /*required=*/true);
+}
+
+bool VerifySizePrefixed(const reflection::Schema &schema,
+ const reflection::Object &root,
+ const uint8_t *const buf, const size_t length,
+ const uoffset_t max_depth, const uoffset_t max_tables) {
+ Verifier v(buf, length, max_depth, max_tables);
+ return VerifyObject(v, schema, root, flatbuffers::GetAnySizePrefixedRoot(buf),
+ /*required=*/true);
}
} // namespace flatbuffers