ONE - On-device Neural Engine
Loading...
Searching...
No Matches
flatbuffers::FlatBufferBuilderImpl< Is64Aware > Class Template Reference

#include <flatbuffer_builder.h>

Collaboration diagram for flatbuffers::FlatBufferBuilderImpl< Is64Aware >:

Data Structures

struct  FieldLoc
 
struct  StringOffsetCompare
 

Public Types

typedef std::conditional< Is64Aware, uoffset64_t, uoffset_t >::type SizeT
 

Public Member Functions

 FlatBufferBuilderImpl (size_t initial_size=1024, Allocator *allocator=nullptr, bool own_allocator=false, size_t buffer_minalign=AlignOf< largest_scalar_t >())
 Default constructor for FlatBufferBuilder.
 
 FlatBufferBuilderImpl (FlatBufferBuilderImpl &&other) noexcept
 Move constructor for FlatBufferBuilder.
 
FlatBufferBuilderImploperator= (FlatBufferBuilderImpl &&other) noexcept
 Move assignment operator for FlatBufferBuilder.
 
void Swap (FlatBufferBuilderImpl &other)
 
 ~FlatBufferBuilderImpl ()
 
void Reset ()
 
void Clear ()
 Reset all the state in this FlatBufferBuilder so it can be reused to construct another buffer.
 
SizeT GetSize () const
 The current size of the serialized buffer, counting from the end.
 
template<bool is_64 = Is64Aware>
std::enable_if< is_64, uoffset_t >::type GetSizeRelative32BitRegion () const
 The current size of the serialized buffer relative to the end of the 32-bit region.
 
template<bool is_64 = Is64Aware>
std::enable_if<!is_64, uoffset_t >::type GetSizeRelative32BitRegion () const
 
uint8_t * GetBufferPointer () const
 Get the serialized buffer (after you call Finish()).
 
flatbuffers::span< uint8_t > GetBufferSpan () const
 Get the serialized buffer (after you call Finish()) as a span.
 
uint8_t * GetCurrentBufferPointer () const
 Get a pointer to an unfinished buffer.
 
 FLATBUFFERS_ATTRIBUTE () DetachedBuffer ReleaseBufferPointer()
 Get the released pointer to the serialized buffer.
 
DetachedBuffer Release ()
 Get the released DetachedBuffer.
 
uint8_t * ReleaseRaw (size_t &size, size_t &offset)
 Get the released pointer to the serialized buffer.
 
size_t GetBufferMinAlignment () const
 get the minimum alignment this buffer needs to be accessed properly. This is only known once all elements have been written (after you call Finish()). You can use this information if you need to embed a FlatBuffer in some other buffer, such that you can later read it without first having to copy it into its own buffer.
 
void ForceDefaults (bool fd)
 In order to save space, fields that are set to their default value don't get serialized into the buffer.
 
void DedupVtables (bool dedup)
 By default vtables are deduped in order to save space.
 
template<template< typename > class OffsetT = Offset>
OffsetT< StringCreateString (const char *str, size_t len)
 Store a string in the buffer, which can contain any binary data.
 
template<template< typename > class OffsetT = Offset>
OffsetT< StringCreateString (const char *str)
 Store a string in the buffer, which is null-terminated.
 
template<template< typename > class OffsetT = Offset>
OffsetT< StringCreateString (char *str)
 Store a string in the buffer, which is null-terminated.
 
template<template< typename > class OffsetT = Offset>
OffsetT< StringCreateString (const std::string &str)
 Store a string in the buffer, which can contain any binary data.
 
template<template< typename > class OffsetT = Offset>
OffsetT< StringCreateString (const String *str)
 Store a string in the buffer, which can contain any binary data.
 
template<template< typename > class OffsetT = Offset, int &... ExplicitArgumentBarrier, typename T >
OffsetT< StringCreateString (const T &str)
 Store a string in the buffer, which can contain any binary data.
 
Offset< StringCreateSharedString (const char *str, size_t len)
 Store a string in the buffer, which can contain any binary data. If a string with this exact contents has already been serialized before, instead simply returns the offset of the existing string. This uses a map stored on the heap, but only stores the numerical offsets.
 
Offset< StringCreateSharedString (const char *str)
 Store a string in the buffer, which null-terminated. If a string with this exact contents has already been serialized before, instead simply returns the offset of the existing string. This uses a map stored on the heap, but only stores the numerical offsets.
 
Offset< StringCreateSharedString (const std::string &str)
 Store a string in the buffer, which can contain any binary data. If a string with this exact contents has already been serialized before, instead simply returns the offset of the existing string. This uses a map stored on the heap, but only stores the numerical offsets.
 
Offset< StringCreateSharedString (const String *str)
 Store a string in the buffer, which can contain any binary data. If a string with this exact contents has already been serialized before, instead simply returns the offset of the existing string. This uses a map stored on the heap, but only stores the numerical offsets.
 
template<typename T , template< typename... > class OffsetT = Offset, template< typename... > class VectorT = Vector>
OffsetT< VectorT< T > > CreateVector (const T *v, size_t len)
 Serialize an array into a FlatBuffer vector.
 
template<typename T , class C >
Offset< Vector< T > > CreateVector (const C &array)
 Serialize an array like object into a FlatBuffer vector.
 
template<typename T >
Offset< Vector< T > > CreateVector (std::initializer_list< T > v)
 Serialize an initializer list into a FlatBuffer vector.
 
template<typename T >
Offset< Vector< Offset< T > > > CreateVector (const Offset< T > *v, size_t len)
 
template<typename T , typename Alloc = std::allocator<T>>
Offset< Vector< T > > CreateVector (const std::vector< T, Alloc > &v)
 Serialize a std::vector into a FlatBuffer vector.
 
template<template< typename... > class VectorT = Vector64, int &... ExplicitArgumentBarrier, typename T >
Offset64< VectorT< T > > CreateVector64 (const std::vector< T > &v)
 
Offset< Vector< uint8_t > > CreateVector (const std::vector< bool > &v)
 
template<typename T >
Offset< Vector< T > > CreateVector (size_t vector_size, const std::function< T(size_t i)> &f)
 Serialize values returned by a function into a FlatBuffer vector. This is a convenience function that takes care of iteration for you.
 
template<typename T , typename F , typename S >
Offset< Vector< T > > CreateVector (size_t vector_size, F f, S *state)
 Serialize values returned by a function into a FlatBuffer vector. This is a convenience function that takes care of iteration for you. This uses a vector stored on the heap to store the intermediate results of the iteration.
 
template<typename StringType = std::string, typename Alloc = std::allocator<StringType>>
Offset< Vector< Offset< String > > > CreateVectorOfStrings (const std::vector< StringType, Alloc > &v)
 Serialize a std::vector<StringType> into a FlatBuffer vector. whereas StringType is any type that is accepted by the CreateString() overloads. This is a convenience function for a common case.
 
template<class It >
Offset< Vector< Offset< String > > > CreateVectorOfStrings (It begin, It end)
 Serialize a collection of Strings into a FlatBuffer vector. This is a convenience function for a common case.
 
template<typename T , template< typename... > class OffsetT = Offset, template< typename... > class VectorT = Vector>
OffsetT< VectorT< const T * > > CreateVectorOfStructs (const T *v, size_t len)
 Serialize an array of structs into a FlatBuffer vector.
 
template<typename T >
Offset< Vector< const T * > > CreateVectorOfStructs (size_t vector_size, const std::function< void(size_t i, T *)> &filler)
 Serialize an array of structs into a FlatBuffer vector.
 
template<typename T , typename F , typename S >
Offset< Vector< const T * > > CreateVectorOfStructs (size_t vector_size, F f, S *state)
 Serialize an array of structs into a FlatBuffer vector.
 
template<typename T , template< typename... > class OffsetT = Offset, template< typename... > class VectorT = Vector, typename Alloc = std::allocator<T>>
OffsetT< VectorT< const T * > > CreateVectorOfStructs (const std::vector< T, Alloc > &v)
 Serialize a std::vector of structs into a FlatBuffer vector.
 
template<template< typename... > class VectorT = Vector64, int & ..., typename T >
Offset64< VectorT< const T * > > CreateVectorOfStructs64 (const std::vector< T > &v)
 
template<typename T , typename S >
Offset< Vector< const T * > > CreateVectorOfNativeStructs (const S *v, size_t len, T(*const pack_func)(const S &))
 Serialize an array of native structs into a FlatBuffer vector.
 
template<typename T , typename S >
Offset< Vector< const T * > > CreateVectorOfNativeStructs (const S *v, size_t len)
 Serialize an array of native structs into a FlatBuffer vector.
 
template<typename T , typename S , typename Alloc = std::allocator<T>>
Offset< Vector< const T * > > CreateVectorOfNativeStructs (const std::vector< S, Alloc > &v, T(*const pack_func)(const S &))
 Serialize a std::vector of native structs into a FlatBuffer vector.
 
template<typename T , typename S , typename Alloc = std::allocator<S>>
Offset< Vector< const T * > > CreateVectorOfNativeStructs (const std::vector< S, Alloc > &v)
 Serialize a std::vector of native structs into a FlatBuffer vector.
 
template<typename T , typename Alloc = std::allocator<T>>
Offset< Vector< const T * > > CreateVectorOfSortedStructs (std::vector< T, Alloc > *v)
 Serialize a std::vector of structs into a FlatBuffer vector in sorted order.
 
template<typename T , typename S , typename Alloc = std::allocator<T>>
Offset< Vector< const T * > > CreateVectorOfSortedNativeStructs (std::vector< S, Alloc > *v)
 Serialize a std::vector of native structs into a FlatBuffer vector in sorted order.
 
template<typename T >
Offset< Vector< const T * > > CreateVectorOfSortedStructs (T *v, size_t len)
 Serialize an array of structs into a FlatBuffer vector in sorted order.
 
template<typename T , typename S >
Offset< Vector< const T * > > CreateVectorOfSortedNativeStructs (S *v, size_t len)
 Serialize an array of native structs into a FlatBuffer vector in sorted order.
 
template<typename T >
Offset< Vector< Offset< T > > > CreateVectorOfSortedTables (Offset< T > *v, size_t len)
 Serialize an array of table offsets as a vector in the buffer in sorted order.
 
template<typename T , typename Alloc = std::allocator<T>>
Offset< Vector< Offset< T > > > CreateVectorOfSortedTables (std::vector< Offset< T >, Alloc > *v)
 Serialize an array of table offsets as a vector in the buffer in sorted order.
 
uoffset_t CreateUninitializedVector (size_t len, size_t elemsize, size_t alignment, uint8_t **buf)
 Specialized version of CreateVector for non-copying use cases. Write the data any time later to the returned buffer pointer buf.
 
uoffset_t CreateUninitializedVector (size_t len, size_t elemsize, uint8_t **buf)
 
template<typename T >
Offset< Vector< T > > CreateUninitializedVector (size_t len, T **buf)
 Specialized version of CreateVector for non-copying use cases. Write the data any time later to the returned buffer pointer buf.
 
template<typename T >
Offset< Vector< const T * > > CreateUninitializedVectorOfStructs (size_t len, T **buf)
 
template<typename T , typename U >
Offset< Vector< T > > CreateVectorScalarCast (const U *v, size_t len)
 
template<typename T >
Offset< const T * > CreateStruct (const T &structobj)
 Write a struct by itself, typically to be part of a union.
 
template<typename T >
void Finish (Offset< T > root, const char *file_identifier=nullptr)
 Finish serializing a buffer by writing the root offset.
 
template<typename T >
void FinishSizePrefixed (Offset< T > root, const char *file_identifier=nullptr)
 Finish a buffer with a 32 bit size field pre-fixed (size of the buffer following the size field). These buffers are NOT compatible with standard buffers created by Finish, i.e. you can't call GetRoot on them, you have to use GetSizePrefixedRoot instead. All >32 bit quantities in this buffer will be aligned when the whole size pre-fixed buffer is aligned. These kinds of buffers are useful for creating a stream of FlatBuffers.
 
void SwapBufAllocator (FlatBufferBuilderImpl &other)
 

Static Public Attributes

static const size_t kFileIdentifierLength
 The length of a FlatBuffer file header.
 

Protected Types

typedef std::set< Offset< String >, StringOffsetCompareStringOffsetMap
 

Protected Member Functions

 FlatBufferBuilderImpl (const FlatBufferBuilderImpl &)
 
FlatBufferBuilderImploperator= (const FlatBufferBuilderImpl &)
 
void Finish (uoffset_t root, const char *file_identifier, bool size_prefix)
 

Protected Attributes

vector_downward< SizeTbuf_
 
uoffset_t num_field_loc
 
voffset_t max_voffset_
 
size_t length_of_64_bit_region_
 
bool nested
 
bool finished
 
size_t minalign_
 
bool force_defaults_
 
bool dedup_vtables_
 
StringOffsetMapstring_pool
 

Detailed Description

template<bool Is64Aware = false>
class flatbuffers::FlatBufferBuilderImpl< Is64Aware >

Definition at line 75 of file flatbuffer_builder.h.

Member Typedef Documentation

◆ SizeT

template<bool Is64Aware = false>
typedef std::conditional<Is64Aware,uoffset64_t,uoffset_t>::type flatbuffers::FlatBufferBuilderImpl< Is64Aware >::SizeT

Definition at line 80 of file flatbuffer_builder.h.

◆ StringOffsetMap

template<bool Is64Aware = false>
typedef std::set<Offset<String>, StringOffsetCompare> flatbuffers::FlatBufferBuilderImpl< Is64Aware >::StringOffsetMap
protected

Definition at line 1329 of file flatbuffer_builder.h.

Constructor & Destructor Documentation

◆ FlatBufferBuilderImpl() [1/3]

template<bool Is64Aware = false>
flatbuffers::FlatBufferBuilderImpl< Is64Aware >::FlatBufferBuilderImpl ( size_t  initial_size = 1024,
Allocator allocator = nullptr,
bool  own_allocator = false,
size_t  buffer_minalign = AlignOf<largest_scalar_t>() 
)
inlineexplicit

Default constructor for FlatBufferBuilder.

Parameters
[in]initial_sizeThe initial size of the buffer, in bytes. Defaults to 1024.
[in]allocatorAn Allocator to use. If null will use DefaultAllocator.
[in]own_allocatorWhether the builder/vector should own the allocator. Defaults to / false.
[in]buffer_minalignForce the buffer to be aligned to the given minimum alignment upon reallocation. Only needed if you intend to store types with custom alignment AND you wish to read the buffer in-place directly after creation.

Definition at line 93 of file flatbuffer_builder.h.

97 : buf_(initial_size, allocator, own_allocator, buffer_minalign,
98 static_cast<SizeT>(Is64Aware ? FLATBUFFERS_MAX_64_BUFFER_SIZE
99 : FLATBUFFERS_MAX_BUFFER_SIZE)),
100 num_field_loc(0),
101 max_voffset_(0),
103 nested(false),
104 finished(false),
105 minalign_(1),
106 force_defaults_(false),
107 dedup_vtables_(true),
108 string_pool(nullptr) {
109 EndianCheck();
110 }
std::conditional< Is64Aware, uoffset64_t, uoffset_t >::type SizeT
src_tensor allocator() -> init(p.src_info< NHWC >())

◆ FlatBufferBuilderImpl() [2/3]

template<bool Is64Aware = false>
flatbuffers::FlatBufferBuilderImpl< Is64Aware >::FlatBufferBuilderImpl ( FlatBufferBuilderImpl< Is64Aware > &&  other)
inlinenoexcept

Move constructor for FlatBufferBuilder.

Definition at line 113 of file flatbuffer_builder.h.

114 : buf_(1024, nullptr, false, AlignOf<largest_scalar_t>(),
115 static_cast<SizeT>(Is64Aware ? FLATBUFFERS_MAX_64_BUFFER_SIZE
116 : FLATBUFFERS_MAX_BUFFER_SIZE)),
117 num_field_loc(0),
118 max_voffset_(0),
120 nested(false),
121 finished(false),
122 minalign_(1),
123 force_defaults_(false),
124 dedup_vtables_(true),
125 string_pool(nullptr) {
126 EndianCheck();
127 // Default construct and swap idiom.
128 // Lack of delegating constructors in vs2010 makes it more verbose than
129 // needed.
130 Swap(other);
131 }
void Swap(FlatBufferBuilderImpl &other)

References flatbuffers::FlatBufferBuilderImpl< Is64Aware >::Swap().

◆ ~FlatBufferBuilderImpl()

template<bool Is64Aware = false>
flatbuffers::FlatBufferBuilderImpl< Is64Aware >::~FlatBufferBuilderImpl ( )
inline

Definition at line 155 of file flatbuffer_builder.h.

155 {
156 if (string_pool) delete string_pool;
157 }

References flatbuffers::FlatBufferBuilderImpl< Is64Aware >::string_pool.

◆ FlatBufferBuilderImpl() [3/3]

template<bool Is64Aware = false>
flatbuffers::FlatBufferBuilderImpl< Is64Aware >::FlatBufferBuilderImpl ( const FlatBufferBuilderImpl< Is64Aware > &  )
protected

Member Function Documentation

◆ Clear()

◆ CreateSharedString() [1/4]

template<bool Is64Aware = false>
Offset< String > flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateSharedString ( const char *  str)
inline

Store a string in the buffer, which null-terminated. If a string with this exact contents has already been serialized before, instead simply returns the offset of the existing string. This uses a map stored on the heap, but only stores the numerical offsets.

Parameters
[in]strA const char pointer to a C-string to add to the buffer.
Returns
Returns the offset in the buffer where the string starts.

Definition at line 647 of file flatbuffer_builder.h.

647 {
648 return CreateSharedString(str, strlen(str));
649 }
Offset< String > CreateSharedString(const char *str, size_t len)
Store a string in the buffer, which can contain any binary data. If a string with this exact contents...

References flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateSharedString().

◆ CreateSharedString() [2/4]

template<bool Is64Aware = false>
Offset< String > flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateSharedString ( const char *  str,
size_t  len 
)
inline

Store a string in the buffer, which can contain any binary data. If a string with this exact contents has already been serialized before, instead simply returns the offset of the existing string. This uses a map stored on the heap, but only stores the numerical offsets.

Parameters
[in]strA const char pointer to the data to be stored as a string.
[in]lenThe number of bytes that should be stored from str.
Returns
Returns the offset in the buffer where the string starts.

Definition at line 608 of file flatbuffer_builder.h.

608 {
609 FLATBUFFERS_ASSERT(FLATBUFFERS_GENERAL_HEAP_ALLOC_OK);
610 if (!string_pool) {
611 string_pool = new StringOffsetMap(StringOffsetCompare(buf_));
612 }
613
614 const size_t size_before_string = buf_.size();
615 // Must first serialize the string, since the set is all offsets into
616 // buffer.
617 const Offset<String> off = CreateString<Offset>(str, len);
618 auto it = string_pool->find(off);
619 // If it exists we reuse existing serialized data!
620 if (it != string_pool->end()) {
621 // We can remove the string we serialized.
622 buf_.pop(buf_.size() - size_before_string);
623 return *it;
624 }
625 // Record this string for future use.
626 string_pool->insert(off);
627 return off;
628 }
#define FLATBUFFERS_ASSERT
Definition base.h:21
std::set< Offset< String >, StringOffsetCompare > StringOffsetMap
void pop(size_t bytes_to_remove)

References flatbuffers::FlatBufferBuilderImpl< Is64Aware >::buf_, FLATBUFFERS_ASSERT, flatbuffers::vector_downward< SizeT >::pop(), flatbuffers::vector_downward< SizeT >::size(), and flatbuffers::FlatBufferBuilderImpl< Is64Aware >::string_pool.

Referenced by flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateSharedString(), flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateSharedString(), and flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateSharedString().

◆ CreateSharedString() [3/4]

template<bool Is64Aware = false>
Offset< String > flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateSharedString ( const std::string &  str)
inline

Store a string in the buffer, which can contain any binary data. If a string with this exact contents has already been serialized before, instead simply returns the offset of the existing string. This uses a map stored on the heap, but only stores the numerical offsets.

Parameters
[in]strA const reference to a std::string to store in the buffer.
Returns
Returns the offset in the buffer where the string starts.

Definition at line 657 of file flatbuffer_builder.h.

657 {
658 return CreateSharedString(str.c_str(), str.length());
659 }
str
Definition infer.py:18

References flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateSharedString().

◆ CreateSharedString() [4/4]

template<bool Is64Aware = false>
Offset< String > flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateSharedString ( const String str)
inline

Store a string in the buffer, which can contain any binary data. If a string with this exact contents has already been serialized before, instead simply returns the offset of the existing string. This uses a map stored on the heap, but only stores the numerical offsets.

Parameters
[in]strA const pointer to a String struct to add to the buffer.
Returns
Returns the offset in the buffer where the string starts

Definition at line 668 of file flatbuffer_builder.h.

668 {
669 return str ? CreateSharedString(str->c_str(), str->size()) : 0;
670 }

References flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateSharedString().

◆ CreateString() [1/6]

template<bool Is64Aware = false>
template<template< typename > class OffsetT = Offset>
OffsetT< String > flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateString ( char *  str)
inline

Store a string in the buffer, which is null-terminated.

Parameters
[in]strA char pointer to a C-string to add to the buffer.
Returns
Returns the offset in the buffer where the string starts.

Definition at line 557 of file flatbuffer_builder.h.

557 {
558 return CreateString<OffsetT>(str, strlen(str));
559 }

◆ CreateString() [2/6]

template<bool Is64Aware = false>
template<template< typename > class OffsetT = Offset>
OffsetT< String > flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateString ( const char *  str)
inline

Store a string in the buffer, which is null-terminated.

Parameters
[in]strA const char pointer to a C-string to add to the buffer.
Returns
Returns the offset in the buffer where the string starts.

Definition at line 549 of file flatbuffer_builder.h.

549 {
550 return CreateString<OffsetT>(str, strlen(str));
551 }

◆ CreateString() [3/6]

template<bool Is64Aware = false>
template<template< typename > class OffsetT = Offset>
OffsetT< String > flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateString ( const char *  str,
size_t  len 
)
inline

Store a string in the buffer, which can contain any binary data.

Parameters
[in]strA const char pointer to the data to be stored as a string.
[in]lenThe number of bytes that should be stored from str.
Returns
Returns the offset in the buffer where the string starts.

Definition at line 539 of file flatbuffer_builder.h.

539 {
540 CreateStringImpl(str, len);
541 return OffsetT<String>(
542 CalculateOffset<typename OffsetT<String>::offset_type>());
543 }

Referenced by flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateVectorOfStrings(), exo::circle_detail::exportOpDefinedTensor(), and exo::tflite_detail::exportOpDefinedTensor().

◆ CreateString() [4/6]

template<bool Is64Aware = false>
template<template< typename > class OffsetT = Offset>
OffsetT< String > flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateString ( const std::string &  str)
inline

Store a string in the buffer, which can contain any binary data.

Parameters
[in]strA const reference to a std::string to store in the buffer.
Returns
Returns the offset in the buffer where the string starts.

Definition at line 565 of file flatbuffer_builder.h.

565 {
566 return CreateString<OffsetT>(str.c_str(), str.length());
567 }

◆ CreateString() [5/6]

template<bool Is64Aware = false>
template<template< typename > class OffsetT = Offset>
OffsetT< String > flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateString ( const String str)
inline

Store a string in the buffer, which can contain any binary data.

Parameters
[in]strA const pointer to a String struct to add to the buffer.
Returns
Returns the offset in the buffer where the string starts

Definition at line 585 of file flatbuffer_builder.h.

585 {
586 return str ? CreateString<OffsetT>(str->c_str(), str->size()) : 0;
587 }

◆ CreateString() [6/6]

template<bool Is64Aware = false>
template<template< typename > class OffsetT = Offset, int &... ExplicitArgumentBarrier, typename T >
OffsetT< String > flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateString ( const T &  str)
inline

Store a string in the buffer, which can contain any binary data.

Parameters
[in]strA const reference to a std::string like type with support of T::c_str() and T::length() to store in the buffer.
Returns
Returns the offset in the buffer where the string starts.

Definition at line 597 of file flatbuffer_builder.h.

597 {
598 return CreateString<OffsetT>(str.c_str(), str.length());
599 }

◆ CreateStruct()

template<bool Is64Aware = false>
template<typename T >
Offset< const T * > flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateStruct ( const T &  structobj)
inline

Write a struct by itself, typically to be part of a union.

Definition at line 1204 of file flatbuffer_builder.h.

1204 {
1205 NotNested();
1206 Align(AlignOf<T>());
1207 buf_.push_small(structobj);
1208 return Offset<const T *>(
1209 CalculateOffset<typename Offset<const T *>::offset_type>());
1210 }
void push_small(const T &little_endian_t)

References flatbuffers::FlatBufferBuilderImpl< Is64Aware >::buf_, and flatbuffers::vector_downward< SizeT >::push_small().

◆ CreateUninitializedVector() [1/3]

template<bool Is64Aware = false>
uoffset_t flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateUninitializedVector ( size_t  len,
size_t  elemsize,
size_t  alignment,
uint8_t **  buf 
)
inline

Specialized version of CreateVector for non-copying use cases. Write the data any time later to the returned buffer pointer buf.

Parameters
[in]lenThe number of elements to store in the vector.
[in]elemsizeThe size of each element in the vector.
[out]bufA pointer to a uint8_t pointer that can be written to at a later time to serialize the data into a vector in the buffer.

Definition at line 1152 of file flatbuffer_builder.h.

1153 {
1154 NotNested();
1155 StartVector(len, elemsize, alignment);
1156 buf_.make_space(len * elemsize);
1157 const uoffset_t vec_start = GetSizeRelative32BitRegion();
1158 auto vec_end = EndVector(len);
1159 *buf = buf_.data_at(vec_start);
1160 return vec_end;
1161 }
std::enable_if< is_64, uoffset_t >::type GetSizeRelative32BitRegion() const
The current size of the serialized buffer relative to the end of the 32-bit region.
uint8_t * make_space(size_t len)
uint8_t * data_at(size_t offset) const

References flatbuffers::FlatBufferBuilderImpl< Is64Aware >::buf_, flatbuffers::vector_downward< SizeT >::data_at(), flatbuffers::FlatBufferBuilderImpl< Is64Aware >::GetSizeRelative32BitRegion(), and flatbuffers::vector_downward< SizeT >::make_space().

Referenced by flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateUninitializedVector(), flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateUninitializedVector(), and flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateUninitializedVectorOfStructs().

◆ CreateUninitializedVector() [2/3]

template<bool Is64Aware = false>
uoffset_t flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateUninitializedVector ( size_t  len,
size_t  elemsize,
uint8_t **  buf 
)
inline

Definition at line 1164 of file flatbuffer_builder.h.

1165 {
1166 return CreateUninitializedVector(len, elemsize, elemsize, buf);
1167 }
uoffset_t CreateUninitializedVector(size_t len, size_t elemsize, size_t alignment, uint8_t **buf)
Specialized version of CreateVector for non-copying use cases. Write the data any time later to the r...

References flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateUninitializedVector().

◆ CreateUninitializedVector() [3/3]

template<bool Is64Aware = false>
template<typename T >
Offset< Vector< T > > flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateUninitializedVector ( size_t  len,
T **  buf 
)
inline

Specialized version of CreateVector for non-copying use cases. Write the data any time later to the returned buffer pointer buf.

Template Parameters
TThe data type of the data that will be stored in the buffer as a vector.
Parameters
[in]lenThe number of elements to store in the vector.
[out]bufA pointer to a pointer of type T that can be written to at a later time to serialize the data into a vector in the buffer.

Definition at line 1178 of file flatbuffer_builder.h.

1178 {
1179 AssertScalarT<T>();
1180 return CreateUninitializedVector(len, sizeof(T), AlignOf<T>(),
1181 reinterpret_cast<uint8_t **>(buf));
1182 }

References flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateUninitializedVector().

◆ CreateUninitializedVectorOfStructs()

template<bool Is64Aware = false>
template<typename T >
Offset< Vector< const T * > > flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateUninitializedVectorOfStructs ( size_t  len,
T **  buf 
)
inline

Definition at line 1185 of file flatbuffer_builder.h.

1186 {
1187 return CreateUninitializedVector(len, sizeof(T), AlignOf<T>(),
1188 reinterpret_cast<uint8_t **>(buf));
1189 }

References flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateUninitializedVector().

◆ CreateVector() [1/8]

template<bool Is64Aware = false>
template<typename T , class C >
Offset< Vector< T > > flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateVector ( const C &  array)
inline

Serialize an array like object into a FlatBuffer vector.

Template Parameters
TThe data type of the array elements.
CThe type of the array.
Parameters
[in]arrayA reference to an array like object of type T to serialize into the buffer as a vector.
Returns
Returns a typed Offset into the serialized data indicating where the vector is stored.

Definition at line 760 of file flatbuffer_builder.h.

760 {
761 return CreateVector(array.data(), array.size());
762 }
OffsetT< VectorT< T > > CreateVector(const T *v, size_t len)
Serialize an array into a FlatBuffer vector.

References flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateVector().

◆ CreateVector() [2/8]

template<bool Is64Aware = false>
template<typename T >
Offset< Vector< Offset< T > > > flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateVector ( const Offset< T > *  v,
size_t  len 
)
inline

Definition at line 775 of file flatbuffer_builder.h.

775 {
776 StartVector<Offset<T>>(len);
777 for (auto i = len; i > 0;) { PushElement(v[--i]); }
778 return Offset<Vector<Offset<T>>>(EndVector(len));
779 }

◆ CreateVector() [3/8]

template<bool Is64Aware = false>
Offset< Vector< uint8_t > > flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateVector ( const std::vector< bool > &  v)
inline

Definition at line 801 of file flatbuffer_builder.h.

801 {
802 StartVector<uint8_t>(v.size());
803 for (auto i = v.size(); i > 0;) {
804 PushElement(static_cast<uint8_t>(v[--i]));
805 }
806 return Offset<Vector<uint8_t>>(EndVector(v.size()));
807 }

◆ CreateVector() [4/8]

template<bool Is64Aware = false>
template<typename T , typename Alloc = std::allocator<T>>
Offset< Vector< T > > flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateVector ( const std::vector< T, Alloc > &  v)
inline

Serialize a std::vector into a FlatBuffer vector.

Template Parameters
TThe data type of the std::vector elements.
Parameters
vA const reference to the std::vector to serialize into the buffer as a vector.
Returns
Returns a typed Offset into the serialized data indicating where the vector is stored.

Definition at line 788 of file flatbuffer_builder.h.

788 {
789 return CreateVector(data(v), v.size());
790 }
const T * data(const std::vector< T, Alloc > &v)

References flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateVector(), and flatbuffers::data().

◆ CreateVector() [5/8]

template<bool Is64Aware = false>
template<typename T , template< typename... > class OffsetT = Offset, template< typename... > class VectorT = Vector>
OffsetT< VectorT< T > > flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateVector ( const T *  v,
size_t  len 
)
inline

Serialize an array into a FlatBuffer vector.

Template Parameters
TThe data type of the array elements.
OffsetTthe type of offset to return
VectorTthe type of vector to cast to.
Parameters
[in]vA pointer to the array of type T to serialize into the buffer as a vector.
[in]lenThe number of elements to serialize.
Returns
Returns a typed TOffset into the serialized data indicating where the vector is stored.

Definition at line 727 of file flatbuffer_builder.h.

727 {
728 // The type of the length field in the vector.
729 typedef typename VectorT<T>::size_type LenT;
730 typedef typename OffsetT<VectorT<T>>::offset_type offset_type;
731 // If this assert hits, you're specifying a template argument that is
732 // causing the wrong overload to be selected, remove it.
733 AssertScalarT<T>();
734 StartVector<T, OffsetT, LenT>(len);
735 if (len > 0) {
736 // clang-format off
737 #if FLATBUFFERS_LITTLEENDIAN
738 PushBytes(reinterpret_cast<const uint8_t *>(v), len * sizeof(T));
739 #else
740 if (sizeof(T) == 1) {
741 PushBytes(reinterpret_cast<const uint8_t *>(v), len);
742 } else {
743 for (auto i = len; i > 0; ) {
744 PushElement(v[--i]);
745 }
746 }
747 #endif
748 // clang-format on
749 }
750 return OffsetT<VectorT<T>>(EndVector<LenT, offset_type>(len));
751 }

Referenced by as_tflite_sparse_index_vec(), tflite2circle::build_circle_ReshapeOptions(), tflite2circle::build_circle_SqueezeOptions(), flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateVector(), flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateVector(), flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateVector(), flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateVector(), flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateVector(), flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateVectorOfSortedTables(), AddV2Chef::custom_value(), AllChef::custom_value(), BatchMatMulV2Chef::custom_value(), BroadcastToChef::custom_value(), ErfChef::custom_value(), MatMulChef::custom_value(), MatrixBandPartChef::custom_value(), MaxPoolWithArgmaxChef::custom_value(), tflite2circle::get_circle_sparse_index_vector(), ReshapeChef::value(), SqueezeChef::value(), luci::OperationExporterRule::visit(), luci::BuiltinOptionsExtractor::visit(), and luci::BuiltinOptionsExtractor::visit().

◆ CreateVector() [6/8]

template<bool Is64Aware = false>
template<typename T >
Offset< Vector< T > > flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateVector ( size_t  vector_size,
const std::function< T(size_t i)> &  f 
)
inline

Serialize values returned by a function into a FlatBuffer vector. This is a convenience function that takes care of iteration for you.

Template Parameters
TThe data type of the std::vector elements.
Parameters
fA function that takes the current iteration 0..vector_size-1 and returns any type that you can construct a FlatBuffers vector out of.
Returns
Returns a typed Offset into the serialized data indicating where the vector is stored.

Definition at line 817 of file flatbuffer_builder.h.

818 {
819 FLATBUFFERS_ASSERT(FLATBUFFERS_GENERAL_HEAP_ALLOC_OK);
820 std::vector<T> elems(vector_size);
821 for (size_t i = 0; i < vector_size; i++) elems[i] = f(i);
822 return CreateVector(elems);
823 }

References flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateVector(), and FLATBUFFERS_ASSERT.

◆ CreateVector() [7/8]

template<bool Is64Aware = false>
template<typename T , typename F , typename S >
Offset< Vector< T > > flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateVector ( size_t  vector_size,
f,
S state 
)
inline

Serialize values returned by a function into a FlatBuffer vector. This is a convenience function that takes care of iteration for you. This uses a vector stored on the heap to store the intermediate results of the iteration.

Template Parameters
TThe data type of the std::vector elements.
Parameters
fA function that takes the current iteration 0..vector_size-1, and the state parameter returning any type that you can construct a FlatBuffers vector out of.
stateState passed to f.
Returns
Returns a typed Offset into the serialized data indicating where the vector is stored.

Definition at line 837 of file flatbuffer_builder.h.

837 {
838 FLATBUFFERS_ASSERT(FLATBUFFERS_GENERAL_HEAP_ALLOC_OK);
839 std::vector<T> elems(vector_size);
840 for (size_t i = 0; i < vector_size; i++) elems[i] = f(i, state);
841 return CreateVector(elems);
842 }

References flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateVector(), and FLATBUFFERS_ASSERT.

◆ CreateVector() [8/8]

template<bool Is64Aware = false>
template<typename T >
Offset< Vector< T > > flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateVector ( std::initializer_list< T >  v)
inline

Serialize an initializer list into a FlatBuffer vector.

Template Parameters
TThe data type of the initializer list elements.
Parameters
[in]vThe value of the initializer list.
Returns
Returns a typed Offset into the serialized data indicating where the vector is stored.

Definition at line 770 of file flatbuffer_builder.h.

770 {
771 return CreateVector(v.begin(), v.size());
772 }

References flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateVector().

◆ CreateVector64()

template<bool Is64Aware = false>
template<template< typename... > class VectorT = Vector64, int &... ExplicitArgumentBarrier, typename T >
Offset64< VectorT< T > > flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateVector64 ( const std::vector< T > &  v)
inline

Definition at line 794 of file flatbuffer_builder.h.

794 {
795 return CreateVector<T, Offset64, VectorT>(data(v), v.size());
796 }

References flatbuffers::data().

◆ CreateVectorOfNativeStructs() [1/4]

template<bool Is64Aware = false>
template<typename T , typename S >
Offset< Vector< const T * > > flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateVectorOfNativeStructs ( const S v,
size_t  len 
)
inline

Serialize an array of native structs into a FlatBuffer vector.

Template Parameters
TThe data type of the struct array elements.
SThe data type of the native struct array elements.
Parameters
[in]vA pointer to the array of type S to serialize into the buffer as a vector.
[in]lenThe number of elements to serialize.
Returns
Returns a typed Offset into the serialized data indicating where the vector is stored.

Definition at line 996 of file flatbuffer_builder.h.

997 {
998 extern T Pack(const S &);
999 return CreateVectorOfNativeStructs(v, len, Pack);
1000 }
#define S(content)
Definition Subnet.cpp:30
Offset< Vector< const T * > > CreateVectorOfNativeStructs(const S *v, size_t len, T(*const pack_func)(const S &))
Serialize an array of native structs into a FlatBuffer vector.
void Pack(const PackParams &params, const Scalar *const *input_data, const Shape &output_shape, Scalar *output_data)
Definition Pack.h:30

References flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateVectorOfNativeStructs(), and S.

◆ CreateVectorOfNativeStructs() [2/4]

template<bool Is64Aware = false>
template<typename T , typename S >
Offset< Vector< const T * > > flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateVectorOfNativeStructs ( const S v,
size_t  len,
T(*)(const S &)  pack_func 
)
inline

Serialize an array of native structs into a FlatBuffer vector.

Template Parameters
TThe data type of the struct array elements.
SThe data type of the native struct array elements.
Parameters
[in]vA pointer to the array of type S to serialize into the buffer as a vector.
[in]lenThe number of elements to serialize.
[in]pack_funcPointer to a function to convert the native struct to the FlatBuffer struct.
Returns
Returns a typed Offset into the serialized data indicating where the vector is stored.

Definition at line 979 of file flatbuffer_builder.h.

980 {
981 FLATBUFFERS_ASSERT(pack_func);
982 auto structs = StartVectorOfStructs<T>(len);
983 for (size_t i = 0; i < len; i++) { structs[i] = pack_func(v[i]); }
984 return EndVectorOfStructs<T>(len);
985 }

References FLATBUFFERS_ASSERT.

Referenced by flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateVectorOfNativeStructs().

◆ CreateVectorOfNativeStructs() [3/4]

template<bool Is64Aware = false>
template<typename T , typename S , typename Alloc = std::allocator<S>>
Offset< Vector< const T * > > flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateVectorOfNativeStructs ( const std::vector< S, Alloc > &  v)
inline

Serialize a std::vector of native structs into a FlatBuffer vector.

Template Parameters
TThe data type of the std::vector struct elements.
SThe data type of the std::vector native struct elements.
Parameters
[in]vA const reference to the std::vector of structs to serialize into the buffer as a vector.
Returns
Returns a typed Offset into the serialized data indicating where the vector is stored.

Definition at line 1027 of file flatbuffer_builder.h.

1028 {
1029 return CreateVectorOfNativeStructs<T, S>(data(v), v.size());
1030 }

References flatbuffers::data().

◆ CreateVectorOfNativeStructs() [4/4]

template<bool Is64Aware = false>
template<typename T , typename S , typename Alloc = std::allocator<T>>
Offset< Vector< const T * > > flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateVectorOfNativeStructs ( const std::vector< S, Alloc > &  v,
T(*)(const S &)  pack_func 
)
inline

Serialize a std::vector of native structs into a FlatBuffer vector.

Template Parameters
TThe data type of the std::vector struct elements.
SThe data type of the std::vector native struct elements.
Parameters
[in]vA const reference to the std::vector of structs to serialize into the buffer as a vector.
[in]pack_funcPointer to a function to convert the native struct to the FlatBuffer struct.
Returns
Returns a typed Offset into the serialized data indicating where the vector is stored.

Definition at line 1013 of file flatbuffer_builder.h.

1014 {
1015 return CreateVectorOfNativeStructs<T, S>(data(v), v.size(), pack_func);
1016 }

References flatbuffers::data().

◆ CreateVectorOfSortedNativeStructs() [1/2]

template<bool Is64Aware = false>
template<typename T , typename S >
Offset< Vector< const T * > > flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateVectorOfSortedNativeStructs ( S v,
size_t  len 
)
inline

Serialize an array of native structs into a FlatBuffer vector in sorted order.

Template Parameters
TThe data type of the struct array elements.
SThe data type of the native struct array elements.
Parameters
[in]vA pointer to the array of type S to serialize into the buffer as a vector.
[in]lenThe number of elements to serialize.
Returns
Returns a typed Offset into the serialized data indicating where the vector is stored.

Definition at line 1091 of file flatbuffer_builder.h.

1092 {
1093 extern T Pack(const S &);
1094 auto structs = StartVectorOfStructs<T>(len);
1095 for (size_t i = 0; i < len; i++) { structs[i] = Pack(v[i]); }
1096 std::stable_sort(structs, structs + len, StructKeyComparator<T>());
1097 return EndVectorOfStructs<T>(len);
1098 }

References S.

◆ CreateVectorOfSortedNativeStructs() [2/2]

template<bool Is64Aware = false>
template<typename T , typename S , typename Alloc = std::allocator<T>>
Offset< Vector< const T * > > flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateVectorOfSortedNativeStructs ( std::vector< S, Alloc > *  v)
inline

Serialize a std::vector of native structs into a FlatBuffer vector in sorted order.

Template Parameters
TThe data type of the std::vector struct elements.
SThe data type of the std::vector native struct elements.
Parameters
[in]vA const reference to the std::vector of structs to serialize into the buffer as a vector.
Returns
Returns a typed Offset into the serialized data indicating where the vector is stored.

Definition at line 1062 of file flatbuffer_builder.h.

1063 {
1064 return CreateVectorOfSortedNativeStructs<T, S>(data(*v), v->size());
1065 }

References flatbuffers::data().

◆ CreateVectorOfSortedStructs() [1/2]

template<bool Is64Aware = false>
template<typename T , typename Alloc = std::allocator<T>>
Offset< Vector< const T * > > flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateVectorOfSortedStructs ( std::vector< T, Alloc > *  v)
inline

Serialize a std::vector of structs into a FlatBuffer vector in sorted order.

Template Parameters
TThe data type of the std::vector struct elements.
Parameters
[in]vA const reference to the std::vector of structs to serialize into the buffer as a vector.
Returns
Returns a typed Offset into the serialized data indicating where the vector is stored.

Definition at line 1048 of file flatbuffer_builder.h.

1049 {
1050 return CreateVectorOfSortedStructs(data(*v), v->size());
1051 }
Offset< Vector< const T * > > CreateVectorOfSortedStructs(std::vector< T, Alloc > *v)
Serialize a std::vector of structs into a FlatBuffer vector in sorted order.

References flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateVectorOfSortedStructs(), and flatbuffers::data().

Referenced by flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateVectorOfSortedStructs().

◆ CreateVectorOfSortedStructs() [2/2]

template<bool Is64Aware = false>
template<typename T >
Offset< Vector< const T * > > flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateVectorOfSortedStructs ( T *  v,
size_t  len 
)
inline

Serialize an array of structs into a FlatBuffer vector in sorted order.

Template Parameters
TThe data type of the struct array elements.
Parameters
[in]vA pointer to the array of type T to serialize into the buffer as a vector.
[in]lenThe number of elements to serialize.
Returns
Returns a typed Offset into the serialized data indicating where the vector is stored.

Definition at line 1076 of file flatbuffer_builder.h.

1076 {
1077 std::stable_sort(v, v + len, StructKeyComparator<T>());
1078 return CreateVectorOfStructs(v, len);
1079 }
OffsetT< VectorT< const T * > > CreateVectorOfStructs(const T *v, size_t len)
Serialize an array of structs into a FlatBuffer vector.

References flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateVectorOfStructs().

◆ CreateVectorOfSortedTables() [1/2]

template<bool Is64Aware = false>
template<typename T >
Offset< Vector< Offset< T > > > flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateVectorOfSortedTables ( Offset< T > *  v,
size_t  len 
)
inline

Serialize an array of table offsets as a vector in the buffer in sorted order.

Template Parameters
TThe data type that the offset refers to.
Parameters
[in]vAn array of type Offset<T> that contains the table offsets to store in the buffer in sorted order.
[in]lenThe number of elements to store in the vector.
Returns
Returns a typed Offset into the serialized data indicating where the vector is stored.

Definition at line 1126 of file flatbuffer_builder.h.

1127 {
1128 std::stable_sort(v, v + len, TableKeyComparator<T>(buf_));
1129 return CreateVector(v, len);
1130 }

References flatbuffers::FlatBufferBuilderImpl< Is64Aware >::buf_, and flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateVector().

Referenced by flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateVectorOfSortedTables().

◆ CreateVectorOfSortedTables() [2/2]

template<bool Is64Aware = false>
template<typename T , typename Alloc = std::allocator<T>>
Offset< Vector< Offset< T > > > flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateVectorOfSortedTables ( std::vector< Offset< T >, Alloc > *  v)
inline

Serialize an array of table offsets as a vector in the buffer in sorted order.

Template Parameters
TThe data type that the offset refers to.
Parameters
[in]vAn array of type Offset<T> that contains the table offsets to store in the buffer in sorted order.
Returns
Returns a typed Offset into the serialized data indicating where the vector is stored.

Definition at line 1140 of file flatbuffer_builder.h.

1141 {
1142 return CreateVectorOfSortedTables(data(*v), v->size());
1143 }
Offset< Vector< Offset< T > > > CreateVectorOfSortedTables(Offset< T > *v, size_t len)
Serialize an array of table offsets as a vector in the buffer in sorted order.

References flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateVectorOfSortedTables(), and flatbuffers::data().

◆ CreateVectorOfStrings() [1/2]

template<bool Is64Aware = false>
template<typename StringType = std::string, typename Alloc = std::allocator<StringType>>
Offset< Vector< Offset< String > > > flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateVectorOfStrings ( const std::vector< StringType, Alloc > &  v)
inline

Serialize a std::vector<StringType> into a FlatBuffer vector. whereas StringType is any type that is accepted by the CreateString() overloads. This is a convenience function for a common case.

Parameters
vA const reference to the std::vector to serialize into the buffer as a vector.
Returns
Returns a typed Offset into the serialized data indicating where the vector is stored.

Definition at line 854 of file flatbuffer_builder.h.

855 {
856 return CreateVectorOfStrings(v.cbegin(), v.cend());
857 }
Offset< Vector< Offset< String > > > CreateVectorOfStrings(const std::vector< StringType, Alloc > &v)
Serialize a std::vector<StringType> into a FlatBuffer vector. whereas StringType is any type that is ...

References flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateVectorOfStrings().

Referenced by flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateVectorOfStrings().

◆ CreateVectorOfStrings() [2/2]

template<bool Is64Aware = false>
template<class It >
Offset< Vector< Offset< String > > > flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateVectorOfStrings ( It  begin,
It  end 
)
inline

Serialize a collection of Strings into a FlatBuffer vector. This is a convenience function for a common case.

Parameters
beginThe beginning iterator of the collection
endThe ending iterator of the collection
Returns
Returns a typed Offset into the serialized data indicating where the vector is stored.

Definition at line 866 of file flatbuffer_builder.h.

866 {
867 auto size = std::distance(begin, end);
868 auto scratch_buffer_usage = size * sizeof(Offset<String>);
869 // If there is not enough space to store the offsets, there definitely won't
870 // be enough space to store all the strings. So ensuring space for the
871 // scratch region is OK, for if it fails, it would have failed later.
872 buf_.ensure_space(scratch_buffer_usage);
873 for (auto it = begin; it != end; ++it) {
875 }
876 StartVector<Offset<String>>(size);
877 for (auto i = 1; i <= size; i++) {
878 // Note we re-evaluate the buf location each iteration to account for any
879 // underlying buffer resizing that may occur.
880 PushElement(*reinterpret_cast<Offset<String> *>(
881 buf_.scratch_end() - i * sizeof(Offset<String>)));
882 }
883 buf_.scratch_pop(scratch_buffer_usage);
884 return Offset<Vector<Offset<String>>>(EndVector(size));
885 }
OffsetT< String > CreateString(const char *str, size_t len)
Store a string in the buffer, which can contain any binary data.
void scratch_pop(size_t bytes_to_remove)
void scratch_push_small(const T &t)
size_t ensure_space(size_t len)
ShapeIterator end(const Shape &s)
int32_t size[5]
Definition Slice.cpp:35
int32_t begin[5]
Definition Slice.cpp:33

References begin, flatbuffers::FlatBufferBuilderImpl< Is64Aware >::buf_, flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateString(), flatbuffers::vector_downward< SizeT >::ensure_space(), flatbuffers::vector_downward< SizeT >::scratch_end(), flatbuffers::vector_downward< SizeT >::scratch_pop(), flatbuffers::vector_downward< SizeT >::scratch_push_small(), and size.

◆ CreateVectorOfStructs() [1/4]

template<bool Is64Aware = false>
template<typename T , template< typename... > class OffsetT = Offset, template< typename... > class VectorT = Vector, typename Alloc = std::allocator<T>>
OffsetT< VectorT< const T * > > flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateVectorOfStructs ( const std::vector< T, Alloc > &  v)
inline

Serialize a std::vector of structs into a FlatBuffer vector.

Template Parameters
TThe data type of the std::vector struct elements.
Parameters
[in]vA const reference to the std::vector of structs to serialize into the buffer as a vector.
Returns
Returns a typed Offset into the serialized data indicating where the vector is stored.

Definition at line 957 of file flatbuffer_builder.h.

958 {
959 return CreateVectorOfStructs<T, OffsetT, VectorT>(data(v), v.size());
960 }

References flatbuffers::data().

◆ CreateVectorOfStructs() [2/4]

template<bool Is64Aware = false>
template<typename T , template< typename... > class OffsetT = Offset, template< typename... > class VectorT = Vector>
OffsetT< VectorT< const T * > > flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateVectorOfStructs ( const T *  v,
size_t  len 
)
inline

Serialize an array of structs into a FlatBuffer vector.

Template Parameters
TThe data type of the struct array elements.
Parameters
[in]vA pointer to the array of type T to serialize into the buffer as a vector.
[in]lenThe number of elements to serialize.
Returns
Returns a typed Offset into the serialized data indicating where the vector is stored.

Definition at line 896 of file flatbuffer_builder.h.

896 {
897 // The type of the length field in the vector.
898 typedef typename VectorT<T>::size_type LenT;
899 typedef typename OffsetT<VectorT<const T *>>::offset_type offset_type;
900
901 StartVector<OffsetT, LenT>(len * sizeof(T) / AlignOf<T>(), sizeof(T),
902 AlignOf<T>());
903 if (len > 0) {
904 PushBytes(reinterpret_cast<const uint8_t *>(v), sizeof(T) * len);
905 }
906 return OffsetT<VectorT<const T *>>(EndVector<LenT, offset_type>(len));
907 }

Referenced by flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateVectorOfSortedStructs().

◆ CreateVectorOfStructs() [3/4]

template<bool Is64Aware = false>
template<typename T >
Offset< Vector< const T * > > flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateVectorOfStructs ( size_t  vector_size,
const std::function< void(size_t i, T *)> &  filler 
)
inline

Serialize an array of structs into a FlatBuffer vector.

Template Parameters
TThe data type of the struct array elements.
Parameters
[in]fillerA function that takes the current iteration 0..vector_size-1 and a pointer to the struct that must be filled.
Returns
Returns a typed Offset into the serialized data indicating where the vector is stored. This is mostly useful when flatbuffers are generated with mutation accessors.

Definition at line 918 of file flatbuffer_builder.h.

919 {
920 T *structs = StartVectorOfStructs<T>(vector_size);
921 for (size_t i = 0; i < vector_size; i++) {
922 filler(i, structs);
923 structs++;
924 }
925 return EndVectorOfStructs<T>(vector_size);
926 }

◆ CreateVectorOfStructs() [4/4]

template<bool Is64Aware = false>
template<typename T , typename F , typename S >
Offset< Vector< const T * > > flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateVectorOfStructs ( size_t  vector_size,
f,
S state 
)
inline

Serialize an array of structs into a FlatBuffer vector.

Template Parameters
TThe data type of the struct array elements.
Parameters
[in]fA function that takes the current iteration 0..vector_size-1, a pointer to the struct that must be filled and the state argument.
[in]stateArbitrary state to pass to f.
Returns
Returns a typed Offset into the serialized data indicating where the vector is stored. This is mostly useful when flatbuffers are generated with mutation accessors.

Definition at line 938 of file flatbuffer_builder.h.

939 {
940 T *structs = StartVectorOfStructs<T>(vector_size);
941 for (size_t i = 0; i < vector_size; i++) {
942 f(i, structs, state);
943 structs++;
944 }
945 return EndVectorOfStructs<T>(vector_size);
946 }

◆ CreateVectorOfStructs64()

template<bool Is64Aware = false>
template<template< typename... > class VectorT = Vector64, int & ..., typename T >
Offset64< VectorT< const T * > > flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateVectorOfStructs64 ( const std::vector< T > &  v)
inline

Definition at line 963 of file flatbuffer_builder.h.

964 {
965 return CreateVectorOfStructs<T, Offset64, VectorT>(data(v), v.size());
966 }

References flatbuffers::data().

◆ CreateVectorScalarCast()

template<bool Is64Aware = false>
template<typename T , typename U >
Offset< Vector< T > > flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateVectorScalarCast ( const U *  v,
size_t  len 
)
inline

Definition at line 1195 of file flatbuffer_builder.h.

1195 {
1196 AssertScalarT<T>();
1197 AssertScalarT<U>();
1198 StartVector<T>(len);
1199 for (auto i = len; i > 0;) { PushElement(static_cast<T>(v[--i])); }
1200 return Offset<Vector<T>>(EndVector(len));
1201 }

◆ DedupVtables()

template<bool Is64Aware = false>
void flatbuffers::FlatBufferBuilderImpl< Is64Aware >::DedupVtables ( bool  dedup)
inline

By default vtables are deduped in order to save space.

Parameters
[in]dedupWhen set to true, dedup vtables.

Definition at line 284 of file flatbuffer_builder.h.

284{ dedup_vtables_ = dedup; }

References flatbuffers::FlatBufferBuilderImpl< Is64Aware >::dedup_vtables_.

◆ Finish() [1/2]

template<bool Is64Aware = false>
template<typename T >
void flatbuffers::FlatBufferBuilderImpl< Is64Aware >::Finish ( Offset< T >  root,
const char *  file_identifier = nullptr 
)
inline

Finish serializing a buffer by writing the root offset.

Parameters
[in]file_identifierIf a file_identifier is given, the buffer will be prefixed with a standard FlatBuffers file header.

Definition at line 1216 of file flatbuffer_builder.h.

1216 {
1217 Finish(root.o, file_identifier, false);
1218 }
void Finish(Offset< T > root, const char *file_identifier=nullptr)
Finish serializing a buffer by writing the root offset.
Op * root(Op *)
Return the root Op from a given Op node.
Definition Op.cpp:144

References flatbuffers::FlatBufferBuilderImpl< Is64Aware >::Finish().

Referenced by tflite2circle::build_circle_AbsOptions(), tflite2circle::build_circle_AddNOptions(), tflite2circle::build_circle_AddOptions(), tflite2circle::build_circle_ArgMaxOptions(), tflite2circle::build_circle_ArgMinOptions(), tflite2circle::build_circle_BatchMatMulOptions(), tflite2circle::build_circle_BatchToSpaceNDOptions(), tflite2circle::build_circle_BidirectionalSequenceLSTMOptions(), tflite2circle::build_circle_BroadcastToOptions(), tflite2circle::build_circle_CastOptions(), tflite2circle::build_circle_ConcatenationOptions(), tflite2circle::build_circle_Conv2DOptions(), tflite2circle::build_circle_CosOptions(), tflite2circle::build_circle_CumsumOptions(), tflite2circle::build_circle_DensifyOptions(), tflite2circle::build_circle_DepthToSpaceOptions(), tflite2circle::build_circle_DepthwiseConv2DOptions(), tflite2circle::build_circle_DequantizeOptions(), tflite2circle::build_circle_DivOptions(), tflite2circle::build_circle_EqualOptions(), tflite2circle::build_circle_ExpandDimsOptions(), tflite2circle::build_circle_ExpOptions(), tflite2circle::build_circle_FakeQuantOptions(), tflite2circle::build_circle_FillOptions(), tflite2circle::build_circle_FloorDivOptions(), tflite2circle::build_circle_FloorModOptions(), tflite2circle::build_circle_FullyConnectedOptions(), tflite2circle::build_circle_GatherNdOptions(), tflite2circle::build_circle_GatherOptions(), tflite2circle::build_circle_GeluOptions(), tflite2circle::build_circle_GreaterEqualOptions(), tflite2circle::build_circle_GreaterOptions(), tflite2circle::build_circle_IfOptions(), tflite2circle::build_circle_L2NormOptions(), tflite2circle::build_circle_LeakyReluOptions(), tflite2circle::build_circle_LessEqualOptions(), tflite2circle::build_circle_LessOptions(), tflite2circle::build_circle_LocalResponseNormalizationOptions(), tflite2circle::build_circle_LogicalAndOptions(), tflite2circle::build_circle_LogicalNotOptions(), tflite2circle::build_circle_LogicalOrOptions(), tflite2circle::build_circle_LogSoftmaxOptions(), tflite2circle::build_circle_MatrixDiagOptions(), tflite2circle::build_circle_MatrixSetDiagOptions(), tflite2circle::build_circle_MaximumMinimumOptions(), tflite2circle::build_circle_MirrorPadOptions(), tflite2circle::build_circle_MulOptions(), tflite2circle::build_circle_NegOptions(), tflite2circle::build_circle_NonMaxSuppressionV4Options(), tflite2circle::build_circle_NonMaxSuppressionV5Options(), tflite2circle::build_circle_NotEqualOptions(), tflite2circle::build_circle_OneHotOptions(), tflite2circle::build_circle_PackOptions(), tflite2circle::build_circle_PadOptions(), tflite2circle::build_circle_PadV2Options(), tflite2circle::build_circle_Pool2DOptions(), tflite2circle::build_circle_PowOptions(), tflite2circle::build_circle_RangeOptions(), tflite2circle::build_circle_RankOptions(), tflite2circle::build_circle_ReducerOptions(), tflite2circle::build_circle_ReshapeOptions(), tflite2circle::build_circle_ResizeBilinearOptions(), tflite2circle::build_circle_ResizeNearestNeighborOptions(), tflite2circle::build_circle_ReverseSequenceOptions(), tflite2circle::build_circle_ReverseV2Options(), tflite2circle::build_circle_ScatterNdOptions(), tflite2circle::build_circle_SegmentSumOptions(), tflite2circle::build_circle_SelectOptions(), tflite2circle::build_circle_SelectV2Options(), tflite2circle::build_circle_ShapeOptions(), tflite2circle::build_circle_SliceOptions(), tflite2circle::build_circle_SoftmaxOptions(), tflite2circle::build_circle_SpaceToBatchNDOptions(), tflite2circle::build_circle_SpaceToDepthOptions(), tflite2circle::build_circle_SparseToDenseOptions(), tflite2circle::build_circle_SplitOptions(), tflite2circle::build_circle_SplitVOptions(), tflite2circle::build_circle_SquaredDifferenceOptions(), tflite2circle::build_circle_SquareOptions(), tflite2circle::build_circle_SqueezeOptions(), tflite2circle::build_circle_StridedSliceOptions(), tflite2circle::build_circle_SubOptions(), tflite2circle::build_circle_SVDFOptions(), tflite2circle::build_circle_TileOptions(), tflite2circle::build_circle_TopKV2Options(), tflite2circle::build_circle_TransposeConvOptions(), tflite2circle::build_circle_TransposeOptions(), tflite2circle::build_circle_UnidirectionalSequenceLSTMOptions(), tflite2circle::build_circle_UniqueOptions(), tflite2circle::build_circle_UnpackOptions(), tflite2circle::build_circle_WhereOptions(), tflite2circle::build_circle_WhileOptions(), tflite2circle::build_circle_ZerosLikeOptions(), flatbuffers::FlatBufferBuilderImpl< Is64Aware >::Finish(), flatbuffers::FlatBufferBuilderImpl< Is64Aware >::FinishSizePrefixed(), tflite2circle::get_circle_sparse_index_vector(), onert::exporter::TrainInfoBuilder::TrainInfoBuilder(), BatchMatMulChef::value(), BCQFullyConnectedChef::value(), BCQGatherChef::value(), FullyConnectedChef::value(), GRUChef::value(), InstanceNormChef::value(), RmsNormChef::value(), RoPEChef::value(), AbsChef::value(), AddChef::value(), AddNChef::value(), ArgMaxChef::value(), ArgMinChef::value(), AveragePool2DChef::value(), BatchToSpaceNDChef::value(), CastChef::value(), ConcatenationChef::value(), Conv2DChef::value(), CosChef::value(), CumSumChef::value(), DensifyChef::value(), DepthToSpaceChef::value(), DepthwiseConv2DChef::value(), DivChef::value(), EqualChef::value(), ExpChef::value(), ExpandDimsChef::value(), FakeQuantChef::value(), FillChef::value(), FloorDivChef::value(), FloorModChef::value(), GatherChef::value(), GatherNdChef::value(), GeluChef::value(), GreaterChef::value(), GreaterEqualChef::value(), IfChef::value(), L2Pool2DChef::value(), LeakyReluChef::value(), LessChef::value(), LessEqualChef::value(), LocalResponseNormalizationChef::value(), LogicalAndChef::value(), LogicalNotChef::value(), LogicalOrChef::value(), LogSoftmaxChef::value(), MatrixDiagChef::value(), MatrixSetDiagChef::value(), MaximumChef::value(), MaxPool2DChef::value(), MeanChef::value(), MinimumChef::value(), MirrorPadChef::value(), MulChef::value(), NegChef::value(), NonMaxSuppressionV4Chef::value(), NonMaxSuppressionV5Chef::value(), NotEqualChef::value(), OneHotChef::value(), PackChef::value(), PadChef::value(), PadV2Chef::value(), PowChef::value(), RangeChef::value(), RankChef::value(), ReduceAnyChef::value(), ReduceMaxChef::value(), ReduceMinChef::value(), ReduceProdChef::value(), ReshapeChef::value(), ResizeBilinearChef::value(), ResizeNearestNeighborChef::value(), ReverseSequenceChef::value(), ReverseV2Chef::value(), ScatterNdChef::value(), SegmentSumChef::value(), SelectChef::value(), SelectV2Chef::value(), ShapeChef::value(), SliceChef::value(), SoftmaxChef::value(), SpaceToBatchNDChef::value(), SpaceToDepthChef::value(), SplitChef::value(), SplitVChef::value(), SquareChef::value(), SquaredDifferenceChef::value(), StridedSliceChef::value(), SubChef::value(), SumChef::value(), SVDFChef::value(), TileChef::value(), TopKV2Chef::value(), TransposeChef::value(), UniqueChef::value(), UnpackChef::value(), WhereChef::value(), WhileChef::value(), and ZerosLikeChef::value().

◆ Finish() [2/2]

template<bool Is64Aware = false>
void flatbuffers::FlatBufferBuilderImpl< Is64Aware >::Finish ( uoffset_t  root,
const char *  file_identifier,
bool  size_prefix 
)
inlineprotected

Definition at line 1246 of file flatbuffer_builder.h.

1246 {
1247 NotNested();
1249
1250 const size_t prefix_size = size_prefix ? sizeof(SizeT) : 0;
1251 // Make sure we track the alignment of the size prefix.
1252 TrackMinAlign(prefix_size);
1253
1254 const size_t root_offset_size = sizeof(uoffset_t);
1255 const size_t file_id_size = file_identifier ? kFileIdentifierLength : 0;
1256
1257 // This will cause the whole buffer to be aligned.
1258 PreAlign(prefix_size + root_offset_size + file_id_size, minalign_);
1259
1260 if (file_identifier) {
1261 FLATBUFFERS_ASSERT(strlen(file_identifier) == kFileIdentifierLength);
1262 PushBytes(reinterpret_cast<const uint8_t *>(file_identifier),
1264 }
1265 PushElement(ReferTo(root)); // Location of root.
1266 if (size_prefix) { PushElement(GetSize()); }
1267 finished = true;
1268 }
static const size_t kFileIdentifierLength
The length of a FlatBuffer file header.
SizeT GetSize() const
The current size of the serialized buffer, counting from the end.

References flatbuffers::FlatBufferBuilderImpl< Is64Aware >::buf_, flatbuffers::vector_downward< SizeT >::clear_scratch(), flatbuffers::FlatBufferBuilderImpl< Is64Aware >::finished, FLATBUFFERS_ASSERT, flatbuffers::FlatBufferBuilderImpl< Is64Aware >::GetSize(), flatbuffers::FlatBufferBuilderImpl< Is64Aware >::kFileIdentifierLength, and flatbuffers::FlatBufferBuilderImpl< Is64Aware >::minalign_.

◆ FinishSizePrefixed()

template<bool Is64Aware = false>
template<typename T >
void flatbuffers::FlatBufferBuilderImpl< Is64Aware >::FinishSizePrefixed ( Offset< T >  root,
const char *  file_identifier = nullptr 
)
inline

Finish a buffer with a 32 bit size field pre-fixed (size of the buffer following the size field). These buffers are NOT compatible with standard buffers created by Finish, i.e. you can't call GetRoot on them, you have to use GetSizePrefixedRoot instead. All >32 bit quantities in this buffer will be aligned when the whole size pre-fixed buffer is aligned. These kinds of buffers are useful for creating a stream of FlatBuffers.

Definition at line 1228 of file flatbuffer_builder.h.

1229 {
1230 Finish(root.o, file_identifier, true);
1231 }

References flatbuffers::FlatBufferBuilderImpl< Is64Aware >::Finish().

◆ FLATBUFFERS_ATTRIBUTE()

template<bool Is64Aware = false>
flatbuffers::FlatBufferBuilderImpl< Is64Aware >::FLATBUFFERS_ATTRIBUTE ( )
inline

Get the released pointer to the serialized buffer.

Warning
Do NOT attempt to use this FlatBufferBuilder afterwards!
Returns
A FlatBuffer that owns the buffer and its allocator and behaves similar to a unique_ptr with a deleter.

Definition at line 227 of file flatbuffer_builder.h.

228 {
229 Finished();
230 return buf_.release();
231 }

References flatbuffers::FlatBufferBuilderImpl< Is64Aware >::buf_, and flatbuffers::vector_downward< SizeT >::release().

◆ ForceDefaults()

template<bool Is64Aware = false>
void flatbuffers::FlatBufferBuilderImpl< Is64Aware >::ForceDefaults ( bool  fd)
inline

In order to save space, fields that are set to their default value don't get serialized into the buffer.

Parameters
[in]fdWhen set to true, always serializes default values that are set. Optional fields which are not set explicitly, will still not be serialized.

Definition at line 280 of file flatbuffer_builder.h.

280{ force_defaults_ = fd; }

References flatbuffers::FlatBufferBuilderImpl< Is64Aware >::force_defaults_.

Referenced by flatbuffers::Parser::Parser().

◆ GetBufferMinAlignment()

template<bool Is64Aware = false>
size_t flatbuffers::FlatBufferBuilderImpl< Is64Aware >::GetBufferMinAlignment ( ) const
inline

get the minimum alignment this buffer needs to be accessed properly. This is only known once all elements have been written (after you call Finish()). You can use this information if you need to embed a FlatBuffer in some other buffer, such that you can later read it without first having to copy it into its own buffer.

Definition at line 259 of file flatbuffer_builder.h.

259 {
260 Finished();
261 return minalign_;
262 }

References flatbuffers::FlatBufferBuilderImpl< Is64Aware >::minalign_.

◆ GetBufferPointer()

template<bool Is64Aware = false>
uint8_t * flatbuffers::FlatBufferBuilderImpl< Is64Aware >::GetBufferPointer ( ) const
inline

Get the serialized buffer (after you call Finish()).

Returns
Returns an uint8_t pointer to the FlatBuffer data inside the buffer.

Definition at line 206 of file flatbuffer_builder.h.

206 {
207 Finished();
208 return buf_.data();
209 }

References flatbuffers::FlatBufferBuilderImpl< Is64Aware >::buf_, and flatbuffers::vector_downward< SizeT >::data().

Referenced by onert::exporter::TrainInfoBuilder::get(), luci::CircleExporterImpl::getBufferPointer(), and onert::exporter::TrainInfoBuilder::TrainInfoBuilder().

◆ GetBufferSpan()

template<bool Is64Aware = false>
flatbuffers::span< uint8_t > flatbuffers::FlatBufferBuilderImpl< Is64Aware >::GetBufferSpan ( ) const
inline

Get the serialized buffer (after you call Finish()) as a span.

Returns
Returns a constructed flatbuffers::span that is a view over the FlatBuffer data inside the buffer.

Definition at line 214 of file flatbuffer_builder.h.

214 {
215 Finished();
216 return flatbuffers::span<uint8_t>(buf_.data(), buf_.size());
217 }

References flatbuffers::FlatBufferBuilderImpl< Is64Aware >::buf_, flatbuffers::vector_downward< SizeT >::data(), and flatbuffers::vector_downward< SizeT >::size().

◆ GetCurrentBufferPointer()

template<bool Is64Aware = false>
uint8_t * flatbuffers::FlatBufferBuilderImpl< Is64Aware >::GetCurrentBufferPointer ( ) const
inline

Get a pointer to an unfinished buffer.

Returns
Returns a uint8_t pointer to the unfinished buffer.

Definition at line 221 of file flatbuffer_builder.h.

221{ return buf_.data(); }

References flatbuffers::FlatBufferBuilderImpl< Is64Aware >::buf_, and flatbuffers::vector_downward< SizeT >::data().

Referenced by flatbuffers::GetMutableTemporaryPointer().

◆ GetSize()

◆ GetSizeRelative32BitRegion() [1/2]

template<bool Is64Aware = false>
template<bool is_64 = Is64Aware>
std::enable_if< is_64, uoffset_t >::type flatbuffers::FlatBufferBuilderImpl< Is64Aware >::GetSizeRelative32BitRegion ( ) const
inline

The current size of the serialized buffer relative to the end of the 32-bit region.

Returns
Returns an uoffset_t with the current size of the buffer.

Definition at line 187 of file flatbuffer_builder.h.

188 {
189 //[32-bit region][64-bit region]
190 // [XXXXXXXXXXXXXXXXXXX] GetSize()
191 // [YYYYYYYYYYYYY] length_of_64_bit_region_
192 // [ZZZZ] return size
193 return static_cast<uoffset_t>(GetSize() - length_of_64_bit_region_);
194 }

References flatbuffers::FlatBufferBuilderImpl< Is64Aware >::GetSize(), and flatbuffers::FlatBufferBuilderImpl< Is64Aware >::length_of_64_bit_region_.

Referenced by flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateUninitializedVector().

◆ GetSizeRelative32BitRegion() [2/2]

template<bool Is64Aware = false>
template<bool is_64 = Is64Aware>
std::enable_if<!is_64, uoffset_t >::type flatbuffers::FlatBufferBuilderImpl< Is64Aware >::GetSizeRelative32BitRegion ( ) const
inline

Definition at line 198 of file flatbuffer_builder.h.

199 {
200 return static_cast<uoffset_t>(GetSize());
201 }

References flatbuffers::FlatBufferBuilderImpl< Is64Aware >::GetSize().

◆ operator=() [1/2]

template<bool Is64Aware = false>
FlatBufferBuilderImpl & flatbuffers::FlatBufferBuilderImpl< Is64Aware >::operator= ( const FlatBufferBuilderImpl< Is64Aware > &  )
protected

◆ operator=() [2/2]

template<bool Is64Aware = false>
FlatBufferBuilderImpl & flatbuffers::FlatBufferBuilderImpl< Is64Aware >::operator= ( FlatBufferBuilderImpl< Is64Aware > &&  other)
inlinenoexcept

Move assignment operator for FlatBufferBuilder.

Definition at line 134 of file flatbuffer_builder.h.

134 {
135 // Move construct a temporary and swap idiom
136 FlatBufferBuilderImpl temp(std::move(other));
137 Swap(temp);
138 return *this;
139 }
FlatBufferBuilderImpl(size_t initial_size=1024, Allocator *allocator=nullptr, bool own_allocator=false, size_t buffer_minalign=AlignOf< largest_scalar_t >())
Default constructor for FlatBufferBuilder.

References flatbuffers::FlatBufferBuilderImpl< Is64Aware >::Swap().

◆ Release()

template<bool Is64Aware = false>
DetachedBuffer flatbuffers::FlatBufferBuilderImpl< Is64Aware >::Release ( )
inline

Get the released DetachedBuffer.

Returns
A DetachedBuffer that owns the buffer and its allocator.

Definition at line 235 of file flatbuffer_builder.h.

235 {
236 Finished();
237 return buf_.release();
238 }

References flatbuffers::FlatBufferBuilderImpl< Is64Aware >::buf_, and flatbuffers::vector_downward< SizeT >::release().

◆ ReleaseRaw()

template<bool Is64Aware = false>
uint8_t * flatbuffers::FlatBufferBuilderImpl< Is64Aware >::ReleaseRaw ( size_t &  size,
size_t &  offset 
)
inline

Get the released pointer to the serialized buffer.

Parameters
sizeThe size of the memory block containing the serialized FlatBuffer.
offsetThe offset from the released pointer where the finished FlatBuffer starts.
Returns
A raw pointer to the start of the memory block containing the serialized FlatBuffer.
Remarks
If the allocator is owned, it gets deleted when the destructor is called..

Definition at line 249 of file flatbuffer_builder.h.

249 {
250 Finished();
251 return buf_.release_raw(size, offset);
252 }
uint8_t * release_raw(size_t &allocated_bytes, size_t &offset)
__global uchar * offset(const Image *img, int x, int y)
Definition helpers.h:540

References flatbuffers::FlatBufferBuilderImpl< Is64Aware >::buf_, offset(), flatbuffers::vector_downward< SizeT >::release_raw(), and size.

◆ Reset()

template<bool Is64Aware = false>
void flatbuffers::FlatBufferBuilderImpl< Is64Aware >::Reset ( )
inline

Definition at line 159 of file flatbuffer_builder.h.

159 {
160 Clear(); // clear builder state
161 buf_.reset(); // deallocate buffer
162 }
void Clear()
Reset all the state in this FlatBufferBuilder so it can be reused to construct another buffer.

References flatbuffers::FlatBufferBuilderImpl< Is64Aware >::buf_, flatbuffers::FlatBufferBuilderImpl< Is64Aware >::Clear(), and flatbuffers::vector_downward< SizeT >::reset().

◆ Swap()

template<bool Is64Aware = false>
void flatbuffers::FlatBufferBuilderImpl< Is64Aware >::Swap ( FlatBufferBuilderImpl< Is64Aware > &  other)
inline

Definition at line 141 of file flatbuffer_builder.h.

141 {
142 using std::swap;
143 buf_.swap(other.buf_);
144 swap(num_field_loc, other.num_field_loc);
145 swap(max_voffset_, other.max_voffset_);
146 swap(length_of_64_bit_region_, other.length_of_64_bit_region_);
147 swap(nested, other.nested);
148 swap(finished, other.finished);
149 swap(minalign_, other.minalign_);
150 swap(force_defaults_, other.force_defaults_);
151 swap(dedup_vtables_, other.dedup_vtables_);
152 swap(string_pool, other.string_pool);
153 }
void swap(vector_downward &other)

References flatbuffers::FlatBufferBuilderImpl< Is64Aware >::buf_, flatbuffers::FlatBufferBuilderImpl< Is64Aware >::dedup_vtables_, flatbuffers::FlatBufferBuilderImpl< Is64Aware >::finished, flatbuffers::FlatBufferBuilderImpl< Is64Aware >::force_defaults_, flatbuffers::FlatBufferBuilderImpl< Is64Aware >::length_of_64_bit_region_, flatbuffers::FlatBufferBuilderImpl< Is64Aware >::max_voffset_, flatbuffers::FlatBufferBuilderImpl< Is64Aware >::minalign_, flatbuffers::FlatBufferBuilderImpl< Is64Aware >::nested, flatbuffers::FlatBufferBuilderImpl< Is64Aware >::num_field_loc, flatbuffers::FlatBufferBuilderImpl< Is64Aware >::string_pool, and flatbuffers::vector_downward< SizeT >::swap().

Referenced by flatbuffers::FlatBufferBuilderImpl< Is64Aware >::FlatBufferBuilderImpl(), flatbuffers::grpc::MessageBuilder::MessageBuilder(), and flatbuffers::FlatBufferBuilderImpl< Is64Aware >::operator=().

◆ SwapBufAllocator()

template<bool Is64Aware = false>
void flatbuffers::FlatBufferBuilderImpl< Is64Aware >::SwapBufAllocator ( FlatBufferBuilderImpl< Is64Aware > &  other)
inline

Field Documentation

◆ buf_

◆ dedup_vtables_

template<bool Is64Aware = false>
bool flatbuffers::FlatBufferBuilderImpl< Is64Aware >::dedup_vtables_
protected

◆ finished

◆ force_defaults_

template<bool Is64Aware = false>
bool flatbuffers::FlatBufferBuilderImpl< Is64Aware >::force_defaults_
protected

◆ kFileIdentifierLength

template<bool Is64Aware = false>
const size_t flatbuffers::FlatBufferBuilderImpl< Is64Aware >::kFileIdentifierLength
static
Initial value:
=
::flatbuffers::kFileIdentifierLength

The length of a FlatBuffer file header.

Definition at line 1238 of file flatbuffer_builder.h.

Referenced by flatbuffers::FlatBufferBuilderImpl< Is64Aware >::Finish().

◆ length_of_64_bit_region_

◆ max_voffset_

template<bool Is64Aware = false>
voffset_t flatbuffers::FlatBufferBuilderImpl< Is64Aware >::max_voffset_
protected

◆ minalign_

◆ nested

template<bool Is64Aware = false>
bool flatbuffers::FlatBufferBuilderImpl< Is64Aware >::nested
protected

◆ num_field_loc

template<bool Is64Aware = false>
uoffset_t flatbuffers::FlatBufferBuilderImpl< Is64Aware >::num_field_loc
protected

◆ string_pool


The documentation for this class was generated from the following file: