mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-15 16:57:29 +00:00
Json : Add --size-prefixed option to flatc (#4645)
to be able to convert to json size prefixed buffers.
This commit is contained in:
committed by
Wouter van Oortmerssen
parent
cc158e7009
commit
e78825e7a0
@@ -1664,13 +1664,14 @@ const T *GetTemporaryPointer(FlatBufferBuilder &fbb, Offset<T> offset) {
|
||||
/// This function is UNDEFINED for FlatBuffers whose schema does not include
|
||||
/// a file_identifier (likely points at padding or the start of a the root
|
||||
/// vtable).
|
||||
inline const char *GetBufferIdentifier(const void *buf) {
|
||||
return reinterpret_cast<const char *>(buf) + sizeof(uoffset_t);
|
||||
inline const char *GetBufferIdentifier(const void *buf, bool size_prefixed = false) {
|
||||
return reinterpret_cast<const char *>(buf) +
|
||||
((size_prefixed) ? 2 * sizeof(uoffset_t) : sizeof(uoffset_t));
|
||||
}
|
||||
|
||||
// Helper to see if the identifier in a buffer has the expected value.
|
||||
inline bool BufferHasIdentifier(const void *buf, const char *identifier) {
|
||||
return strncmp(GetBufferIdentifier(buf), identifier,
|
||||
inline bool BufferHasIdentifier(const void *buf, const char *identifier, bool size_prefixed = false) {
|
||||
return strncmp(GetBufferIdentifier(buf, size_prefixed), identifier,
|
||||
FlatBufferBuilder::kFileIdentifierLength) == 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user