ONE - On-device Neural Engine
Loading...
Searching...
No Matches
flatbuffers::FlatBufferBuilder Class Reference

Helper class to hold data needed in creation of a FlatBuffer. To serialize data, you typically call one of the Create*() functions in the generated code, which in turn call a sequence of StartTable/ PushElement/AddElement/EndTable, or the builtin CreateString/ CreateVector functions. Do this is depth-first order to build up a tree to the root. Finish() wraps up the buffer ready for transport. More...

#include <flatbuffers.h>

Collaboration diagram for flatbuffers::FlatBufferBuilder:

Data Structures

struct  FieldLoc
 
struct  StringOffsetCompare
 

Public Member Functions

 FlatBufferBuilder (size_t initial_size=1024, Allocator *allocator=nullptr, bool own_allocator=false, size_t buffer_minalign=AlignOf< largest_scalar_t >())
 Default constructor for FlatBufferBuilder.
 
 FlatBufferBuilder (FlatBufferBuilder &&other)
 Move constructor for FlatBufferBuilder.
 
FlatBufferBuilderoperator= (FlatBufferBuilder &&other)
 Move assignment operator for FlatBufferBuilder.
 
void Swap (FlatBufferBuilder &other)
 
 ~FlatBufferBuilder ()
 
void Reset ()
 
void Clear ()
 Reset all the state in this FlatBufferBuilder so it can be reused to construct another buffer.
 
uoffset_t GetSize () const
 The current size of the serialized buffer, counting from the end.
 
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 (deprecated("use Release() instead")) 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.
 
Offset< StringCreateString (const char *str, size_t len)
 Store a string in the buffer, which can contain any binary data.
 
Offset< StringCreateString (const char *str)
 Store a string in the buffer, which is null-terminated.
 
Offset< StringCreateString (char *str)
 Store a string in the buffer, which is null-terminated.
 
Offset< StringCreateString (const std::string &str)
 Store a string in the buffer, which can contain any binary data.
 
Offset< StringCreateString (const String *str)
 Store a string in the buffer, which can contain any binary data.
 
template<typename T >
Offset< 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.
 
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.
 
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.
 
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.
 
template<typename T >
Offset< Vector< T > > CreateVector (const T *v, size_t len)
 Serialize an array into a FlatBuffer vector.
 
template<typename T >
Offset< Vector< Offset< T > > > CreateVector (const Offset< T > *v, size_t len)
 
template<typename T >
Offset< Vector< T > > CreateVector (const std::vector< T > &v)
 Serialize a std::vector into a FlatBuffer vector.
 
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.
 
Offset< Vector< Offset< String > > > CreateVectorOfStrings (const std::vector< std::string > &v)
 Serialize a std::vector<std::string> into a FlatBuffer vector. This is a convenience function for a common case.
 
template<typename T >
Offset< Vector< const T * > > CreateVectorOfStructs (const T *v, size_t len)
 Serialize an array of structs into a FlatBuffer vector.
 
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 >
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 , typename Alloc >
Offset< Vector< const T * > > CreateVectorOfStructs (const std::vector< T, Alloc > &v)
 Serialize a std::vector of structs into a FlatBuffer vector.
 
template<typename T , typename S >
Offset< Vector< const T * > > CreateVectorOfNativeStructs (const std::vector< S > &v, T((*const pack_func)(const S &)))
 Serialize a std::vector of native structs into a FlatBuffer vector.
 
template<typename T , typename S >
Offset< Vector< const T * > > CreateVectorOfNativeStructs (const std::vector< S > &v)
 Serialize a std::vector of native structs into a FlatBuffer vector.
 
template<typename T >
Offset< Vector< const T * > > CreateVectorOfSortedStructs (std::vector< T > *v)
 Serialize a std::vector of structs into a FlatBuffer vector in sorted order.
 
template<typename T , typename S >
Offset< Vector< const T * > > CreateVectorOfSortedNativeStructs (std::vector< S > *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 >
Offset< Vector< Offset< T > > > CreateVectorOfSortedTables (std::vector< Offset< T > > *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, uint8_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< 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 (FlatBufferBuilder &other)
 

Static Public Attributes

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

Protected Types

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

Protected Member Functions

 FlatBufferBuilder (const FlatBufferBuilder &)
 
FlatBufferBuilderoperator= (const FlatBufferBuilder &)
 
void Finish (uoffset_t root, const char *file_identifier, bool size_prefix)
 

Protected Attributes

vector_downward buf_
 
uoffset_t num_field_loc
 
voffset_t max_voffset_
 
bool nested
 
bool finished
 
size_t minalign_
 
bool force_defaults_
 
bool dedup_vtables_
 
StringOffsetMapstring_pool
 

Detailed Description

Helper class to hold data needed in creation of a FlatBuffer. To serialize data, you typically call one of the Create*() functions in the generated code, which in turn call a sequence of StartTable/ PushElement/AddElement/EndTable, or the builtin CreateString/ CreateVector functions. Do this is depth-first order to build up a tree to the root. Finish() wraps up the buffer ready for transport.

Definition at line 1171 of file flatbuffers.h.

Member Typedef Documentation

◆ StringOffsetMap

Definition at line 2282 of file flatbuffers.h.

Constructor & Destructor Documentation

◆ FlatBufferBuilder() [1/3]

flatbuffers::FlatBufferBuilder::FlatBufferBuilder ( 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 1185 of file flatbuffers.h.

1188 : buf_(initial_size, allocator, own_allocator, buffer_minalign), num_field_loc(0),
1189 max_voffset_(0), nested(false), finished(false), minalign_(1), force_defaults_(false),
1190 dedup_vtables_(true), string_pool(nullptr)
1191 {
1192 EndianCheck();
1193 }
void EndianCheck()
Definition flatbuffers.h:78

References flatbuffers::EndianCheck().

◆ FlatBufferBuilder() [2/3]

flatbuffers::FlatBufferBuilder::FlatBufferBuilder ( FlatBufferBuilder &&  other)
inline

Move constructor for FlatBufferBuilder.

Definition at line 1197 of file flatbuffers.h.

1201 : buf_(1024, nullptr, false, AlignOf<largest_scalar_t>()), num_field_loc(0), max_voffset_(0),
1202 nested(false), finished(false), minalign_(1), force_defaults_(false), dedup_vtables_(true),
1203 string_pool(nullptr)
1204 {
1205 EndianCheck();
1206 // Default construct and swap idiom.
1207 // Lack of delegating constructors in vs2010 makes it more verbose than needed.
1208 Swap(other);
1209 }
void Swap(FlatBufferBuilder &other)

References flatbuffers::EndianCheck(), and Swap().

◆ ~FlatBufferBuilder()

flatbuffers::FlatBufferBuilder::~FlatBufferBuilder ( )
inline

Definition at line 1238 of file flatbuffers.h.

1239 {
1240 if (string_pool)
1241 delete string_pool;
1242 }

References string_pool.

◆ FlatBufferBuilder() [3/3]

flatbuffers::FlatBufferBuilder::FlatBufferBuilder ( const FlatBufferBuilder )
protected

Member Function Documentation

◆ Clear()

void flatbuffers::FlatBufferBuilder::Clear ( )
inline

Reset all the state in this FlatBufferBuilder so it can be reused to construct another buffer.

Definition at line 1252 of file flatbuffers.h.

1253 {
1254 ClearOffsets();
1255 buf_.clear();
1256 nested = false;
1257 finished = false;
1258 minalign_ = 1;
1259 if (string_pool)
1260 string_pool->clear();
1261 }

References buf_, flatbuffers::vector_downward::clear(), finished, minalign_, nested, and string_pool.

Referenced by Reset().

◆ CreateSharedString() [1/4]

Offset< String > flatbuffers::FlatBufferBuilder::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.

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 1693 of file flatbuffers.h.

1694 {
1695 return CreateSharedString(str, strlen(str));
1696 }
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...
const char * str
Definition util.h:290

References CreateSharedString(), and flatbuffers::str.

◆ CreateSharedString() [2/4]

Offset< String > flatbuffers::FlatBufferBuilder::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.

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 1656 of file flatbuffers.h.

1657 {
1658 if (!string_pool)
1659 string_pool = new StringOffsetMap(StringOffsetCompare(buf_));
1660 auto size_before_string = buf_.size();
1661 // Must first serialize the string, since the set is all offsets into
1662 // buffer.
1663 auto off = CreateString(str, len);
1664 auto it = string_pool->find(off);
1665 // If it exists we reuse existing serialized data!
1666 if (it != string_pool->end())
1667 {
1668 // We can remove the string we serialized.
1669 buf_.pop(buf_.size() - size_before_string);
1670 return *it;
1671 }
1672 // Record this string for future use.
1673 string_pool->insert(off);
1674 return off;
1675 }
Offset< String > CreateString(const char *str, size_t len)
Store a string in the buffer, which can contain any binary data.
std::set< Offset< String >, StringOffsetCompare > StringOffsetMap
void pop(size_t bytes_to_remove)

References buf_, CreateString(), flatbuffers::vector_downward::pop(), flatbuffers::vector_downward::size(), flatbuffers::str, and string_pool.

Referenced by CreateSharedString(), CreateSharedString(), and CreateSharedString().

◆ CreateSharedString() [3/4]

Offset< String > flatbuffers::FlatBufferBuilder::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.

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 1703 of file flatbuffers.h.

1704 {
1705 return CreateSharedString(str.c_str(), str.length());
1706 }

References CreateSharedString(), and flatbuffers::str.

◆ CreateSharedString() [4/4]

Offset< String > flatbuffers::FlatBufferBuilder::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.

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 1714 of file flatbuffers.h.

1715 {
1716 return CreateSharedString(str->c_str(), str->size());
1717 }

References CreateSharedString(), and flatbuffers::str.

◆ CreateString() [1/6]

Offset< String > flatbuffers::FlatBufferBuilder::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 1613 of file flatbuffers.h.

1613{ return CreateString(str, strlen(str)); }

References CreateString(), and flatbuffers::str.

Referenced by CreateString().

◆ CreateString() [2/6]

Offset< String > flatbuffers::FlatBufferBuilder::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 1608 of file flatbuffers.h.

1608{ return CreateString(str, strlen(str)); }

References CreateString(), and flatbuffers::str.

Referenced by CreateString().

◆ CreateString() [3/6]

Offset< String > flatbuffers::FlatBufferBuilder::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 1595 of file flatbuffers.h.

1596 {
1597 NotNested();
1598 PreAlign<uoffset_t>(len + 1); // Always 0-terminated.
1599 buf_.fill(1);
1600 PushBytes(reinterpret_cast<const uint8_t *>(str), len);
1601 PushElement(static_cast<uoffset_t>(len));
1602 return Offset<String>(GetSize());
1603 }
uoffset_t GetSize() const
The current size of the serialized buffer, counting from the end.
void fill(size_t zero_pad_bytes)

References buf_, flatbuffers::vector_downward::fill(), GetSize(), and flatbuffers::str.

Referenced by CreateSharedString(), CreateString(), CreateString(), CreateString(), CreateVectorOfStrings(), exo::circle_detail::exportOpDefinedTensor(), and exo::tflite_detail::exportOpDefinedTensor().

◆ CreateString() [4/6]

Offset< String > flatbuffers::FlatBufferBuilder::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 1618 of file flatbuffers.h.

1619 {
1620 return CreateString(str.c_str(), str.length());
1621 }

References CreateString(), and flatbuffers::str.

◆ CreateString() [5/6]

Offset< String > flatbuffers::FlatBufferBuilder::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 1636 of file flatbuffers.h.

1637 {
1638 return str ? CreateString(str->c_str(), str->size()) : 0;
1639 }

References CreateString(), and flatbuffers::str.

◆ CreateString() [6/6]

template<typename T >
Offset< String > flatbuffers::FlatBufferBuilder::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 1645 of file flatbuffers.h.

1646 {
1647 return CreateString(str.c_str(), str.length());
1648 }

References CreateString(), and flatbuffers::str.

◆ CreateStruct()

template<typename T >
Offset< const T * > flatbuffers::FlatBufferBuilder::CreateStruct ( const T &  structobj)
inline

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

Definition at line 2182 of file flatbuffers.h.

2183 {
2184 NotNested();
2185 Align(AlignOf<T>());
2186 buf_.push_small(structobj);
2187 return Offset<const T *>(GetSize());
2188 }
void push_small(const T &little_endian_t)

References buf_, GetSize(), and flatbuffers::vector_downward::push_small().

◆ CreateUninitializedVector() [1/2]

uoffset_t flatbuffers::FlatBufferBuilder::CreateUninitializedVector ( size_t  len,
size_t  elemsize,
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 2135 of file flatbuffers.h.

2136 {
2137 NotNested();
2138 StartVector(len, elemsize);
2139 buf_.make_space(len * elemsize);
2140 auto vec_start = GetSize();
2141 auto vec_end = EndVector(len);
2142 *buf = buf_.data_at(vec_start);
2143 return vec_end;
2144 }
uint8_t * data_at(size_t offset) const
uint8_t * make_space(size_t len)

References buf_, flatbuffers::vector_downward::data_at(), GetSize(), and flatbuffers::vector_downward::make_space().

Referenced by CreateUninitializedVector(), and CreateUninitializedVectorOfStructs().

◆ CreateUninitializedVector() [2/2]

template<typename T >
Offset< Vector< T > > flatbuffers::FlatBufferBuilder::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 2154 of file flatbuffers.h.

2155 {
2156 AssertScalarT<T>();
2157 return CreateUninitializedVector(len, sizeof(T), reinterpret_cast<uint8_t **>(buf));
2158 }
uoffset_t CreateUninitializedVector(size_t len, size_t elemsize, uint8_t **buf)
Specialized version of CreateVector for non-copying use cases. Write the data any time later to the r...

References CreateUninitializedVector().

◆ CreateUninitializedVectorOfStructs()

template<typename T >
Offset< Vector< const T * > > flatbuffers::FlatBufferBuilder::CreateUninitializedVectorOfStructs ( size_t  len,
T **  buf 
)
inline

Definition at line 2161 of file flatbuffers.h.

2162 {
2163 return CreateUninitializedVector(len, sizeof(T), reinterpret_cast<uint8_t **>(buf));
2164 }

References CreateUninitializedVector().

◆ CreateVector() [1/6]

template<typename T >
Offset< Vector< Offset< T > > > flatbuffers::FlatBufferBuilder::CreateVector ( const Offset< T > *  v,
size_t  len 
)
inline

Definition at line 1792 of file flatbuffers.h.

1793 {
1794 StartVector(len, sizeof(Offset<T>));
1795 for (auto i = len; i > 0;)
1796 {
1797 PushElement(v[--i]);
1798 }
1799 return Offset<Vector<Offset<T>>>(EndVector(len));
1800 }

◆ CreateVector() [2/6]

Offset< Vector< uint8_t > > flatbuffers::FlatBufferBuilder::CreateVector ( const std::vector< bool > &  v)
inline

Definition at line 1816 of file flatbuffers.h.

1817 {
1818 StartVector(v.size(), sizeof(uint8_t));
1819 for (auto i = v.size(); i > 0;)
1820 {
1821 PushElement(static_cast<uint8_t>(v[--i]));
1822 }
1823 return Offset<Vector<uint8_t>>(EndVector(v.size()));
1824 }

◆ CreateVector() [3/6]

template<typename T >
Offset< Vector< T > > flatbuffers::FlatBufferBuilder::CreateVector ( const std::vector< T > &  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 1808 of file flatbuffers.h.

1809 {
1810 return CreateVector(data(v), v.size());
1811 }
Offset< Vector< T > > CreateVector(const T *v, size_t len)
Serialize an array into a FlatBuffer vector.
const T * data(const std::vector< T, Alloc > &v)

References CreateVector(), and flatbuffers::data().

◆ CreateVector() [4/6]

template<typename T >
Offset< Vector< T > > flatbuffers::FlatBufferBuilder::CreateVector ( const T *  v,
size_t  len 
)
inline

Serialize an array into a FlatBuffer vector.

Template Parameters
TThe data type of the 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 1762 of file flatbuffers.h.

1763 {
1764 // If this assert hits, you're specifying a template argument that is
1765 // causing the wrong overload to be selected, remove it.
1766 AssertScalarT<T>();
1767 StartVector(len, sizeof(T));
1768 if (len == 0)
1769 {
1770 return Offset<Vector<T>>(EndVector(len));
1771 }
1772
1773#if FLATBUFFERS_LITTLEENDIAN
1774 PushBytes(reinterpret_cast<const uint8_t *>(v), len * sizeof(T));
1775#else
1776 if (sizeof(T) == 1)
1777 {
1778 PushBytes(reinterpret_cast<const uint8_t *>(v), len);
1779 }
1780 else
1781 {
1782 for (auto i = len; i > 0;)
1783 {
1784 PushElement(v[--i]);
1785 }
1786 }
1787#endif
1788 // clang-format on
1789 return Offset<Vector<T>>(EndVector(len));
1790 }

Referenced by as_tflite_sparse_index_vec(), tflite2circle::build_circle_ReshapeOptions(), tflite2circle::build_circle_SqueezeOptions(), luci::circle_custom_options(), CreateVector(), CreateVector(), CreateVector(), CreateVectorOfSortedTables(), CreateVectorOfStrings(), 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() [5/6]

template<typename T >
Offset< Vector< T > > flatbuffers::FlatBufferBuilder::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 1835 of file flatbuffers.h.

1836 {
1837 std::vector<T> elems(vector_size);
1838 for (size_t i = 0; i < vector_size; i++)
1839 elems[i] = f(i);
1840 return CreateVector(elems);
1841 }

References CreateVector().

◆ CreateVector() [6/6]

template<typename T , typename F , typename S >
Offset< Vector< T > > flatbuffers::FlatBufferBuilder::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.

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 1855 of file flatbuffers.h.

1856 {
1857 std::vector<T> elems(vector_size);
1858 for (size_t i = 0; i < vector_size; i++)
1859 elems[i] = f(i, state);
1860 return CreateVector(elems);
1861 }

References CreateVector().

◆ CreateVectorOfNativeStructs() [1/4]

template<typename T , typename S >
Offset< Vector< const T * > > flatbuffers::FlatBufferBuilder::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 1920 of file flatbuffers.h.

1921 {
1922 extern T Pack(const S &);
1923 return CreateVectorOfNativeStructs(v, len, Pack);
1924 }
#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 CreateVectorOfNativeStructs(), and S.

◆ CreateVectorOfNativeStructs() [2/4]

template<typename T , typename S >
Offset< Vector< const T * > > flatbuffers::FlatBufferBuilder::CreateVectorOfNativeStructs ( const S v,
size_t  len,
T((*const pack_func)(const S &))   
)
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 1902 of file flatbuffers.h.

1904 {
1905 FLATBUFFERS_ASSERT(pack_func);
1906 std::vector<T> vv(len);
1907 std::transform(v, v + len, vv.begin(), pack_func);
1908 return CreateVectorOfStructs<T>(data(vv), vv.size());
1909 }
#define FLATBUFFERS_ASSERT
Definition base.h:37

References flatbuffers::data(), and FLATBUFFERS_ASSERT.

Referenced by CreateVectorOfNativeStructs().

◆ CreateVectorOfNativeStructs() [3/4]

template<typename T , typename S >
Offset< Vector< const T * > > flatbuffers::FlatBufferBuilder::CreateVectorOfNativeStructs ( const std::vector< S > &  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 2009 of file flatbuffers.h.

2010 {
2011 return CreateVectorOfNativeStructs<T, S>(data(v), v.size());
2012 }

References flatbuffers::data().

◆ CreateVectorOfNativeStructs() [4/4]

template<typename T , typename S >
Offset< Vector< const T * > > flatbuffers::FlatBufferBuilder::CreateVectorOfNativeStructs ( const std::vector< S > &  v,
T((*const pack_func)(const S &))   
)
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 1994 of file flatbuffers.h.

1996 {
1997 return CreateVectorOfNativeStructs<T, S>(data(v), v.size(), pack_func);
1998 }

References flatbuffers::data().

◆ CreateVectorOfSortedNativeStructs() [1/2]

template<typename T , typename S >
Offset< Vector< const T * > > flatbuffers::FlatBufferBuilder::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 2073 of file flatbuffers.h.

2074 {
2075 extern T Pack(const S &);
2076 typedef T (*Pack_t)(const S &);
2077 std::vector<T> vv(len);
2078 std::transform(v, v + len, vv.begin(), static_cast<Pack_t &>(Pack));
2079 return CreateVectorOfSortedStructs<T>(vv, len);
2080 }

References S.

◆ CreateVectorOfSortedNativeStructs() [2/2]

template<typename T , typename S >
Offset< Vector< const T * > > flatbuffers::FlatBufferBuilder::CreateVectorOfSortedNativeStructs ( std::vector< S > *  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 2044 of file flatbuffers.h.

2045 {
2046 return CreateVectorOfSortedNativeStructs<T, S>(data(*v), v->size());
2047 }

References flatbuffers::data().

◆ CreateVectorOfSortedStructs() [1/2]

template<typename T >
Offset< Vector< const T * > > flatbuffers::FlatBufferBuilder::CreateVectorOfSortedStructs ( std::vector< T > *  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 2030 of file flatbuffers.h.

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

References CreateVectorOfSortedStructs(), and flatbuffers::data().

Referenced by CreateVectorOfSortedStructs().

◆ CreateVectorOfSortedStructs() [2/2]

template<typename T >
Offset< Vector< const T * > > flatbuffers::FlatBufferBuilder::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 2057 of file flatbuffers.h.

2058 {
2059 std::sort(v, v + len, StructKeyComparator<T>());
2060 return CreateVectorOfStructs(v, len);
2061 }
Offset< Vector< const T * > > CreateVectorOfStructs(const T *v, size_t len)
Serialize an array of structs into a FlatBuffer vector.

References CreateVectorOfStructs().

◆ CreateVectorOfSortedTables() [1/2]

template<typename T >
Offset< Vector< Offset< T > > > flatbuffers::FlatBufferBuilder::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 2109 of file flatbuffers.h.

2110 {
2111 std::sort(v, v + len, TableKeyComparator<T>(buf_));
2112 return CreateVector(v, len);
2113 }

References buf_, and CreateVector().

Referenced by CreateVectorOfSortedTables().

◆ CreateVectorOfSortedTables() [2/2]

template<typename T >
Offset< Vector< Offset< T > > > flatbuffers::FlatBufferBuilder::CreateVectorOfSortedTables ( std::vector< Offset< T > > *  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 2123 of file flatbuffers.h.

2124 {
2125 return CreateVectorOfSortedTables(data(*v), v->size());
2126 }
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 CreateVectorOfSortedTables(), and flatbuffers::data().

◆ CreateVectorOfStrings()

Offset< Vector< Offset< String > > > flatbuffers::FlatBufferBuilder::CreateVectorOfStrings ( const std::vector< std::string > &  v)
inline

Serialize a std::vector<std::string> into a FlatBuffer vector. 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 1869 of file flatbuffers.h.

1870 {
1871 std::vector<Offset<String>> offsets(v.size());
1872 for (size_t i = 0; i < v.size(); i++)
1873 offsets[i] = CreateString(v[i]);
1874 return CreateVector(offsets);
1875 }

References CreateString(), and CreateVector().

◆ CreateVectorOfStructs() [1/4]

template<typename T , typename Alloc >
Offset< Vector< const T * > > flatbuffers::FlatBufferBuilder::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 1978 of file flatbuffers.h.

1979 {
1980 return CreateVectorOfStructs(data(v), v.size());
1981 }

References CreateVectorOfStructs(), and flatbuffers::data().

◆ CreateVectorOfStructs() [2/4]

template<typename T >
Offset< Vector< const T * > > flatbuffers::FlatBufferBuilder::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 1884 of file flatbuffers.h.

1885 {
1886 StartVector(len * sizeof(T) / AlignOf<T>(), AlignOf<T>());
1887 PushBytes(reinterpret_cast<const uint8_t *>(v), sizeof(T) * len);
1888 return Offset<Vector<const T *>>(EndVector(len));
1889 }

Referenced by CreateVectorOfSortedStructs(), and CreateVectorOfStructs().

◆ CreateVectorOfStructs() [3/4]

template<typename T >
Offset< Vector< const T * > > flatbuffers::FlatBufferBuilder::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 1936 of file flatbuffers.h.

1938 {
1939 T *structs = StartVectorOfStructs<T>(vector_size);
1940 for (size_t i = 0; i < vector_size; i++)
1941 {
1942 filler(i, structs);
1943 structs++;
1944 }
1945 return EndVectorOfStructs<T>(vector_size);
1946 }

◆ CreateVectorOfStructs() [4/4]

template<typename T , typename F , typename S >
Offset< Vector< const T * > > flatbuffers::FlatBufferBuilder::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 1960 of file flatbuffers.h.

1961 {
1962 T *structs = StartVectorOfStructs<T>(vector_size);
1963 for (size_t i = 0; i < vector_size; i++)
1964 {
1965 f(i, structs, state);
1966 structs++;
1967 }
1968 return EndVectorOfStructs<T>(vector_size);
1969 }

◆ CreateVectorScalarCast()

template<typename T , typename U >
Offset< Vector< T > > flatbuffers::FlatBufferBuilder::CreateVectorScalarCast ( const U *  v,
size_t  len 
)
inline

Definition at line 2169 of file flatbuffers.h.

2170 {
2171 AssertScalarT<T>();
2172 AssertScalarT<U>();
2173 StartVector(len, sizeof(T));
2174 for (auto i = len; i > 0;)
2175 {
2176 PushElement(static_cast<T>(v[--i]));
2177 }
2178 return Offset<Vector<T>>(EndVector(len));
2179 }

◆ DedupVtables()

void flatbuffers::FlatBufferBuilder::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 1355 of file flatbuffers.h.

1355{ dedup_vtables_ = dedup; }

References dedup_vtables_.

◆ Finish() [1/2]

template<typename T >
void flatbuffers::FlatBufferBuilder::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 2196 of file flatbuffers.h.

2197 {
2198 Finish(root.o, file_identifier, false);
2199 }
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 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(), Finish(), 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]

void flatbuffers::FlatBufferBuilder::Finish ( uoffset_t  root,
const char *  file_identifier,
bool  size_prefix 
)
inlineprotected

Definition at line 2221 of file flatbuffers.h.

2222 {
2223 NotNested();
2225 // This will cause the whole buffer to be aligned.
2226 PreAlign((size_prefix ? sizeof(uoffset_t) : 0) + sizeof(uoffset_t) +
2227 (file_identifier ? kFileIdentifierLength : 0),
2228 minalign_);
2229 if (file_identifier)
2230 {
2231 FLATBUFFERS_ASSERT(strlen(file_identifier) == kFileIdentifierLength);
2232 PushBytes(reinterpret_cast<const uint8_t *>(file_identifier), kFileIdentifierLength);
2233 }
2234 PushElement(ReferTo(root)); // Location of root.
2235 if (size_prefix)
2236 {
2237 PushElement(GetSize());
2238 }
2239 finished = true;
2240 }
static const size_t kFileIdentifierLength
The length of a FlatBuffer file header.

References buf_, flatbuffers::vector_downward::clear_scratch(), finished, FLATBUFFERS_ASSERT, GetSize(), kFileIdentifierLength, and minalign_.

◆ FinishSizePrefixed()

template<typename T >
void flatbuffers::FlatBufferBuilder::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 2209 of file flatbuffers.h.

2210 {
2211 Finish(root.o, file_identifier, true);
2212 }

References Finish().

◆ FLATBUFFERS_ATTRIBUTE()

flatbuffers::FlatBufferBuilder::FLATBUFFERS_ATTRIBUTE ( deprecated("use Release() instead")  )
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 1293 of file flatbuffers.h.

1295 {
1296 Finished();
1297 return buf_.release();
1298 }

References buf_, and flatbuffers::vector_downward::release().

◆ ForceDefaults()

void flatbuffers::FlatBufferBuilder::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 1351 of file flatbuffers.h.

1351{ force_defaults_ = fd; }

References force_defaults_.

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

◆ GetBufferMinAlignment()

size_t flatbuffers::FlatBufferBuilder::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 1328 of file flatbuffers.h.

1329 {
1330 Finished();
1331 return minalign_;
1332 }

References minalign_.

◆ GetBufferPointer()

uint8_t * flatbuffers::FlatBufferBuilder::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 1270 of file flatbuffers.h.

1271 {
1272 Finished();
1273 return buf_.data();
1274 }

References buf_, and flatbuffers::vector_downward::data().

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

◆ GetBufferSpan()

flatbuffers::span< uint8_t > flatbuffers::FlatBufferBuilder::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 1279 of file flatbuffers.h.

1280 {
1281 Finished();
1282 return flatbuffers::span<uint8_t>(buf_.data(), buf_.size());
1283 }

References buf_, flatbuffers::vector_downward::data(), and flatbuffers::vector_downward::size().

◆ GetCurrentBufferPointer()

uint8_t * flatbuffers::FlatBufferBuilder::GetCurrentBufferPointer ( ) const
inline

Get a pointer to an unfinished buffer.

Returns
Returns a uint8_t pointer to the unfinished buffer.

Definition at line 1287 of file flatbuffers.h.

1287{ return buf_.data(); }

References buf_, and flatbuffers::vector_downward::data().

◆ GetSize()

uoffset_t flatbuffers::FlatBufferBuilder::GetSize ( ) const
inline

The current size of the serialized buffer, counting from the end.

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

Definition at line 1265 of file flatbuffers.h.

1265{ return buf_.size(); }

References buf_, and flatbuffers::vector_downward::size().

Referenced by luci::check_size_limit(), CreateString(), CreateStruct(), CreateUninitializedVector(), Finish(), luci::CircleExporterImpl::getBufferSize(), onert::exporter::TrainInfoBuilder::size(), and onert::exporter::TrainInfoBuilder::TrainInfoBuilder().

◆ operator=() [1/2]

FlatBufferBuilder & flatbuffers::FlatBufferBuilder::operator= ( const FlatBufferBuilder )
protected

◆ operator=() [2/2]

FlatBufferBuilder & flatbuffers::FlatBufferBuilder::operator= ( FlatBufferBuilder &&  other)
inline

Move assignment operator for FlatBufferBuilder.

Definition at line 1214 of file flatbuffers.h.

1215 {
1216 // Move construct a temporary and swap idiom
1217 FlatBufferBuilder temp(std::move(other));
1218 Swap(temp);
1219 return *this;
1220 }
FlatBufferBuilder(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 Swap().

◆ Release()

DetachedBuffer flatbuffers::FlatBufferBuilder::Release ( )
inline

Get the released DetachedBuffer.

Returns
A DetachedBuffer that owns the buffer and its allocator.

Definition at line 1302 of file flatbuffers.h.

1303 {
1304 Finished();
1305 return buf_.release();
1306 }

References buf_, and flatbuffers::vector_downward::release().

◆ ReleaseRaw()

uint8_t * flatbuffers::FlatBufferBuilder::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 1317 of file flatbuffers.h.

1318 {
1319 Finished();
1320 return buf_.release_raw(size, offset);
1321 }
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
int32_t size[5]
Definition Slice.cpp:35

References buf_, offset(), flatbuffers::vector_downward::release_raw(), and size.

Referenced by flatbuffers::grpc::MessageBuilder::ReleaseRaw().

◆ Reset()

void flatbuffers::FlatBufferBuilder::Reset ( )
inline

Definition at line 1244 of file flatbuffers.h.

1245 {
1246 Clear(); // clear builder state
1247 buf_.reset(); // deallocate buffer
1248 }
void Clear()
Reset all the state in this FlatBufferBuilder so it can be reused to construct another buffer.

References buf_, Clear(), and flatbuffers::vector_downward::reset().

Referenced by flatbuffers::grpc::MessageBuilder::ReleaseMessage().

◆ Swap()

void flatbuffers::FlatBufferBuilder::Swap ( FlatBufferBuilder other)
inline

Definition at line 1224 of file flatbuffers.h.

1225 {
1226 using std::swap;
1227 buf_.swap(other.buf_);
1228 swap(num_field_loc, other.num_field_loc);
1229 swap(max_voffset_, other.max_voffset_);
1230 swap(nested, other.nested);
1231 swap(finished, other.finished);
1232 swap(minalign_, other.minalign_);
1233 swap(force_defaults_, other.force_defaults_);
1234 swap(dedup_vtables_, other.dedup_vtables_);
1235 swap(string_pool, other.string_pool);
1236 }
void swap(vector_downward &other)

References buf_, dedup_vtables_, finished, force_defaults_, max_voffset_, minalign_, nested, num_field_loc, string_pool, and flatbuffers::vector_downward::swap().

Referenced by FlatBufferBuilder(), flatbuffers::grpc::MessageBuilder::MessageBuilder(), operator=(), and flatbuffers::grpc::MessageBuilder::Swap().

◆ SwapBufAllocator()

void flatbuffers::FlatBufferBuilder::SwapBufAllocator ( FlatBufferBuilder other)
inline

Definition at line 2214 of file flatbuffers.h.

2214{ buf_.swap_allocator(other.buf_); }
void swap_allocator(vector_downward &other)

References buf_, and flatbuffers::vector_downward::swap_allocator().

Field Documentation

◆ buf_

◆ dedup_vtables_

bool flatbuffers::FlatBufferBuilder::dedup_vtables_
protected

Definition at line 2267 of file flatbuffers.h.

Referenced by DedupVtables(), and Swap().

◆ finished

bool flatbuffers::FlatBufferBuilder::finished
protected

Definition at line 2261 of file flatbuffers.h.

Referenced by Clear(), Finish(), and Swap().

◆ force_defaults_

bool flatbuffers::FlatBufferBuilder::force_defaults_
protected

Definition at line 2265 of file flatbuffers.h.

Referenced by ForceDefaults(), and Swap().

◆ kFileIdentifierLength

const size_t flatbuffers::FlatBufferBuilder::kFileIdentifierLength = 4
static

The length of a FlatBuffer file header.

Definition at line 2191 of file flatbuffers.h.

Referenced by Finish(), and flatbuffers::Registry::FlatBufferToText().

◆ max_voffset_

voffset_t flatbuffers::FlatBufferBuilder::max_voffset_
protected

Definition at line 2255 of file flatbuffers.h.

Referenced by Swap().

◆ minalign_

size_t flatbuffers::FlatBufferBuilder::minalign_
protected

Definition at line 2263 of file flatbuffers.h.

Referenced by Clear(), Finish(), GetBufferMinAlignment(), and Swap().

◆ nested

bool flatbuffers::FlatBufferBuilder::nested
protected

Definition at line 2258 of file flatbuffers.h.

Referenced by Clear(), and Swap().

◆ num_field_loc

uoffset_t flatbuffers::FlatBufferBuilder::num_field_loc
protected

Definition at line 2252 of file flatbuffers.h.

Referenced by Swap().

◆ string_pool

StringOffsetMap* flatbuffers::FlatBufferBuilder::string_pool
protected

Definition at line 2283 of file flatbuffers.h.

Referenced by Clear(), CreateSharedString(), Swap(), and ~FlatBufferBuilder().


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