diff options
| author | Pimyn Girgis <pimyn@google.com> | 2025-12-02 12:28:10 +0000 |
|---|---|---|
| committer | Tahuti <pimyn@google.com> | 2025-12-03 09:02:54 +0000 |
| commit | 1cfbf16e320ca9bdadd9c24eb1d2d68b25369ba6 (patch) | |
| tree | be0ce827f327c8a76125307e64047e01fa449d4c /executor/_include/flatbuffers/flatbuffers.h | |
| parent | 42a04216dd856c12e723e48930e85d63998e4eda (diff) | |
executor: update flatbuffers
Update flatbuffers to v23.5.26, which matches the compiler version in the new env container.
Diffstat (limited to 'executor/_include/flatbuffers/flatbuffers.h')
| -rw-r--r-- | executor/_include/flatbuffers/flatbuffers.h | 18 |
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 |
