aboutsummaryrefslogtreecommitdiffstats
path: root/executor/_include/flatbuffers/flatbuffers.h
diff options
context:
space:
mode:
Diffstat (limited to 'executor/_include/flatbuffers/flatbuffers.h')
-rw-r--r--executor/_include/flatbuffers/flatbuffers.h18
1 files changed, 16 insertions, 2 deletions
diff --git a/executor/_include/flatbuffers/flatbuffers.h b/executor/_include/flatbuffers/flatbuffers.h
index 642178897..bc828a313 100644
--- a/executor/_include/flatbuffers/flatbuffers.h
+++ b/executor/_include/flatbuffers/flatbuffers.h
@@ -17,6 +17,8 @@
#ifndef FLATBUFFERS_H_
#define FLATBUFFERS_H_
+#include <algorithm>
+
// TODO: These includes are for mitigating the pains of users editing their
// source because they relied on flatbuffers.h to include everything for them.
#include "flatbuffers/array.h"
@@ -74,8 +76,20 @@ inline const uint8_t *GetBufferStartFromRootPointer(const void *root) {
}
/// @brief This return the prefixed size of a FlatBuffer.
-inline uoffset_t GetPrefixedSize(const uint8_t *buf) {
- return ReadScalar<uoffset_t>(buf);
+template<typename SizeT = uoffset_t>
+inline SizeT GetPrefixedSize(const uint8_t *buf) {
+ return ReadScalar<SizeT>(buf);
+}
+
+// Gets the total length of the buffer given a sized prefixed FlatBuffer.
+//
+// This includes the size of the prefix as well as the buffer:
+//
+// [size prefix][flatbuffer]
+// |---------length--------|
+template<typename SizeT = uoffset_t>
+inline SizeT GetSizePrefixedBufferLength(const uint8_t *const buf) {
+ return ReadScalar<SizeT>(buf) + sizeof(SizeT);
}
// Base class for native objects (FlatBuffer data de-serialized into native