ONE - On-device Neural Engine
Loading...
Searching...
No Matches
flatbuffers Namespace Reference

Namespaces

namespace  grpc
 
namespace  internal
 

Data Structures

class  Allocator
 
class  Array
 
class  Array< Offset< T >, length >
 
class  BaseGenerator
 
struct  bool_constant
 
class  CheckedError
 
class  CodeWriter
 
struct  CommentConfig
 
struct  conditional
 
class  DefaultAllocator
 
struct  Definition
 
class  DetachedBuffer
 
struct  EnumDef
 
struct  EnumVal
 
struct  FieldDef
 
class  FlatBufferBuilder
 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...
 
class  FLATBUFFERS_FINAL_CLASS
 
class  FlatCompiler
 
class  FloatConstantGenerator
 
struct  FnvTraits
 
struct  FnvTraits< uint32_t >
 
struct  FnvTraits< uint64_t >
 
struct  IDLOptions
 
struct  IndirectHelper
 
struct  IndirectHelper< const T * >
 
struct  IndirectHelper< Offset< T > >
 
struct  integral_constant
 
struct  is_enum
 
struct  is_floating_point
 
struct  is_same
 
struct  is_scalar
 
struct  is_unsigned
 
struct  IterationVisitor
 
struct  make_unsigned
 
struct  NamedHashFunction
 
struct  Namespace
 
struct  nullopt_t
 
class  numeric_limits
 
struct  Offset
 
class  Parser
 
struct  ParserState
 
class  pointer_inside_vector
 
class  Registry
 
struct  RPCCall
 
struct  ServiceDef
 
class  SimpleFloatConstantGenerator
 
struct  String
 
struct  StructDef
 
class  SymbolTable
 
struct  ToStringVisitor
 
struct  Type
 
class  TypedFloatConstantGenerator
 
class  unique_ptr
 
struct  Value
 
class  Vector
 
class  vector_downward
 
struct  VectorIterator
 
class  VectorOfAny
 
struct  VectorReverseIterator
 

Typedefs

typedef bool(* LoadFileFunction) (const char *filename, bool binary, std::string *dest)
 
typedef bool(* FileExistsFunction) (const char *filename)
 

Enumerations

enum  BaseType
 

Functions

void GenComment (const std::vector< std::string > &dc, std::string *code_ptr, const CommentConfig *config, const char *prefix="")
 
template<typename T >
bool IsTheSameAs (T e, T def)
 
template<typename T >
bool IsOutRange (const T &v, const T &low, const T &high)
 
template<typename T >
bool IsInRange (const T &v, const T &low, const T &high)
 
void EndianCheck ()
 
template<typename T >
FLATBUFFERS_CONSTEXPR size_t AlignOf ()
 
template<typename T , typename U >
Vector< Offset< T > > * VectorCast (Vector< Offset< U > > *ptr)
 
template<typename T , typename U >
const Vector< Offset< T > > * VectorCast (const Vector< Offset< U > > *ptr)
 
template<typename T , uint16_t length>
Array< T, length > & CastToArray (T(&arr)[length])
 
template<typename T , uint16_t length>
const Array< T, length > & CastToArray (const T(&arr)[length])
 
template<typename E , typename T , uint16_t length>
Array< E, length > & CastToArrayOfEnum (T(&arr)[length])
 
template<typename E , typename T , uint16_t length>
const Array< E, length > & CastToArrayOfEnum (const T(&arr)[length])
 
uint8_t * Allocate (Allocator *allocator, size_t size)
 
void Deallocate (Allocator *allocator, uint8_t *p, size_t size)
 
uint8_t * ReallocateDownward (Allocator *allocator, uint8_t *old_p, size_t old_size, size_t new_size, size_t in_use_back, size_t in_use_front)
 
voffset_t FieldIndexToOffset (voffset_t field_id)
 
template<typename T , typename Alloc >
const T * data (const std::vector< T, Alloc > &v)
 
template<typename T , typename Alloc >
T * data (std::vector< T, Alloc > &v)
 
void LogCompilerWarn (const std::string &warn)
 
void LogCompilerError (const std::string &err)
 
template<typename T >
HashFnv1 (const char *input)
 
template<typename T >
HashFnv1a (const char *input)
 
template<>
uint16_t HashFnv1< uint16_t > (const char *input)
 
template<>
uint16_t HashFnv1a< uint16_t > (const char *input)
 
NamedHashFunction< uint16_t >::HashFunction FindHashFunction16 (const char *name)
 
NamedHashFunction< uint32_t >::HashFunction FindHashFunction32 (const char *name)
 
NamedHashFunction< uint64_t >::HashFunction FindHashFunction64 (const char *name)
 
bool IsScalar (BaseType t)
 
bool IsInteger (BaseType t)
 
bool IsFloat (BaseType t)
 
bool IsLong (BaseType t)
 
bool IsBool (BaseType t)
 
bool IsOneByte (BaseType t)
 
bool IsUnsigned (BaseType t)
 
size_t SizeOf (BaseType t)
 
bool operator< (const Namespace &a, const Namespace &b)
 
bool IsString (const Type &type)
 
bool IsStruct (const Type &type)
 
bool IsUnion (const Type &type)
 
bool IsVector (const Type &type)
 
bool IsArray (const Type &type)
 
bool IsSeries (const Type &type)
 
bool IsEnum (const Type &type)
 
size_t InlineSize (const Type &type)
 
size_t InlineAlignment (const Type &type)
 
bool operator== (const EnumVal &lhs, const EnumVal &rhs)
 
bool operator!= (const EnumVal &lhs, const EnumVal &rhs)
 
bool EqualByName (const Type &a, const Type &b)
 
std::string MakeCamel (const std::string &in, bool first=true)
 
std::string MakeScreamingCamel (const std::string &in)
 
bool GenerateTextFromTable (const Parser &parser, const void *table, const std::string &tablename, std::string *text)
 
bool GenerateText (const Parser &parser, const void *flatbuffer, std::string *text)
 
bool GenerateTextFile (const Parser &parser, const std::string &path, const std::string &file_name)
 
bool GenerateJsonSchema (const Parser &parser, std::string *json)
 
bool GenerateBinary (const Parser &parser, const std::string &path, const std::string &file_name)
 
bool GenerateCPP (const Parser &parser, const std::string &path, const std::string &file_name)
 
bool GenerateCSharp (const Parser &parser, const std::string &path, const std::string &file_name)
 
bool GenerateDart (const Parser &parser, const std::string &path, const std::string &file_name)
 
bool GenerateJava (const Parser &parser, const std::string &path, const std::string &file_name)
 
bool GenerateTS (const Parser &parser, const std::string &path, const std::string &file_name)
 
bool GenerateGo (const Parser &parser, const std::string &path, const std::string &file_name)
 
bool GeneratePhp (const Parser &parser, const std::string &path, const std::string &file_name)
 
bool GeneratePython (const Parser &parser, const std::string &path, const std::string &file_name)
 
bool GenerateLobster (const Parser &parser, const std::string &path, const std::string &file_name)
 
bool GenerateLua (const Parser &parser, const std::string &path, const std::string &file_name)
 
bool GenerateRust (const Parser &parser, const std::string &path, const std::string &file_name)
 
bool GenerateJsonSchema (const Parser &parser, const std::string &path, const std::string &file_name)
 
bool GenerateKotlin (const Parser &parser, const std::string &path, const std::string &file_name)
 
bool GenerateSwift (const Parser &parser, const std::string &path, const std::string &file_name)
 
std::string GenerateFBS (const Parser &parser, const std::string &file_name)
 
bool GenerateFBS (const Parser &parser, const std::string &path, const std::string &file_name)
 
std::string TSMakeRule (const Parser &parser, const std::string &path, const std::string &file_name)
 
std::string CPPMakeRule (const Parser &parser, const std::string &path, const std::string &file_name)
 
std::string DartMakeRule (const Parser &parser, const std::string &path, const std::string &file_name)
 
std::string RustMakeRule (const Parser &parser, const std::string &path, const std::string &file_name)
 
std::string JavaCSharpMakeRule (const Parser &parser, const std::string &path, const std::string &file_name)
 
std::string TextMakeRule (const Parser &parser, const std::string &path, const std::string &file_names)
 
std::string BinaryMakeRule (const Parser &parser, const std::string &path, const std::string &file_name)
 
bool GenerateCppGRPC (const Parser &parser, const std::string &path, const std::string &file_name)
 
bool GenerateGoGRPC (const Parser &parser, const std::string &path, const std::string &file_name)
 
bool GenerateJavaGRPC (const Parser &parser, const std::string &path, const std::string &file_name)
 
bool GeneratePythonGRPC (const Parser &parser, const std::string &path, const std::string &file_name)
 
bool GenerateSwiftGRPC (const Parser &parser, const std::string &path, const std::string &file_name)
 
bool GenerateTSGRPC (const Parser &parser, const std::string &path, const std::string &file_name)
 
size_t InlineSize (ElementaryType type, const TypeTable *type_table)
 
int64_t LookupEnum (int64_t enum_val, const int64_t *values, size_t num_values)
 
template<typename T >
const char * EnumName (T tval, const TypeTable *type_table)
 
void IterateObject (const uint8_t *obj, const TypeTable *type_table, IterationVisitor *visitor)
 
void IterateValue (ElementaryType type, const uint8_t *val, const TypeTable *type_table, const uint8_t *prev_val, soffset_t vector_index, IterationVisitor *visitor)
 
void IterateFlatBuffer (const uint8_t *buffer, const TypeTable *type_table, IterationVisitor *callback)
 
std::string FlatBufferToString (const uint8_t *buffer, const TypeTable *type_table, bool multi_line=false, bool vector_delimited=true)
 
bool IsScalar (reflection::BaseType t)
 
bool IsInteger (reflection::BaseType t)
 
bool IsFloat (reflection::BaseType t)
 
bool IsLong (reflection::BaseType t)
 
size_t GetTypeSize (reflection::BaseType base_type)
 
size_t GetTypeSizeInline (reflection::BaseType base_type, int type_index, const reflection::Schema &schema)
 
Table * GetAnyRoot (uint8_t *flatbuf)
 
const Table * GetAnyRoot (const uint8_t *flatbuf)
 
template<typename T >
GetFieldDefaultI (const reflection::Field &field)
 
template<typename T >
GetFieldDefaultF (const reflection::Field &field)
 
template<typename T >
GetFieldI (const Table &table, const reflection::Field &field)
 
template<typename T >
GetFieldF (const Table &table, const reflection::Field &field)
 
const StringGetFieldS (const Table &table, const reflection::Field &field)
 
template<typename T >
Vector< T > * GetFieldV (const Table &table, const reflection::Field &field)
 
VectorOfAnyGetFieldAnyV (const Table &table, const reflection::Field &field)
 
Table * GetFieldT (const Table &table, const reflection::Field &field)
 
const Struct * GetFieldStruct (const Table &table, const reflection::Field &field)
 
const Struct * GetFieldStruct (const Struct &structure, const reflection::Field &field)
 
int64_t GetAnyValueI (reflection::BaseType type, const uint8_t *data)
 
double GetAnyValueF (reflection::BaseType type, const uint8_t *data)
 
std::string GetAnyValueS (reflection::BaseType type, const uint8_t *data, const reflection::Schema *schema, int type_index)
 
int64_t GetAnyFieldI (const Table &table, const reflection::Field &field)
 
double GetAnyFieldF (const Table &table, const reflection::Field &field)
 
std::string GetAnyFieldS (const Table &table, const reflection::Field &field, const reflection::Schema *schema)
 
int64_t GetAnyFieldI (const Struct &st, const reflection::Field &field)
 
double GetAnyFieldF (const Struct &st, const reflection::Field &field)
 
std::string GetAnyFieldS (const Struct &st, const reflection::Field &field)
 
int64_t GetAnyVectorElemI (const VectorOfAny *vec, reflection::BaseType elem_type, size_t i)
 
double GetAnyVectorElemF (const VectorOfAny *vec, reflection::BaseType elem_type, size_t i)
 
std::string GetAnyVectorElemS (const VectorOfAny *vec, reflection::BaseType elem_type, size_t i)
 
template<typename T >
T * GetAnyVectorElemPointer (const VectorOfAny *vec, size_t i)
 
template<typename T >
T * GetAnyVectorElemAddressOf (const VectorOfAny *vec, size_t i, size_t elem_size)
 
template<typename T >
T * GetAnyFieldAddressOf (const Table &table, const reflection::Field &field)
 
template<typename T >
T * GetAnyFieldAddressOf (const Struct &st, const reflection::Field &field)
 
template<typename T >
bool SetField (Table *table, const reflection::Field &field, T val)
 
void SetAnyValueI (reflection::BaseType type, uint8_t *data, int64_t val)
 
void SetAnyValueF (reflection::BaseType type, uint8_t *data, double val)
 
void SetAnyValueS (reflection::BaseType type, uint8_t *data, const char *val)
 
bool SetAnyFieldI (Table *table, const reflection::Field &field, int64_t val)
 
bool SetAnyFieldF (Table *table, const reflection::Field &field, double val)
 
bool SetAnyFieldS (Table *table, const reflection::Field &field, const char *val)
 
void SetAnyFieldI (Struct *st, const reflection::Field &field, int64_t val)
 
void SetAnyFieldF (Struct *st, const reflection::Field &field, double val)
 
void SetAnyFieldS (Struct *st, const reflection::Field &field, const char *val)
 
void SetAnyVectorElemI (VectorOfAny *vec, reflection::BaseType elem_type, size_t i, int64_t val)
 
void SetAnyVectorElemF (VectorOfAny *vec, reflection::BaseType elem_type, size_t i, double val)
 
void SetAnyVectorElemS (VectorOfAny *vec, reflection::BaseType elem_type, size_t i, const char *val)
 
template<typename T , typename U >
pointer_inside_vector< T, U > piv (T *ptr, std::vector< U > &vec)
 
const char * UnionTypeFieldSuffix ()
 
const reflection::Object & GetUnionType (const reflection::Schema &schema, const reflection::Object &parent, const reflection::Field &unionfield, const Table &table)
 
void SetString (const reflection::Schema &schema, const std::string &val, const String *str, std::vector< uint8_t > *flatbuf, const reflection::Object *root_table=nullptr)
 
uint8_t * ResizeAnyVector (const reflection::Schema &schema, uoffset_t newsize, const VectorOfAny *vec, uoffset_t num_elems, uoffset_t elem_size, std::vector< uint8_t > *flatbuf, const reflection::Object *root_table=nullptr)
 
template<typename T >
void ResizeVector (const reflection::Schema &schema, uoffset_t newsize, T val, const Vector< T > *vec, std::vector< uint8_t > *flatbuf, const reflection::Object *root_table=nullptr)
 
const uint8_t * AddFlatBuffer (std::vector< uint8_t > &flatbuf, const uint8_t *newbuf, size_t newlen)
 
bool SetFieldT (Table *table, const reflection::Field &field, const uint8_t *val)
 
Offset< const Table * > CopyTable (FlatBufferBuilder &fbb, const reflection::Schema &schema, const reflection::Object &objectdef, const Table &table, bool use_string_pooling=false)
 
bool Verify (const reflection::Schema &schema, const reflection::Object &root, const uint8_t *buf, size_t length, uoffset_t max_depth=64, uoffset_t max_tables=1000000)
 
char & string_back (std::string &value)
 
char string_back (const std::string &value)
 
template<typename T >
T * vector_data (std::vector< T > &vector)
 
template<typename T >
const T * vector_data (const std::vector< T > &vector)
 
template<typename T , typename V >
void vector_emplace_back (std::vector< T > *vector, V &&data)
 
template<class T >
FLATBUFFERS_CONSTEXPR_CPP11 bool operator== (const Optional< T > &opt, nullopt_t) FLATBUFFERS_NOEXCEPT
 
template<class T >
FLATBUFFERS_CONSTEXPR_CPP11 bool operator== (nullopt_t, const Optional< T > &opt) FLATBUFFERS_NOEXCEPT
 
template<class T , class U >
FLATBUFFERS_CONSTEXPR_CPP11 bool operator== (const Optional< T > &lhs, const U &rhs) FLATBUFFERS_NOEXCEPT
 
template<class T , class U >
FLATBUFFERS_CONSTEXPR_CPP11 bool operator== (const T &lhs, const Optional< U > &rhs) FLATBUFFERS_NOEXCEPT
 
template<class T , class U >
FLATBUFFERS_CONSTEXPR_CPP11 bool operator== (const Optional< T > &lhs, const Optional< U > &rhs) FLATBUFFERS_NOEXCEPT
 
bool check_ascii_range (char x, char a, char b)
 
bool is_alpha (char c)
 
bool is_alpha_upper (char c)
 
bool is_alpha_char (char c, char alpha)
 
bool is_digit (char c)
 
bool is_xdigit (char c)
 
bool is_alnum (char c)
 
char CharToUpper (char c)
 
char CharToLower (char c)
 
template<typename T >
std::string NumToString (T t)
 
template<>
std::string NumToString< signed char > (signed char t)
 
template<>
std::string NumToString< unsigned char > (unsigned char t)
 
template<>
std::string NumToString< char > (char t)
 
template<typename T >
std::string FloatToString (T t, int precision)
 
template<>
std::string NumToString< double > (double t)
 
template<>
std::string NumToString< float > (float t)
 
std::string IntToStringHex (int i, int xdigits)
 
void strtoval_impl (int64_t *val, const char *str, char **endptr, int base)
 
void strtoval_impl (uint64_t *val, const char *str, char **endptr, int base)
 
void strtoval_impl (double *val, const char *str, char **endptr)
 
 __supress_ubsan__ ("float-cast-overflow") inline void strtoval_impl(float *val
 
template<typename T >
bool StringToIntegerImpl (T *val, const char *const str, const int base=0, const bool check_errno=true)
 
template<typename T >
bool StringToFloatImpl (T *val, const char *const str)
 
template<typename T >
bool StringToNumber (const char *s, T *val)
 
template<>
bool StringToNumber< int64_t > (const char *str, int64_t *val)
 
template<>
bool StringToNumber< uint64_t > (const char *str, uint64_t *val)
 
template<>
bool StringToNumber (const char *s, float *val)
 
template<>
bool StringToNumber (const char *s, double *val)
 
int64_t StringToInt (const char *s, int base=10)
 
uint64_t StringToUInt (const char *s, int base=10)
 
LoadFileFunction SetLoadFileFunction (LoadFileFunction load_file_function)
 
FileExistsFunction SetFileExistsFunction (FileExistsFunction file_exists_function)
 
bool FileExists (const char *name)
 
bool DirExists (const char *name)
 
bool LoadFile (const char *name, bool binary, std::string *buf)
 
bool SaveFile (const char *name, const char *buf, size_t len, bool binary)
 
bool SaveFile (const char *name, const std::string &buf, bool binary)
 
std::string StripExtension (const std::string &filepath)
 
std::string GetExtension (const std::string &filepath)
 
std::string StripPath (const std::string &filepath)
 
std::string StripFileName (const std::string &filepath)
 
std::string ConCatPathFileName (const std::string &path, const std::string &filename)
 
std::string PosixPath (const char *path)
 
void EnsureDirExists (const std::string &filepath)
 
std::string AbsolutePath (const std::string &filepath)
 
int ToUTF8 (uint32_t ucc, std::string *out)
 
int FromUTF8 (const char **in)
 
std::string WordWrap (const std::string in, size_t max_length, const std::string wrapped_line_prefix, const std::string wrapped_line_suffix)
 
bool EscapeString (const char *s, size_t length, std::string *_text, bool allow_non_utf8, bool natural_utf8)
 
std::string BufferToHexText (const void *buffer, size_t buffer_size, size_t max_length, const std::string &wrapped_line_prefix, const std::string &wrapped_line_suffix)
 
std::string RemoveStringQuotes (const std::string &s)
 
bool SetGlobalTestLocale (const char *locale_name, std::string *_value=nullptr)
 
bool ReadEnvironmentVariable (const char *var_name, std::string *_value=nullptr)
 
void SetupDefaultCRTReportMode ()
 

Variables

const NamedHashFunction< uint16_t > kHashFunctions16 []
 
const NamedHashFunction< uint32_t > kHashFunctions32 []
 
const NamedHashFunction< uint64_t > kHashFunctions64 []
 
const char *const kTypeNames []
 
const char kTypeSizes []
 
FLATBUFFERS_CONSTEXPR std::size_t dynamic_extent = static_cast<std::size_t>(-1)
 
const char * str
 
const char char ** endptr
 
FLATBUFFERS_CONSTEXPR char kPathSeparator = '/'
 

Typedef Documentation

◆ FileExistsFunction

typedef bool(* flatbuffers::FileExistsFunction) (const char *filename)

Definition at line 448 of file util.h.

◆ LoadFileFunction

typedef bool(* flatbuffers::LoadFileFunction) (const char *filename, bool binary, std::string *dest)

Definition at line 447 of file util.h.

Enumeration Type Documentation

◆ BaseType

Definition at line 119 of file idl.h.

119 {
120 #define FLATBUFFERS_TD(ENUM, ...) \
121 BASE_TYPE_ ## ENUM,
123 #undef FLATBUFFERS_TD
124};
#define FLATBUFFERS_TD(ENUM,...)
Definition idl.h:120
#define FLATBUFFERS_GEN_TYPES(TD)
Definition idl.h:110

Function Documentation

◆ __supress_ubsan__()

flatbuffers::__supress_ubsan__ ( "float-cast-overflow"  )

◆ AbsolutePath()

std::string flatbuffers::AbsolutePath ( const std::string &  filepath)

◆ AddFlatBuffer()

const uint8_t * flatbuffers::AddFlatBuffer ( std::vector< uint8_t > &  flatbuf,
const uint8_t *  newbuf,
size_t  newlen 
)

◆ AlignOf()

template<typename T >
FLATBUFFERS_CONSTEXPR size_t flatbuffers::AlignOf ( )

Definition at line 86 of file flatbuffers.h.

87{
88#ifdef _MSC_VER
89 return __alignof(T);
90#else
91#ifndef alignof
92 return __alignof__(T);
93#else
94 return alignof(T);
95#endif
96#endif
97 // clang-format on
98}

◆ Allocate()

uint8_t * flatbuffers::Allocate ( Allocator allocator,
size_t  size 
)
inline

Definition at line 731 of file flatbuffers.h.

732{
733 return allocator ? allocator->allocate(size) : DefaultAllocator().allocate(size);
734}
virtual uint8_t * allocate(size_t size)=0
uint8_t * allocate(size_t size) FLATBUFFERS_OVERRIDE
int32_t size[5]
Definition Slice.cpp:35

References flatbuffers::DefaultAllocator::allocate(), flatbuffers::Allocator::allocate(), and size.

◆ BinaryMakeRule()

std::string flatbuffers::BinaryMakeRule ( const Parser parser,
const std::string &  path,
const std::string &  file_name 
)
extern

◆ BufferToHexText()

std::string flatbuffers::BufferToHexText ( const void *  buffer,
size_t  buffer_size,
size_t  max_length,
const std::string &  wrapped_line_prefix,
const std::string &  wrapped_line_suffix 
)
inline

Definition at line 753 of file util.h.

756{
757 std::string text = wrapped_line_prefix;
758 size_t start_offset = 0;
759 const char *s = reinterpret_cast<const char *>(buffer);
760 for (size_t i = 0; s && i < buffer_size; i++)
761 {
762 // Last iteration or do we have more?
763 bool have_more = i + 1 < buffer_size;
764 text += "0x";
765 text += IntToStringHex(static_cast<uint8_t>(s[i]), 2);
766 if (have_more)
767 {
768 text += ',';
769 }
770 // If we have more to process and we reached max_length
771 if (have_more && text.size() + wrapped_line_suffix.size() >= start_offset + max_length)
772 {
773 text += wrapped_line_suffix;
774 text += '\n';
775 start_offset = text.size();
776 text += wrapped_line_prefix;
777 }
778 }
779 text += wrapped_line_suffix;
780 return text;
781}
std::string IntToStringHex(int i, int xdigits)
Definition util.h:218

References IntToStringHex().

◆ CastToArray() [1/2]

template<typename T , uint16_t length>
const Array< T, length > & flatbuffers::CastToArray ( const T(&)  arr[length])

Definition at line 614 of file flatbuffers.h.

615{
616 return *reinterpret_cast<const Array<T, length> *>(arr);
617}

◆ CastToArray() [2/2]

template<typename T , uint16_t length>
Array< T, length > & flatbuffers::CastToArray ( T(&)  arr[length])

Definition at line 609 of file flatbuffers.h.

610{
611 return *reinterpret_cast<Array<T, length> *>(arr);
612}

◆ CastToArrayOfEnum() [1/2]

template<typename E , typename T , uint16_t length>
const Array< E, length > & flatbuffers::CastToArrayOfEnum ( const T(&)  arr[length])

Definition at line 627 of file flatbuffers.h.

628{
629 static_assert(sizeof(E) == sizeof(T), "invalid enum type E");
630 return *reinterpret_cast<const Array<E, length> *>(arr);
631}

◆ CastToArrayOfEnum() [2/2]

template<typename E , typename T , uint16_t length>
Array< E, length > & flatbuffers::CastToArrayOfEnum ( T(&)  arr[length])

Definition at line 620 of file flatbuffers.h.

621{
622 static_assert(sizeof(E) == sizeof(T), "invalid enum type E");
623 return *reinterpret_cast<Array<E, length> *>(arr);
624}

◆ CharToLower()

char flatbuffers::CharToLower ( char  c)
inline

Definition at line 90 of file util.h.

91{
92 return static_cast<char>(::tolower(static_cast<unsigned char>(c)));
93}

◆ CharToUpper()

char flatbuffers::CharToUpper ( char  c)
inline

Definition at line 85 of file util.h.

86{
87 return static_cast<char>(::toupper(static_cast<unsigned char>(c)));
88}

◆ check_ascii_range()

bool flatbuffers::check_ascii_range ( char  x,
char  a,
char  b 
)
inline

Definition at line 43 of file util.h.

44{
45 FLATBUFFERS_ASSERT(a <= b);
46 // (Hacker's Delight): `a <= x <= b` <=> `(x-a) <={u} (b-a)`.
47 // The x, a, b will be promoted to int and subtracted without overflow.
48 return static_cast<unsigned int>(x - a) <= static_cast<unsigned int>(b - a);
49}
#define FLATBUFFERS_ASSERT
Definition base.h:37

References FLATBUFFERS_ASSERT.

Referenced by is_alpha(), is_alpha_upper(), is_digit(), and is_xdigit().

◆ ConCatPathFileName()

std::string flatbuffers::ConCatPathFileName ( const std::string &  path,
const std::string &  filename 
)

◆ CopyTable()

Offset< const Table * > flatbuffers::CopyTable ( FlatBufferBuilder fbb,
const reflection::Schema &  schema,
const reflection::Object &  objectdef,
const Table &  table,
bool  use_string_pooling = false 
)

◆ CPPMakeRule()

std::string flatbuffers::CPPMakeRule ( const Parser parser,
const std::string &  path,
const std::string &  file_name 
)
extern

◆ DartMakeRule()

std::string flatbuffers::DartMakeRule ( const Parser parser,
const std::string &  path,
const std::string &  file_name 
)
extern

◆ data() [1/2]

template<typename T , typename Alloc >
const T * flatbuffers::data ( const std::vector< T, Alloc > &  v)

Definition at line 1145 of file flatbuffers.h.

1146{
1147 // Eventually the returned pointer gets passed down to memcpy, so
1148 // we need it to be non-null to avoid undefined behavior.
1149 static uint8_t t;
1150 return v.empty() ? reinterpret_cast<const T *>(&t) : &v.front();
1151}

Referenced by luci_interpreter::BuddyMemoryManager::allocate_memory(), luci_interpreter::SimpleMemoryManager::allocate_memory(), luci_interpreter::TestMemoryManager::allocate_memory(), luci_interpreter::Interpreter::allocateAndWriteInputTensor(), luci::asymmetric_wquant_with_minmax_per_layer(), luci::compute::DepthwiseConv2D::bias(), luci::compute::FullyConnected::bias(), luci_interpreter::RuntimeGraph::configureGraphInput(), luci_interpreter::RuntimeGraph::configureGraphInput(), flatbuffers::FlatBufferBuilder::CreateVector(), flatbuffers::FlatBufferBuilder::CreateVectorOfNativeStructs(), flatbuffers::FlatBufferBuilder::CreateVectorOfNativeStructs(), flatbuffers::FlatBufferBuilder::CreateVectorOfNativeStructs(), flatbuffers::FlatBufferBuilder::CreateVectorOfSortedNativeStructs(), flatbuffers::FlatBufferBuilder::CreateVectorOfSortedStructs(), flatbuffers::FlatBufferBuilder::CreateVectorOfSortedTables(), flatbuffers::FlatBufferBuilder::CreateVectorOfStructs(), luci_interpreter::kernels::testing::dequantize(), luci_interpreter::kernels::testing::dequantizeTensorData(), luci::CircleExportMetadata::encoded_execution_plan_table(), luci::CircleExportMetadata::encoded_op_table(), luci::CircleExportMetadata::encoded_source_table(), luci_interpreter::execute_kernel_CircleLogicalNot(), luci_interpreter::execute_kernel_CircleMirrorPad(), luci::compute::DepthwiseConv2D::filter(), luci::Importer::importModule(), luci::compute::DepthwiseConv2D::input(), luci::compute::FullyConnected::input(), luci_interpreter::RuntimeGraph::makeInplaceOperation(), luci_interpreter::kernels::testing::makeInputTensor(), luci_interpreter::kernels::testing::makeInputTensor(), luci_interpreter::kernels::testing::makeInputTensor(), luci::compute::DepthwiseConv2D::output(), luci::compute::FullyConnected::output(), luci::CircleReader::parse(), luci::quant_const(), luci_interpreter::kernels::testing::quantize(), luci_interpreter::Interpreter::readOutputTensor(), luci_interpreter::BuddyMemoryManager::release_memory(), luci_interpreter::SimpleMemoryManager::release_memory(), luci_interpreter::SimpleMemoryManager::release_memory(), luci_interpreter::RuntimeGraph::resetOutputTensorsData(), luci_interpreter::RuntimeGraph::resetTensorData(), luci_interpreter::RuntimeGraph::setDataToTensor(), luci::symmetric_wquant_with_minmax_per_layer(), vector_emplace_back(), luci::compute::FullyConnected::weights(), and luci_interpreter::Interpreter::writeInputTensor().

◆ data() [2/2]

template<typename T , typename Alloc >
T * flatbuffers::data ( std::vector< T, Alloc > &  v)

Definition at line 1152 of file flatbuffers.h.

1153{
1154 // Eventually the returned pointer gets passed down to memcpy, so
1155 // we need it to be non-null to avoid undefined behavior.
1156 static uint8_t t;
1157 return v.empty() ? reinterpret_cast<T *>(&t) : &v.front();
1158}

◆ Deallocate()

void flatbuffers::Deallocate ( Allocator allocator,
uint8_t *  p,
size_t  size 
)
inline

Definition at line 736 of file flatbuffers.h.

737{
738 if (allocator)
739 allocator->deallocate(p, size);
740 else
742}
virtual void deallocate(uint8_t *p, size_t size)=0
void deallocate(uint8_t *p, size_t) FLATBUFFERS_OVERRIDE

References flatbuffers::Allocator::deallocate(), flatbuffers::DefaultAllocator::deallocate(), and size.

Referenced by flatbuffers::vector_downward::clear_buffer(), and flatbuffers::DetachedBuffer::destroy().

◆ DirExists()

bool flatbuffers::DirExists ( const char *  name)

◆ EndianCheck()

void flatbuffers::EndianCheck ( )
inline

Definition at line 78 of file flatbuffers.h.

79{
80 int endiantest = 1;
81 // If this fails, see FLATBUFFERS_LITTLEENDIAN above.
82 FLATBUFFERS_ASSERT(*reinterpret_cast<char *>(&endiantest) == FLATBUFFERS_LITTLEENDIAN);
83 (void)endiantest;
84}

References FLATBUFFERS_ASSERT.

Referenced by flatbuffers::FlatBufferBuilder::FlatBufferBuilder(), and flatbuffers::FlatBufferBuilder::FlatBufferBuilder().

◆ EnsureDirExists()

void flatbuffers::EnsureDirExists ( const std::string &  filepath)

◆ EnumName()

template<typename T >
const char * flatbuffers::EnumName ( tval,
const TypeTable *  type_table 
)

Definition at line 128 of file minireflect.h.

129{
130 if (!type_table || !type_table->names)
131 return nullptr;
132 auto i = LookupEnum(static_cast<int64_t>(tval), type_table->values, type_table->num_elems);
133 if (i >= 0 && i < static_cast<int64_t>(type_table->num_elems))
134 {
135 return type_table->names[i];
136 }
137 return nullptr;
138}
int64_t LookupEnum(int64_t enum_val, const int64_t *values, size_t num_values)

References LookupEnum().

Referenced by IterateValue().

◆ EqualByName()

bool flatbuffers::EqualByName ( const Type a,
const Type b 
)
inline

Definition at line 510 of file idl.h.

511{
512 return a.base_type == b.base_type && a.element == b.element &&
513 (a.struct_def == b.struct_def || a.struct_def->name == b.struct_def->name) &&
514 (a.enum_def == b.enum_def || a.enum_def->name == b.enum_def->name);
515}
std::string name
Definition idl.h:289
BaseType element
Definition idl.h:185
StructDef * struct_def
Definition idl.h:186
BaseType base_type
Definition idl.h:184
EnumDef * enum_def
Definition idl.h:187

References flatbuffers::Type::base_type, flatbuffers::Type::element, flatbuffers::Type::enum_def, flatbuffers::Definition::name, and flatbuffers::Type::struct_def.

◆ EscapeString()

bool flatbuffers::EscapeString ( const char *  s,
size_t  length,
std::string *  _text,
bool  allow_non_utf8,
bool  natural_utf8 
)
inline

Definition at line 652 of file util.h.

654{
655 std::string &text = *_text;
656 text += "\"";
657 for (uoffset_t i = 0; i < length; i++)
658 {
659 char c = s[i];
660 switch (c)
661 {
662 case '\n':
663 text += "\\n";
664 break;
665 case '\t':
666 text += "\\t";
667 break;
668 case '\r':
669 text += "\\r";
670 break;
671 case '\b':
672 text += "\\b";
673 break;
674 case '\f':
675 text += "\\f";
676 break;
677 case '\"':
678 text += "\\\"";
679 break;
680 case '\\':
681 text += "\\\\";
682 break;
683 default:
684 if (c >= ' ' && c <= '~')
685 {
686 text += c;
687 }
688 else
689 {
690 // Not printable ASCII data. Let's see if it's valid UTF-8 first:
691 const char *utf8 = s + i;
692 int ucc = FromUTF8(&utf8);
693 if (ucc < 0)
694 {
695 if (allow_non_utf8)
696 {
697 text += "\\x";
698 text += IntToStringHex(static_cast<uint8_t>(c), 2);
699 }
700 else
701 {
702 // There are two cases here:
703 //
704 // 1) We reached here by parsing an IDL file. In that case,
705 // we previously checked for non-UTF-8, so we shouldn't reach
706 // here.
707 //
708 // 2) We reached here by someone calling GenerateText()
709 // on a previously-serialized flatbuffer. The data might have
710 // non-UTF-8 Strings, or might be corrupt.
711 //
712 // In both cases, we have to give up and inform the caller
713 // they have no JSON.
714 return false;
715 }
716 }
717 else
718 {
719 if (natural_utf8)
720 {
721 // utf8 points to past all utf-8 bytes parsed
722 text.append(s + i, static_cast<size_t>(utf8 - s - i));
723 }
724 else if (ucc <= 0xFFFF)
725 {
726 // Parses as Unicode within JSON's \uXXXX range, so use that.
727 text += "\\u";
728 text += IntToStringHex(ucc, 4);
729 }
730 else if (ucc <= 0x10FFFF)
731 {
732 // Encode Unicode SMP values to a surrogate pair using two \u
733 // escapes.
734 uint32_t base = ucc - 0x10000;
735 auto high_surrogate = (base >> 10) + 0xD800;
736 auto low_surrogate = (base & 0x03FF) + 0xDC00;
737 text += "\\u";
738 text += IntToStringHex(high_surrogate, 4);
739 text += "\\u";
740 text += IntToStringHex(low_surrogate, 4);
741 }
742 // Skip past characters recognized.
743 i = static_cast<uoffset_t>(utf8 - s - 1);
744 }
745 }
746 break;
747 }
748 }
749 text += "\"";
750 return true;
751}

References FromUTF8(), and IntToStringHex().

Referenced by flatbuffers::ToStringVisitor::String(), and flexbuffers::Reference::ToString().

◆ FieldIndexToOffset()

voffset_t flatbuffers::FieldIndexToOffset ( voffset_t  field_id)
inline

Definition at line 1138 of file flatbuffers.h.

1139{
1140 // Should correspond to what EndTable() below builds up.
1141 const int fixed_fields = 2; // Vtable size and Object Size.
1142 return static_cast<voffset_t>((field_id + fixed_fields) * sizeof(voffset_t));
1143}

Referenced by IterateObject().

◆ FileExists()

bool flatbuffers::FileExists ( const char *  name)

◆ FindHashFunction16()

NamedHashFunction< uint16_t >::HashFunction flatbuffers::FindHashFunction16 ( const char *  name)
inline

Definition at line 104 of file hash.h.

105{
106 std::size_t size = sizeof(kHashFunctions16) / sizeof(kHashFunctions16[0]);
107 for (std::size_t i = 0; i < size; ++i)
108 {
109 if (std::strcmp(name, kHashFunctions16[i].name) == 0)
110 {
111 return kHashFunctions16[i].function;
112 }
113 }
114 return nullptr;
115}
const NamedHashFunction< uint16_t > kHashFunctions16[]
Definition hash.h:89

References flatbuffers::NamedHashFunction< T >::function, kHashFunctions16, and size.

◆ FindHashFunction32()

NamedHashFunction< uint32_t >::HashFunction flatbuffers::FindHashFunction32 ( const char *  name)
inline

Definition at line 117 of file hash.h.

118{
119 std::size_t size = sizeof(kHashFunctions32) / sizeof(kHashFunctions32[0]);
120 for (std::size_t i = 0; i < size; ++i)
121 {
122 if (std::strcmp(name, kHashFunctions32[i].name) == 0)
123 {
124 return kHashFunctions32[i].function;
125 }
126 }
127 return nullptr;
128}
const NamedHashFunction< uint32_t > kHashFunctions32[]
Definition hash.h:94

References flatbuffers::NamedHashFunction< T >::function, kHashFunctions32, and size.

◆ FindHashFunction64()

NamedHashFunction< uint64_t >::HashFunction flatbuffers::FindHashFunction64 ( const char *  name)
inline

Definition at line 130 of file hash.h.

131{
132 std::size_t size = sizeof(kHashFunctions64) / sizeof(kHashFunctions64[0]);
133 for (std::size_t i = 0; i < size; ++i)
134 {
135 if (std::strcmp(name, kHashFunctions64[i].name) == 0)
136 {
137 return kHashFunctions64[i].function;
138 }
139 }
140 return nullptr;
141}
const NamedHashFunction< uint64_t > kHashFunctions64[]
Definition hash.h:99

References flatbuffers::NamedHashFunction< T >::function, kHashFunctions64, and size.

◆ FlatBufferToString()

std::string flatbuffers::FlatBufferToString ( const uint8_t *  buffer,
const TypeTable *  type_table,
bool  multi_line = false,
bool  vector_delimited = true 
)
inline

Definition at line 497 of file minireflect.h.

499{
500 ToStringVisitor tostring_visitor(multi_line ? "\n" : " ", false, "", vector_delimited);
501 IterateFlatBuffer(buffer, type_table, &tostring_visitor);
502 return tostring_visitor.s;
503}
void IterateFlatBuffer(const uint8_t *buffer, const TypeTable *type_table, IterationVisitor *callback)

References IterateFlatBuffer(), and flatbuffers::ToStringVisitor::s.

◆ FloatToString()

template<typename T >
std::string flatbuffers::FloatToString ( t,
int  precision 
)

Definition at line 183 of file util.h.

184{
185 // clang-format off
186
187 #ifndef FLATBUFFERS_PREFER_PRINTF
188 // to_string() prints different numbers of digits for floats depending on
189 // platform and isn't available on Android, so we use stringstream
190 std::stringstream ss;
191 // Use std::fixed to suppress scientific notation.
192 ss << std::fixed;
193 // Default precision is 6, we want that to be higher for doubles.
194 ss << std::setprecision(precision);
195 ss << t;
196 auto s = ss.str();
197 #else // FLATBUFFERS_PREFER_PRINTF
198 auto v = static_cast<double>(t);
199 auto s = NumToStringImplWrapper(v, "%0.*f", precision);
200 #endif // FLATBUFFERS_PREFER_PRINTF
201 // clang-format on
202 // Sadly, std::fixed turns "1" into "1.00000", so here we undo that.
203 auto p = s.find_last_not_of('0');
204 if (p != std::string::npos)
205 {
206 // Strip trailing zeroes. If it is a whole number, keep one zero.
207 s.resize(p + (s[p] == '.' ? 2 : 1));
208 }
209 return s;
210}

Referenced by NumToString< double >(), and NumToString< float >().

◆ FromUTF8()

int flatbuffers::FromUTF8 ( const char **  in)
inline

Definition at line 552 of file util.h.

553{
554 int len = 0;
555 // Count leading 1 bits.
556 for (int mask = 0x80; mask >= 0x04; mask >>= 1)
557 {
558 if (**in & mask)
559 {
560 len++;
561 }
562 else
563 {
564 break;
565 }
566 }
567 if ((static_cast<unsigned char>(**in) << len) & 0x80)
568 return -1; // Bit after leading 1's must be 0.
569 if (!len)
570 return *(*in)++;
571 // UTF-8 encoded values with a length are between 2 and 4 bytes.
572 if (len < 2 || len > 4)
573 {
574 return -1;
575 }
576 // Grab initial bits of the code.
577 int ucc = *(*in)++ & ((1 << (7 - len)) - 1);
578 for (int i = 0; i < len - 1; i++)
579 {
580 if ((**in & 0xC0) != 0x80)
581 return -1; // Upper bits must 1 0.
582 ucc <<= 6;
583 ucc |= *(*in)++ & 0x3F; // Grab 6 more bits of the code.
584 }
585 // UTF-8 cannot encode values between 0xD800 and 0xDFFF (reserved for
586 // UTF-16 surrogate pairs).
587 if (ucc >= 0xD800 && ucc <= 0xDFFF)
588 {
589 return -1;
590 }
591 // UTF-8 must represent code points in their shortest possible encoding.
592 switch (len)
593 {
594 case 2:
595 // Two bytes of UTF-8 can represent code points from U+0080 to U+07FF.
596 if (ucc < 0x0080 || ucc > 0x07FF)
597 {
598 return -1;
599 }
600 break;
601 case 3:
602 // Three bytes of UTF-8 can represent code points from U+0800 to U+FFFF.
603 if (ucc < 0x0800 || ucc > 0xFFFF)
604 {
605 return -1;
606 }
607 break;
608 case 4:
609 // Four bytes of UTF-8 can represent code points from U+10000 to U+10FFFF.
610 if (ucc < 0x10000 || ucc > 0x10FFFF)
611 {
612 return -1;
613 }
614 break;
615 }
616 return ucc;
617}

Referenced by EscapeString().

◆ GenComment()

void flatbuffers::GenComment ( const std::vector< std::string > &  dc,
std::string *  code_ptr,
const CommentConfig config,
const char *  prefix = "" 
)
extern

◆ GenerateBinary()

bool flatbuffers::GenerateBinary ( const Parser parser,
const std::string &  path,
const std::string &  file_name 
)
extern

◆ GenerateCPP()

bool flatbuffers::GenerateCPP ( const Parser parser,
const std::string &  path,
const std::string &  file_name 
)
extern

◆ GenerateCppGRPC()

bool flatbuffers::GenerateCppGRPC ( const Parser parser,
const std::string &  path,
const std::string &  file_name 
)

◆ GenerateCSharp()

bool flatbuffers::GenerateCSharp ( const Parser parser,
const std::string &  path,
const std::string &  file_name 
)
extern

◆ GenerateDart()

bool flatbuffers::GenerateDart ( const Parser parser,
const std::string &  path,
const std::string &  file_name 
)
extern

◆ GenerateFBS() [1/2]

std::string flatbuffers::GenerateFBS ( const Parser parser,
const std::string &  file_name 
)
extern

◆ GenerateFBS() [2/2]

bool flatbuffers::GenerateFBS ( const Parser parser,
const std::string &  path,
const std::string &  file_name 
)
extern

◆ GenerateGo()

bool flatbuffers::GenerateGo ( const Parser parser,
const std::string &  path,
const std::string &  file_name 
)
extern

◆ GenerateGoGRPC()

bool flatbuffers::GenerateGoGRPC ( const Parser parser,
const std::string &  path,
const std::string &  file_name 
)

◆ GenerateJava()

bool flatbuffers::GenerateJava ( const Parser parser,
const std::string &  path,
const std::string &  file_name 
)
extern

◆ GenerateJavaGRPC()

bool flatbuffers::GenerateJavaGRPC ( const Parser parser,
const std::string &  path,
const std::string &  file_name 
)

◆ GenerateJsonSchema() [1/2]

bool flatbuffers::GenerateJsonSchema ( const Parser parser,
const std::string &  path,
const std::string &  file_name 
)
extern

◆ GenerateJsonSchema() [2/2]

bool flatbuffers::GenerateJsonSchema ( const Parser parser,
std::string *  json 
)
extern

◆ GenerateKotlin()

bool flatbuffers::GenerateKotlin ( const Parser parser,
const std::string &  path,
const std::string &  file_name 
)
extern

◆ GenerateLobster()

bool flatbuffers::GenerateLobster ( const Parser parser,
const std::string &  path,
const std::string &  file_name 
)
extern

◆ GenerateLua()

bool flatbuffers::GenerateLua ( const Parser parser,
const std::string &  path,
const std::string &  file_name 
)
extern

◆ GeneratePhp()

bool flatbuffers::GeneratePhp ( const Parser parser,
const std::string &  path,
const std::string &  file_name 
)
extern

◆ GeneratePython()

bool flatbuffers::GeneratePython ( const Parser parser,
const std::string &  path,
const std::string &  file_name 
)
extern

◆ GeneratePythonGRPC()

bool flatbuffers::GeneratePythonGRPC ( const Parser parser,
const std::string &  path,
const std::string &  file_name 
)

◆ GenerateRust()

bool flatbuffers::GenerateRust ( const Parser parser,
const std::string &  path,
const std::string &  file_name 
)
extern

◆ GenerateSwift()

bool flatbuffers::GenerateSwift ( const Parser parser,
const std::string &  path,
const std::string &  file_name 
)
extern

◆ GenerateSwiftGRPC()

bool flatbuffers::GenerateSwiftGRPC ( const Parser parser,
const std::string &  path,
const std::string &  file_name 
)
extern

◆ GenerateText()

bool flatbuffers::GenerateText ( const Parser parser,
const void *  flatbuffer,
std::string *  text 
)
extern

◆ GenerateTextFile()

bool flatbuffers::GenerateTextFile ( const Parser parser,
const std::string &  path,
const std::string &  file_name 
)
extern

◆ GenerateTextFromTable()

bool flatbuffers::GenerateTextFromTable ( const Parser parser,
const void *  table,
const std::string &  tablename,
std::string *  text 
)
extern

◆ GenerateTS()

bool flatbuffers::GenerateTS ( const Parser parser,
const std::string &  path,
const std::string &  file_name 
)
extern

◆ GenerateTSGRPC()

bool flatbuffers::GenerateTSGRPC ( const Parser parser,
const std::string &  path,
const std::string &  file_name 
)
extern

◆ GetAnyFieldAddressOf() [1/2]

template<typename T >
T * flatbuffers::GetAnyFieldAddressOf ( const Struct &  st,
const reflection::Field &  field 
)

Definition at line 282 of file reflection.h.

283{
284 return reinterpret_cast<T *>(st.GetAddressOf(field.offset()));
285}

◆ GetAnyFieldAddressOf() [2/2]

template<typename T >
T * flatbuffers::GetAnyFieldAddressOf ( const Table &  table,
const reflection::Field &  field 
)

Definition at line 276 of file reflection.h.

277{
278 return reinterpret_cast<T *>(table.GetAddressOf(field.offset()));
279}

◆ GetAnyFieldF() [1/2]

double flatbuffers::GetAnyFieldF ( const Struct &  st,
const reflection::Field &  field 
)
inline

Definition at line 225 of file reflection.h.

226{
227 return GetAnyValueF(field.type()->base_type(), st.GetAddressOf(field.offset()));
228}
double GetAnyValueF(reflection::BaseType type, const uint8_t *data)

References GetAnyValueF().

◆ GetAnyFieldF() [2/2]

double flatbuffers::GetAnyFieldF ( const Table &  table,
const reflection::Field &  field 
)
inline

Definition at line 200 of file reflection.h.

201{
202 auto field_ptr = table.GetAddressOf(field.offset());
203 return field_ptr ? GetAnyValueF(field.type()->base_type(), field_ptr) : field.default_real();
204}

References GetAnyValueF().

◆ GetAnyFieldI() [1/2]

int64_t flatbuffers::GetAnyFieldI ( const Struct &  st,
const reflection::Field &  field 
)
inline

Definition at line 219 of file reflection.h.

220{
221 return GetAnyValueI(field.type()->base_type(), st.GetAddressOf(field.offset()));
222}
int64_t GetAnyValueI(reflection::BaseType type, const uint8_t *data)

References GetAnyValueI().

◆ GetAnyFieldI() [2/2]

int64_t flatbuffers::GetAnyFieldI ( const Table &  table,
const reflection::Field &  field 
)
inline

Definition at line 193 of file reflection.h.

194{
195 auto field_ptr = table.GetAddressOf(field.offset());
196 return field_ptr ? GetAnyValueI(field.type()->base_type(), field_ptr) : field.default_integer();
197}

References GetAnyValueI().

◆ GetAnyFieldS() [1/2]

std::string flatbuffers::GetAnyFieldS ( const Struct &  st,
const reflection::Field &  field 
)
inline

Definition at line 231 of file reflection.h.

232{
233 return GetAnyValueS(field.type()->base_type(), st.GetAddressOf(field.offset()), nullptr, -1);
234}
std::string GetAnyValueS(reflection::BaseType type, const uint8_t *data, const reflection::Schema *schema, int type_index)

References GetAnyValueS().

◆ GetAnyFieldS() [2/2]

std::string flatbuffers::GetAnyFieldS ( const Table &  table,
const reflection::Field &  field,
const reflection::Schema *  schema 
)
inline

Definition at line 209 of file reflection.h.

211{
212 auto field_ptr = table.GetAddressOf(field.offset());
213 return field_ptr
214 ? GetAnyValueS(field.type()->base_type(), field_ptr, schema, field.type()->index())
215 : "";
216}

References GetAnyValueS().

◆ GetAnyRoot() [1/2]

const Table * flatbuffers::GetAnyRoot ( const uint8_t *  flatbuf)
inline

Definition at line 102 of file reflection.h.

102{ return GetRoot<Table>(flatbuf); }

◆ GetAnyRoot() [2/2]

Table * flatbuffers::GetAnyRoot ( uint8_t *  flatbuf)
inline

Definition at line 101 of file reflection.h.

101{ return GetMutableRoot<Table>(flatbuf); }

◆ GetAnyValueF()

double flatbuffers::GetAnyValueF ( reflection::BaseType  type,
const uint8_t *  data 
)

◆ GetAnyValueI()

int64_t flatbuffers::GetAnyValueI ( reflection::BaseType  type,
const uint8_t *  data 
)

◆ GetAnyValueS()

std::string flatbuffers::GetAnyValueS ( reflection::BaseType  type,
const uint8_t *  data,
const reflection::Schema *  schema,
int  type_index 
)

◆ GetAnyVectorElemAddressOf()

template<typename T >
T * flatbuffers::GetAnyVectorElemAddressOf ( const VectorOfAny vec,
size_t  i,
size_t  elem_size 
)

Definition at line 270 of file reflection.h.

271{
272 return reinterpret_cast<T *>(vec->Data() + elem_size * i);
273}
const uint8_t * Data() const

References flatbuffers::VectorOfAny::Data().

◆ GetAnyVectorElemF()

double flatbuffers::GetAnyVectorElemF ( const VectorOfAny vec,
reflection::BaseType  elem_type,
size_t  i 
)
inline

Definition at line 243 of file reflection.h.

244{
245 return GetAnyValueF(elem_type, vec->Data() + GetTypeSize(elem_type) * i);
246}
size_t GetTypeSize(reflection::BaseType base_type)
Definition reflection.h:53

References flatbuffers::VectorOfAny::Data(), GetAnyValueF(), and GetTypeSize().

◆ GetAnyVectorElemI()

int64_t flatbuffers::GetAnyVectorElemI ( const VectorOfAny vec,
reflection::BaseType  elem_type,
size_t  i 
)
inline

Definition at line 237 of file reflection.h.

238{
239 return GetAnyValueI(elem_type, vec->Data() + GetTypeSize(elem_type) * i);
240}

References flatbuffers::VectorOfAny::Data(), GetAnyValueI(), and GetTypeSize().

◆ GetAnyVectorElemPointer()

template<typename T >
T * flatbuffers::GetAnyVectorElemPointer ( const VectorOfAny vec,
size_t  i 
)

Definition at line 258 of file reflection.h.

259{
260 auto elem_ptr = vec->Data() + sizeof(uoffset_t) * i;
261 return reinterpret_cast<T *>(elem_ptr + ReadScalar<uoffset_t>(elem_ptr));
262}

References flatbuffers::VectorOfAny::Data().

◆ GetAnyVectorElemS()

std::string flatbuffers::GetAnyVectorElemS ( const VectorOfAny vec,
reflection::BaseType  elem_type,
size_t  i 
)
inline

Definition at line 249 of file reflection.h.

251{
252 return GetAnyValueS(elem_type, vec->Data() + GetTypeSize(elem_type) * i, nullptr, -1);
253}

References flatbuffers::VectorOfAny::Data(), GetAnyValueS(), and GetTypeSize().

◆ GetExtension()

std::string flatbuffers::GetExtension ( const std::string &  filepath)

◆ GetFieldAnyV()

VectorOfAny * flatbuffers::GetFieldAnyV ( const Table &  table,
const reflection::Field &  field 
)
inline

Definition at line 150 of file reflection.h.

151{
152 return table.GetPointer<VectorOfAny *>(field.offset());
153}

◆ GetFieldDefaultF()

template<typename T >
T flatbuffers::GetFieldDefaultF ( const reflection::Field &  field)

Definition at line 112 of file reflection.h.

113{
114 FLATBUFFERS_ASSERT(sizeof(T) == GetTypeSize(field.type()->base_type()));
115 return static_cast<T>(field.default_real());
116}

References FLATBUFFERS_ASSERT, and GetTypeSize().

◆ GetFieldDefaultI()

template<typename T >
T flatbuffers::GetFieldDefaultI ( const reflection::Field &  field)

Definition at line 105 of file reflection.h.

106{
107 FLATBUFFERS_ASSERT(sizeof(T) == GetTypeSize(field.type()->base_type()));
108 return static_cast<T>(field.default_integer());
109}

References FLATBUFFERS_ASSERT, and GetTypeSize().

◆ GetFieldF()

template<typename T >
T flatbuffers::GetFieldF ( const Table &  table,
const reflection::Field &  field 
)

Definition at line 126 of file reflection.h.

127{
128 FLATBUFFERS_ASSERT(sizeof(T) == GetTypeSize(field.type()->base_type()));
129 return table.GetField<T>(field.offset(), static_cast<T>(field.default_real()));
130}

References FLATBUFFERS_ASSERT, and GetTypeSize().

◆ GetFieldI()

template<typename T >
T flatbuffers::GetFieldI ( const Table &  table,
const reflection::Field &  field 
)

Definition at line 119 of file reflection.h.

120{
121 FLATBUFFERS_ASSERT(sizeof(T) == GetTypeSize(field.type()->base_type()));
122 return table.GetField<T>(field.offset(), static_cast<T>(field.default_integer()));
123}

References FLATBUFFERS_ASSERT, and GetTypeSize().

◆ GetFieldS()

const String * flatbuffers::GetFieldS ( const Table &  table,
const reflection::Field &  field 
)
inline

Definition at line 133 of file reflection.h.

134{
135 FLATBUFFERS_ASSERT(field.type()->base_type() == reflection::String);
136 return table.GetPointer<const String *>(field.offset());
137}

References FLATBUFFERS_ASSERT.

◆ GetFieldStruct() [1/2]

const Struct * flatbuffers::GetFieldStruct ( const Struct &  structure,
const reflection::Field &  field 
)
inline

Definition at line 173 of file reflection.h.

174{
175 FLATBUFFERS_ASSERT(field.type()->base_type() == reflection::Obj);
176 return structure.GetStruct<const Struct *>(field.offset());
177}

References FLATBUFFERS_ASSERT.

◆ GetFieldStruct() [2/2]

const Struct * flatbuffers::GetFieldStruct ( const Table &  table,
const reflection::Field &  field 
)
inline

Definition at line 164 of file reflection.h.

165{
166 // TODO: This does NOT check if the field is a table or struct, but we'd need
167 // access to the schema to check the is_struct flag.
168 FLATBUFFERS_ASSERT(field.type()->base_type() == reflection::Obj);
169 return table.GetStruct<const Struct *>(field.offset());
170}

References FLATBUFFERS_ASSERT.

◆ GetFieldT()

Table * flatbuffers::GetFieldT ( const Table &  table,
const reflection::Field &  field 
)
inline

Definition at line 156 of file reflection.h.

157{
158 FLATBUFFERS_ASSERT(field.type()->base_type() == reflection::Obj ||
159 field.type()->base_type() == reflection::Union);
160 return table.GetPointer<Table *>(field.offset());
161}

References FLATBUFFERS_ASSERT.

◆ GetFieldV()

template<typename T >
Vector< T > * flatbuffers::GetFieldV ( const Table &  table,
const reflection::Field &  field 
)

Definition at line 140 of file reflection.h.

141{
142 FLATBUFFERS_ASSERT(field.type()->base_type() == reflection::Vector &&
143 sizeof(T) == GetTypeSize(field.type()->element()));
144 return table.GetPointer<Vector<T> *>(field.offset());
145}

References FLATBUFFERS_ASSERT, and GetTypeSize().

◆ GetTypeSize()

size_t flatbuffers::GetTypeSize ( reflection::BaseType  base_type)
inline

Definition at line 53 of file reflection.h.

54{
55 // This needs to correspond to the BaseType enum.
56 static size_t sizes[] = {
57 0, // None
58 1, // UType
59 1, // Bool
60 1, // Byte
61 1, // UByte
62 2, // Short
63 2, // UShort
64 4, // Int
65 4, // UInt
66 8, // Long
67 8, // ULong
68 4, // Float
69 8, // Double
70 4, // String
71 4, // Vector
72 4, // Obj
73 4, // Union
74 0, // Array. Only used in structs. 0 was chosen to prevent out-of-bounds
75 // errors.
76
77 0 // MaxBaseType. This must be kept the last entry in this array.
78 };
79 static_assert(sizeof(sizes) / sizeof(size_t) == reflection::MaxBaseType + 1,
80 "Size of sizes[] array does not match the count of BaseType "
81 "enum values.");
82 return sizes[base_type];
83}

Referenced by GetAnyVectorElemF(), GetAnyVectorElemI(), GetAnyVectorElemS(), GetFieldDefaultF(), GetFieldDefaultI(), GetFieldF(), GetFieldI(), GetFieldV(), GetTypeSizeInline(), SetAnyVectorElemF(), SetAnyVectorElemI(), SetAnyVectorElemS(), SetField(), and SetFieldT().

◆ GetTypeSizeInline()

size_t flatbuffers::GetTypeSizeInline ( reflection::BaseType  base_type,
int  type_index,
const reflection::Schema &  schema 
)
inline

Definition at line 87 of file reflection.h.

89{
90 if (base_type == reflection::Obj && schema.objects()->Get(type_index)->is_struct())
91 {
92 return schema.objects()->Get(type_index)->bytesize();
93 }
94 else
95 {
96 return GetTypeSize(base_type);
97 }
98}

References GetTypeSize().

◆ GetUnionType()

const reflection::Object & flatbuffers::GetUnionType ( const reflection::Schema &  schema,
const reflection::Object &  parent,
const reflection::Field &  unionfield,
const Table &  table 
)
inline

Definition at line 423 of file reflection.h.

427{
428 auto enumdef = schema.enums()->Get(unionfield.type()->index());
429 // TODO: this is clumsy and slow, but no other way to find it?
430 auto type_field =
431 parent.fields()->LookupByKey((unionfield.name()->str() + UnionTypeFieldSuffix()).c_str());
432 FLATBUFFERS_ASSERT(type_field);
433 auto union_type = GetFieldI<uint8_t>(table, *type_field);
434 auto enumval = enumdef->values()->LookupByKey(union_type);
435 return *enumval->object();
436}
const char * UnionTypeFieldSuffix()
Definition reflection.h:420

References FLATBUFFERS_ASSERT, and UnionTypeFieldSuffix().

◆ HashFnv1()

template<typename T >
T flatbuffers::HashFnv1 ( const char *  input)

Definition at line 47 of file hash.h.

48{
50 for (const char *c = input; *c; ++c)
51 {
53 hash ^= static_cast<unsigned char>(*c);
54 }
55 return hash;
56}

◆ HashFnv1< uint16_t >()

template<>
uint16_t flatbuffers::HashFnv1< uint16_t > ( const char *  input)
inline

Definition at line 69 of file hash.h.

70{
71 uint32_t hash = HashFnv1<uint32_t>(input);
72 return (hash >> 16) ^ (hash & 0xffff);
73}

◆ HashFnv1a()

template<typename T >
T flatbuffers::HashFnv1a ( const char *  input)

Definition at line 58 of file hash.h.

59{
61 for (const char *c = input; *c; ++c)
62 {
63 hash ^= static_cast<unsigned char>(*c);
65 }
66 return hash;
67}

◆ HashFnv1a< uint16_t >()

template<>
uint16_t flatbuffers::HashFnv1a< uint16_t > ( const char *  input)
inline

Definition at line 75 of file hash.h.

76{
77 uint32_t hash = HashFnv1a<uint32_t>(input);
78 return (hash >> 16) ^ (hash & 0xffff);
79}

◆ InlineAlignment()

size_t flatbuffers::InlineAlignment ( const Type type)
inline

Definition at line 492 of file idl.h.

493{
494 if (IsStruct(type))
495 {
496 return type.struct_def->minalign;
497 }
498 else if (IsArray(type))
499 {
500 return IsStruct(type.VectorType()) ? type.struct_def->minalign : SizeOf(type.element);
501 }
502 else
503 {
504 return SizeOf(type.base_type);
505 }
506}
bool IsStruct(const Type &type)
Definition idl.h:464
size_t SizeOf(BaseType t)
Definition idl.h:155
type
Definition infer.py:18

References IsArray(), IsStruct(), and SizeOf().

◆ InlineSize() [1/2]

size_t flatbuffers::InlineSize ( const Type type)
inline

Definition at line 485 of file idl.h.

486{
487 return IsStruct(type) ? type.struct_def->bytesize
488 : (IsArray(type) ? InlineSize(type.VectorType()) * type.fixed_length
489 : SizeOf(type.base_type));
490}
bool IsArray(const Type &type)
Definition idl.h:476
size_t InlineSize(const Type &type)
Definition idl.h:485

References InlineSize(), IsArray(), IsStruct(), and SizeOf().

Referenced by InlineSize(), and IterateObject().

◆ InlineSize() [2/2]

size_t flatbuffers::InlineSize ( ElementaryType  type,
const TypeTable *  type_table 
)
inline

Definition at line 77 of file minireflect.h.

78{
79 switch (type)
80 {
81 case ET_UTYPE:
82 case ET_BOOL:
83 case ET_CHAR:
84 case ET_UCHAR:
85 return 1;
86 case ET_SHORT:
87 case ET_USHORT:
88 return 2;
89 case ET_INT:
90 case ET_UINT:
91 case ET_FLOAT:
92 case ET_STRING:
93 return 4;
94 case ET_LONG:
95 case ET_ULONG:
96 case ET_DOUBLE:
97 return 8;
98 case ET_SEQUENCE:
99 switch (type_table->st)
100 {
101 case ST_TABLE:
102 case ST_UNION:
103 return 4;
104 case ST_STRUCT:
105 return static_cast<size_t>(type_table->values[type_table->num_elems]);
106 default:
107 FLATBUFFERS_ASSERT(false);
108 return 1;
109 }
110 default:
111 FLATBUFFERS_ASSERT(false);
112 return 1;
113 }
114}

References FLATBUFFERS_ASSERT.

◆ IntToStringHex()

std::string flatbuffers::IntToStringHex ( int  i,
int  xdigits 
)
inline

Definition at line 218 of file util.h.

219{
220 FLATBUFFERS_ASSERT(i >= 0);
221 // clang-format off
222
223 #ifndef FLATBUFFERS_PREFER_PRINTF
224 std::stringstream ss;
225 ss << std::setw(xdigits) << std::setfill('0') << std::hex << std::uppercase
226 << i;
227 return ss.str();
228 #else // FLATBUFFERS_PREFER_PRINTF
229 return NumToStringImplWrapper(i, "%.*X", xdigits);
230 #endif // FLATBUFFERS_PREFER_PRINTF
231 // clang-format on
232}

References FLATBUFFERS_ASSERT.

Referenced by BufferToHexText(), and EscapeString().

◆ is_alnum()

bool flatbuffers::is_alnum ( char  c)
inline

Definition at line 83 of file util.h.

83{ return is_alpha(c) || is_digit(c); }
bool is_alpha(char c)
Definition util.h:52
bool is_digit(char c)
Definition util.h:74

References is_alpha(), and is_digit().

◆ is_alpha()

bool flatbuffers::is_alpha ( char  c)
inline

Definition at line 52 of file util.h.

53{
54 // ASCII only: alpha to upper case => reset bit 0x20 (~0x20 = 0xDF).
55 return check_ascii_range(c & 0xDF, 'a' & 0xDF, 'z' & 0xDF);
56}
bool check_ascii_range(char x, char a, char b)
Definition util.h:43

References check_ascii_range().

Referenced by is_alnum(), and is_alpha_char().

◆ is_alpha_char()

bool flatbuffers::is_alpha_char ( char  c,
char  alpha 
)
inline

Definition at line 62 of file util.h.

63{
65 // ASCII only: alpha to upper case => reset bit 0x20 (~0x20 = 0xDF).
66 return ((c & 0xDF) == (alpha & 0xDF));
67}

References FLATBUFFERS_ASSERT, and is_alpha().

Referenced by StringToIntegerImpl().

◆ is_alpha_upper()

bool flatbuffers::is_alpha_upper ( char  c)
inline

Definition at line 59 of file util.h.

59{ return check_ascii_range(c, 'A', 'Z'); }

References check_ascii_range().

◆ is_digit()

bool flatbuffers::is_digit ( char  c)
inline

Definition at line 74 of file util.h.

74{ return check_ascii_range(c, '0', '9'); }

References check_ascii_range().

Referenced by is_alnum(), is_xdigit(), StringToIntegerImpl(), and StringToNumber< uint64_t >().

◆ is_xdigit()

bool flatbuffers::is_xdigit ( char  c)
inline

Definition at line 76 of file util.h.

77{
78 // Replace by look-up table.
79 return is_digit(c) || check_ascii_range(c & 0xDF, 'a' & 0xDF, 'f' & 0xDF);
80}

References check_ascii_range(), and is_digit().

◆ IsArray()

bool flatbuffers::IsArray ( const Type type)
inline

Definition at line 476 of file idl.h.

476{ return type.base_type == BASE_TYPE_ARRAY; }

Referenced by InlineAlignment(), InlineSize(), and IsSeries().

◆ IsBool()

bool flatbuffers::IsBool ( BaseType  t)
inline

Definition at line 140 of file idl.h.

140{ return t == BASE_TYPE_BOOL; }

◆ IsEnum()

bool flatbuffers::IsEnum ( const Type type)
inline

Definition at line 480 of file idl.h.

481{
482 return type.enum_def != nullptr && IsInteger(type.base_type);
483}
bool IsInteger(BaseType t)
Definition idl.h:134

References IsInteger().

◆ IsFloat() [1/2]

bool flatbuffers::IsFloat ( BaseType  t)
inline

Definition at line 136 of file idl.h.

136 { return t == BASE_TYPE_FLOAT ||
137 t == BASE_TYPE_DOUBLE; }

Referenced by SetField().

◆ IsFloat() [2/2]

bool flatbuffers::IsFloat ( reflection::BaseType  t)
inline

Definition at line 43 of file reflection.h.

44{
45 return t == reflection::Float || t == reflection::Double;
46}

◆ IsInRange()

template<typename T >
bool flatbuffers::IsInRange ( const T &  v,
const T &  low,
const T &  high 
)
inline

Definition at line 62 of file flatbuffers.h.

63{
64 return !IsOutRange(v, low, high);
65}
bool IsOutRange(const T &v, const T &low, const T &high)
Definition flatbuffers.h:56

References IsOutRange().

◆ IsInteger() [1/2]

bool flatbuffers::IsInteger ( BaseType  t)
inline

Definition at line 134 of file idl.h.

134 { return t >= BASE_TYPE_UTYPE &&
135 t <= BASE_TYPE_ULONG; }

Referenced by IsEnum(), and SetField().

◆ IsInteger() [2/2]

bool flatbuffers::IsInteger ( reflection::BaseType  t)
inline

Definition at line 39 of file reflection.h.

40{
41 return t >= reflection::UType && t <= reflection::ULong;
42}

◆ IsLong() [1/2]

bool flatbuffers::IsLong ( BaseType  t)
inline

Definition at line 138 of file idl.h.

138 { return t == BASE_TYPE_LONG ||
139 t == BASE_TYPE_ULONG; }

◆ IsLong() [2/2]

bool flatbuffers::IsLong ( reflection::BaseType  t)
inline

Definition at line 47 of file reflection.h.

48{
49 return t == reflection::Long || t == reflection::ULong;
50}

◆ IsOneByte()

bool flatbuffers::IsOneByte ( BaseType  t)
inline

Definition at line 141 of file idl.h.

141 { return t >= BASE_TYPE_UTYPE &&
142 t <= BASE_TYPE_UCHAR; }

◆ IsOutRange()

template<typename T >
bool flatbuffers::IsOutRange ( const T &  v,
const T &  low,
const T &  high 
)
inline

Definition at line 56 of file flatbuffers.h.

57{
58 return (v < low) || (high < v);
59}

Referenced by IsInRange().

◆ IsScalar() [1/2]

bool flatbuffers::IsScalar ( BaseType  t)
inline

Definition at line 132 of file idl.h.

132 { return t >= BASE_TYPE_UTYPE &&
133 t <= BASE_TYPE_DOUBLE; }

Referenced by flatbuffers::FieldDef::IsScalarOptional(), and SetField().

◆ IsScalar() [2/2]

bool flatbuffers::IsScalar ( reflection::BaseType  t)
inline

Definition at line 35 of file reflection.h.

36{
37 return t >= reflection::UType && t <= reflection::Double;
38}

◆ IsSeries()

bool flatbuffers::IsSeries ( const Type type)
inline

Definition at line 478 of file idl.h.

478{ return IsVector(type) || IsArray(type); }
bool IsVector(const Type &type)
Definition idl.h:474

References IsArray(), and IsVector().

◆ IsString()

bool flatbuffers::IsString ( const Type type)
inline

Definition at line 462 of file idl.h.

462{ return type.base_type == BASE_TYPE_STRING; }

◆ IsStruct()

bool flatbuffers::IsStruct ( const Type type)
inline

Definition at line 464 of file idl.h.

465{
466 return type.base_type == BASE_TYPE_STRUCT && type.struct_def->fixed;
467}

Referenced by InlineAlignment(), and InlineSize().

◆ IsTheSameAs()

template<typename T >
bool flatbuffers::IsTheSameAs ( e,
def 
)
inline

Definition at line 37 of file flatbuffers.h.

37{ return e == def; }

◆ IsUnion()

bool flatbuffers::IsUnion ( const Type type)
inline

Definition at line 469 of file idl.h.

470{
471 return type.enum_def != nullptr && type.enum_def->is_union;
472}

◆ IsUnsigned()

bool flatbuffers::IsUnsigned ( BaseType  t)
inline

Definition at line 144 of file idl.h.

144 {
145 return (t == BASE_TYPE_UTYPE) || (t == BASE_TYPE_UCHAR) ||
146 (t == BASE_TYPE_USHORT) || (t == BASE_TYPE_UINT) ||
147 (t == BASE_TYPE_ULONG);
148}

◆ IsVector()

bool flatbuffers::IsVector ( const Type type)
inline

Definition at line 474 of file idl.h.

474{ return type.base_type == BASE_TYPE_VECTOR; }

Referenced by IsSeries().

◆ IterateFlatBuffer()

void flatbuffers::IterateFlatBuffer ( const uint8_t *  buffer,
const TypeTable *  type_table,
IterationVisitor callback 
)
inline

Definition at line 350 of file minireflect.h.

352{
353 IterateObject(GetRoot<uint8_t>(buffer), type_table, callback);
354}
void IterateObject(const uint8_t *obj, const TypeTable *type_table, IterationVisitor *visitor)

References IterateObject().

Referenced by FlatBufferToString().

◆ IterateObject()

void flatbuffers::IterateObject ( const uint8_t *  obj,
const TypeTable *  type_table,
IterationVisitor visitor 
)
inline

Definition at line 280 of file minireflect.h.

282{
283 visitor->StartSequence();
284 const uint8_t *prev_val = nullptr;
285 size_t set_idx = 0;
286 size_t array_idx = 0;
287 for (size_t i = 0; i < type_table->num_elems; i++)
288 {
289 auto type_code = type_table->type_codes[i];
290 auto type = static_cast<ElementaryType>(type_code.base_type);
291 auto is_repeating = type_code.is_repeating != 0;
292 auto ref_idx = type_code.sequence_ref;
293 const TypeTable *ref = nullptr;
294 if (ref_idx >= 0)
295 {
296 ref = type_table->type_refs[ref_idx]();
297 }
298 auto name = type_table->names ? type_table->names[i] : nullptr;
299 const uint8_t *val = nullptr;
300 if (type_table->st == ST_TABLE)
301 {
302 val = reinterpret_cast<const Table *>(obj)->GetAddressOf(
303 FieldIndexToOffset(static_cast<voffset_t>(i)));
304 }
305 else
306 {
307 val = obj + type_table->values[i];
308 }
309 visitor->Field(i, set_idx, type, is_repeating, ref, name, val);
310 if (val)
311 {
312 set_idx++;
313 if (is_repeating)
314 {
315 auto elem_ptr = val;
316 size_t size = 0;
317 if (type_table->st == ST_TABLE)
318 {
319 // variable length vector
320 val += ReadScalar<uoffset_t>(val);
321 auto vec = reinterpret_cast<const Vector<uint8_t> *>(val);
322 elem_ptr = vec->Data();
323 size = vec->size();
324 }
325 else
326 {
327 // otherwise fixed size array
328 size = type_table->array_sizes[array_idx];
329 ++array_idx;
330 }
331 visitor->StartVector();
332 for (size_t j = 0; j < size; j++)
333 {
334 visitor->Element(j, type, ref, elem_ptr);
335 IterateValue(type, elem_ptr, ref, prev_val, static_cast<soffset_t>(j), visitor);
336 elem_ptr += InlineSize(type, ref);
337 }
338 visitor->EndVector();
339 }
340 else
341 {
342 IterateValue(type, val, ref, prev_val, -1, visitor);
343 }
344 }
345 prev_val = val;
346 }
347 visitor->EndSequence();
348}
void IterateValue(ElementaryType type, const uint8_t *val, const TypeTable *type_table, const uint8_t *prev_val, soffset_t vector_index, IterationVisitor *visitor)
virtual void Field(size_t, size_t, ElementaryType, bool, const TypeTable *, const char *, const uint8_t *)
Definition minireflect.h:46
virtual void Element(size_t, ElementaryType, const TypeTable *, const uint8_t *)
Definition minireflect.h:70

References flatbuffers::Vector< T >::Data(), flatbuffers::IterationVisitor::Element(), flatbuffers::IterationVisitor::EndSequence(), flatbuffers::IterationVisitor::EndVector(), flatbuffers::IterationVisitor::Field(), FieldIndexToOffset(), InlineSize(), IterateValue(), size, flatbuffers::IterationVisitor::StartSequence(), and flatbuffers::IterationVisitor::StartVector().

Referenced by IterateFlatBuffer(), and IterateValue().

◆ IterateValue()

void flatbuffers::IterateValue ( ElementaryType  type,
const uint8_t *  val,
const TypeTable *  type_table,
const uint8_t *  prev_val,
soffset_t  vector_index,
IterationVisitor visitor 
)
inline

Definition at line 142 of file minireflect.h.

144{
145 switch (type)
146 {
147 case ET_UTYPE:
148 {
149 auto tval = ReadScalar<uint8_t>(val);
150 visitor->UType(tval, EnumName(tval, type_table));
151 break;
152 }
153 case ET_BOOL:
154 {
155 visitor->Bool(ReadScalar<uint8_t>(val) != 0);
156 break;
157 }
158 case ET_CHAR:
159 {
160 auto tval = ReadScalar<int8_t>(val);
161 visitor->Char(tval, EnumName(tval, type_table));
162 break;
163 }
164 case ET_UCHAR:
165 {
166 auto tval = ReadScalar<uint8_t>(val);
167 visitor->UChar(tval, EnumName(tval, type_table));
168 break;
169 }
170 case ET_SHORT:
171 {
172 auto tval = ReadScalar<int16_t>(val);
173 visitor->Short(tval, EnumName(tval, type_table));
174 break;
175 }
176 case ET_USHORT:
177 {
178 auto tval = ReadScalar<uint16_t>(val);
179 visitor->UShort(tval, EnumName(tval, type_table));
180 break;
181 }
182 case ET_INT:
183 {
184 auto tval = ReadScalar<int32_t>(val);
185 visitor->Int(tval, EnumName(tval, type_table));
186 break;
187 }
188 case ET_UINT:
189 {
190 auto tval = ReadScalar<uint32_t>(val);
191 visitor->UInt(tval, EnumName(tval, type_table));
192 break;
193 }
194 case ET_LONG:
195 {
196 visitor->Long(ReadScalar<int64_t>(val));
197 break;
198 }
199 case ET_ULONG:
200 {
201 visitor->ULong(ReadScalar<uint64_t>(val));
202 break;
203 }
204 case ET_FLOAT:
205 {
206 visitor->Float(ReadScalar<float>(val));
207 break;
208 }
209 case ET_DOUBLE:
210 {
211 visitor->Double(ReadScalar<double>(val));
212 break;
213 }
214 case ET_STRING:
215 {
216 val += ReadScalar<uoffset_t>(val);
217 visitor->String(reinterpret_cast<const String *>(val));
218 break;
219 }
220 case ET_SEQUENCE:
221 {
222 switch (type_table->st)
223 {
224 case ST_TABLE:
225 val += ReadScalar<uoffset_t>(val);
226 IterateObject(val, type_table, visitor);
227 break;
228 case ST_STRUCT:
229 IterateObject(val, type_table, visitor);
230 break;
231 case ST_UNION:
232 {
233 val += ReadScalar<uoffset_t>(val);
234 FLATBUFFERS_ASSERT(prev_val);
235 auto union_type = *prev_val; // Always a uint8_t.
236 if (vector_index >= 0)
237 {
238 auto type_vec = reinterpret_cast<const Vector<uint8_t> *>(prev_val);
239 union_type = type_vec->Get(static_cast<uoffset_t>(vector_index));
240 }
241 auto type_code_idx = LookupEnum(union_type, type_table->values, type_table->num_elems);
242 if (type_code_idx >= 0 && type_code_idx < static_cast<int32_t>(type_table->num_elems))
243 {
244 auto type_code = type_table->type_codes[type_code_idx];
245 switch (type_code.base_type)
246 {
247 case ET_SEQUENCE:
248 {
249 auto ref = type_table->type_refs[type_code.sequence_ref]();
250 IterateObject(val, ref, visitor);
251 break;
252 }
253 case ET_STRING:
254 visitor->String(reinterpret_cast<const String *>(val));
255 break;
256 default:
257 visitor->Unknown(val);
258 }
259 }
260 else
261 {
262 visitor->Unknown(val);
263 }
264 break;
265 }
266 case ST_ENUM:
267 FLATBUFFERS_ASSERT(false);
268 break;
269 }
270 break;
271 }
272 default:
273 {
274 visitor->Unknown(val);
275 break;
276 }
277 }
278}
const char * EnumName(T tval, const TypeTable *type_table)
virtual void Long(int64_t)
Definition minireflect.h:61
virtual void Int(int32_t, const char *)
Definition minireflect.h:59
virtual void Char(int8_t, const char *)
Definition minireflect.h:55
virtual void UType(uint8_t, const char *)
Definition minireflect.h:53
virtual void UShort(uint16_t, const char *)
Definition minireflect.h:58
virtual void Float(float)
Definition minireflect.h:63
virtual void UInt(uint32_t, const char *)
Definition minireflect.h:60
virtual void Bool(bool)
Definition minireflect.h:54
virtual void Double(double)
Definition minireflect.h:64
virtual void ULong(uint64_t)
Definition minireflect.h:62
virtual void Unknown(const uint8_t *)
Definition minireflect.h:66
virtual void String(const String *)
Definition minireflect.h:65
virtual void Short(int16_t, const char *)
Definition minireflect.h:57
virtual void UChar(uint8_t, const char *)
Definition minireflect.h:56

References flatbuffers::IterationVisitor::Bool(), flatbuffers::IterationVisitor::Char(), flatbuffers::IterationVisitor::Double(), EnumName(), FLATBUFFERS_ASSERT, flatbuffers::IterationVisitor::Float(), flatbuffers::Vector< T >::Get(), flatbuffers::IterationVisitor::Int(), IterateObject(), flatbuffers::IterationVisitor::Long(), LookupEnum(), flatbuffers::IterationVisitor::Short(), flatbuffers::IterationVisitor::String(), flatbuffers::IterationVisitor::UChar(), flatbuffers::IterationVisitor::UInt(), flatbuffers::IterationVisitor::ULong(), flatbuffers::IterationVisitor::Unknown(), flatbuffers::IterationVisitor::UShort(), and flatbuffers::IterationVisitor::UType().

Referenced by IterateObject().

◆ JavaCSharpMakeRule()

std::string flatbuffers::JavaCSharpMakeRule ( const Parser parser,
const std::string &  path,
const std::string &  file_name 
)
extern

◆ LoadFile()

bool flatbuffers::LoadFile ( const char *  name,
bool  binary,
std::string *  buf 
)

◆ LogCompilerError()

void flatbuffers::LogCompilerError ( const std::string &  err)
extern

◆ LogCompilerWarn()

void flatbuffers::LogCompilerWarn ( const std::string &  warn)
extern

◆ LookupEnum()

int64_t flatbuffers::LookupEnum ( int64_t  enum_val,
const int64_t *  values,
size_t  num_values 
)
inline

Definition at line 116 of file minireflect.h.

117{
118 if (!values)
119 return enum_val;
120 for (size_t i = 0; i < num_values; i++)
121 {
122 if (enum_val == values[i])
123 return static_cast<int64_t>(i);
124 }
125 return -1; // Unknown enum value.
126}

Referenced by EnumName(), and IterateValue().

◆ MakeCamel()

std::string flatbuffers::MakeCamel ( const std::string &  in,
bool  first = true 
)
extern

◆ MakeScreamingCamel()

std::string flatbuffers::MakeScreamingCamel ( const std::string &  in)
extern

◆ NumToString()

template<typename T >
std::string flatbuffers::NumToString ( t)

Definition at line 139 of file util.h.

140{
141 // clang-format off
142
143 #ifndef FLATBUFFERS_PREFER_PRINTF
144 std::stringstream ss;
145 ss << t;
146 return ss.str();
147 #else // FLATBUFFERS_PREFER_PRINTF
148 auto v = static_cast<long long>(t);
149 return NumToStringImplWrapper(v, "%.*lld");
150 #endif // FLATBUFFERS_PREFER_PRINTF
151 // clang-format on
152}

Referenced by flatbuffers::ToStringVisitor::Double(), flatbuffers::ToStringVisitor::Float(), flatbuffers::ToStringVisitor::Long(), flatbuffers::ToStringVisitor::Named(), NumToString< char >(), NumToString< signed char >(), NumToString< unsigned char >(), flexbuffers::Reference::ToString(), flatbuffers::EnumDef::ToString(), and flatbuffers::ToStringVisitor::ULong().

◆ NumToString< char >()

template<>
std::string flatbuffers::NumToString< char > ( char  t)
inline

Definition at line 162 of file util.h.

163{
164 return NumToString(static_cast<int>(t));
165}
std::string NumToString(T t)
Definition util.h:139

References NumToString().

◆ NumToString< double >()

template<>
std::string flatbuffers::NumToString< double > ( double  t)
inline

Definition at line 212 of file util.h.

212{ return FloatToString(t, 12); }
std::string FloatToString(T t, int precision)
Definition util.h:183

References FloatToString().

◆ NumToString< float >()

template<>
std::string flatbuffers::NumToString< float > ( float  t)
inline

Definition at line 213 of file util.h.

213{ return FloatToString(t, 6); }

References FloatToString().

◆ NumToString< signed char >()

template<>
std::string flatbuffers::NumToString< signed char > ( signed char  t)
inline

Definition at line 154 of file util.h.

155{
156 return NumToString(static_cast<int>(t));
157}

References NumToString().

◆ NumToString< unsigned char >()

template<>
std::string flatbuffers::NumToString< unsigned char > ( unsigned char  t)
inline

Definition at line 158 of file util.h.

159{
160 return NumToString(static_cast<int>(t));
161}

References NumToString().

◆ operator!=()

bool flatbuffers::operator!= ( const EnumVal lhs,
const EnumVal rhs 
)
inline

Definition at line 508 of file idl.h.

508{ return !(lhs == rhs); }

◆ operator<()

bool flatbuffers::operator< ( const Namespace a,
const Namespace b 
)
inline

Definition at line 265 of file idl.h.

266{
267 size_t min_size = std::min(a.components.size(), b.components.size());
268 for (size_t i = 0; i < min_size; ++i)
269 {
270 if (a.components[i] != b.components[i])
271 return a.components[i] < b.components[i];
272 }
273 return a.components.size() < b.components.size();
274}
std::vector< std::string > components
Definition idl.h:261

References flatbuffers::Namespace::components.

◆ operator==() [1/6]

bool flatbuffers::operator== ( const EnumVal lhs,
const EnumVal rhs 
)
inline

Definition at line 507 of file idl.h.

507{ return lhs.value == rhs.value; }

◆ operator==() [2/6]

template<class T , class U >
FLATBUFFERS_CONSTEXPR_CPP11 bool flatbuffers::operator== ( const Optional< T > &  lhs,
const Optional< U > &  rhs 
)

Definition at line 465 of file stl_emulation.h.

465 {
466 return static_cast<bool>(lhs) != static_cast<bool>(rhs)
467 ? false
468 : !static_cast<bool>(lhs) ? false : (*lhs == *rhs);
469}

◆ operator==() [3/6]

template<class T , class U >
FLATBUFFERS_CONSTEXPR_CPP11 bool flatbuffers::operator== ( const Optional< T > &  lhs,
const U &  rhs 
)

Definition at line 455 of file stl_emulation.h.

455 {
456 return static_cast<bool>(lhs) && (*lhs == rhs);
457}

◆ operator==() [4/6]

template<class T >
FLATBUFFERS_CONSTEXPR_CPP11 bool flatbuffers::operator== ( const Optional< T > &  opt,
nullopt_t   
)

Definition at line 446 of file stl_emulation.h.

446 {
447 return !opt;
448}

◆ operator==() [5/6]

template<class T , class U >
FLATBUFFERS_CONSTEXPR_CPP11 bool flatbuffers::operator== ( const T &  lhs,
const Optional< U > &  rhs 
)

Definition at line 460 of file stl_emulation.h.

460 {
461 return static_cast<bool>(rhs) && (lhs == *rhs);
462}

◆ operator==() [6/6]

template<class T >
FLATBUFFERS_CONSTEXPR_CPP11 bool flatbuffers::operator== ( nullopt_t  ,
const Optional< T > &  opt 
)

Definition at line 450 of file stl_emulation.h.

450 {
451 return !opt;
452}

◆ piv()

template<typename T , typename U >
pointer_inside_vector< T, U > flatbuffers::piv ( T *  ptr,
std::vector< U > &  vec 
)

Definition at line 415 of file reflection.h.

◆ PosixPath()

std::string flatbuffers::PosixPath ( const char *  path)

◆ ReadEnvironmentVariable()

bool flatbuffers::ReadEnvironmentVariable ( const char *  var_name,
std::string *  _value = nullptr 
)

◆ ReallocateDownward()

uint8_t * flatbuffers::ReallocateDownward ( Allocator allocator,
uint8_t *  old_p,
size_t  old_size,
size_t  new_size,
size_t  in_use_back,
size_t  in_use_front 
)
inline

Definition at line 744 of file flatbuffers.h.

746{
747 return allocator
748 ? allocator->reallocate_downward(old_p, old_size, new_size, in_use_back, in_use_front)
749 : DefaultAllocator().reallocate_downward(old_p, old_size, new_size, in_use_back,
750 in_use_front);
751}
virtual uint8_t * reallocate_downward(uint8_t *old_p, size_t old_size, size_t new_size, size_t in_use_back, size_t in_use_front)

References flatbuffers::Allocator::reallocate_downward().

◆ RemoveStringQuotes()

std::string flatbuffers::RemoveStringQuotes ( const std::string &  s)

◆ ResizeAnyVector()

uint8_t * flatbuffers::ResizeAnyVector ( const reflection::Schema &  schema,
uoffset_t  newsize,
const VectorOfAny vec,
uoffset_t  num_elems,
uoffset_t  elem_size,
std::vector< uint8_t > *  flatbuf,
const reflection::Object *  root_table = nullptr 
)

Referenced by ResizeVector().

◆ ResizeVector()

template<typename T >
void flatbuffers::ResizeVector ( const reflection::Schema &  schema,
uoffset_t  newsize,
val,
const Vector< T > *  vec,
std::vector< uint8_t > *  flatbuf,
const reflection::Object *  root_table = nullptr 
)

Definition at line 457 of file reflection.h.

459{
460 auto delta_elem = static_cast<int>(newsize) - static_cast<int>(vec->size());
461 auto newelems =
462 ResizeAnyVector(schema, newsize, reinterpret_cast<const VectorOfAny *>(vec), vec->size(),
463 static_cast<uoffset_t>(sizeof(T)), flatbuf, root_table);
464 // Set new elements to "val".
465 for (int i = 0; i < delta_elem; i++)
466 {
467 auto loc = newelems + i * sizeof(T);
469 if (is_scalar)
470 {
471 WriteScalar(loc, val);
472 }
473 else
474 { // struct
475 *reinterpret_cast<T *>(loc) = val;
476 }
477 }
478}
uoffset_t size() const
uint8_t * ResizeAnyVector(const reflection::Schema &schema, uoffset_t newsize, const VectorOfAny *vec, uoffset_t num_elems, uoffset_t elem_size, std::vector< uint8_t > *flatbuf, const reflection::Object *root_table=nullptr)

References ResizeAnyVector(), and flatbuffers::Vector< T >::size().

◆ RustMakeRule()

std::string flatbuffers::RustMakeRule ( const Parser parser,
const std::string &  path,
const std::string &  file_name 
)
extern

◆ SaveFile() [1/2]

bool flatbuffers::SaveFile ( const char *  name,
const char *  buf,
size_t  len,
bool  binary 
)

Referenced by SaveFile().

◆ SaveFile() [2/2]

bool flatbuffers::SaveFile ( const char *  name,
const std::string &  buf,
bool  binary 
)
inline

Definition at line 477 of file util.h.

478{
479 return SaveFile(name, buf.c_str(), buf.size(), binary);
480}
bool SaveFile(const char *name, const char *buf, size_t len, bool binary)

References SaveFile().

◆ SetAnyFieldF() [1/2]

void flatbuffers::SetAnyFieldF ( Struct *  st,
const reflection::Field &  field,
double  val 
)
inline

Definition at line 356 of file reflection.h.

357{
358 SetAnyValueF(field.type()->base_type(), st->GetAddressOf(field.offset()), val);
359}
void SetAnyValueF(reflection::BaseType type, uint8_t *data, double val)

References SetAnyValueF().

◆ SetAnyFieldF() [2/2]

bool flatbuffers::SetAnyFieldF ( Table *  table,
const reflection::Field &  field,
double  val 
)
inline

Definition at line 330 of file reflection.h.

331{
332 auto field_ptr = table->GetAddressOf(field.offset());
333 if (!field_ptr)
334 return val == GetFieldDefaultF<double>(field);
335 SetAnyValueF(field.type()->base_type(), field_ptr, val);
336 return true;
337}

References SetAnyValueF().

◆ SetAnyFieldI() [1/2]

void flatbuffers::SetAnyFieldI ( Struct *  st,
const reflection::Field &  field,
int64_t  val 
)
inline

Definition at line 350 of file reflection.h.

351{
352 SetAnyValueI(field.type()->base_type(), st->GetAddressOf(field.offset()), val);
353}
void SetAnyValueI(reflection::BaseType type, uint8_t *data, int64_t val)

References SetAnyValueI().

◆ SetAnyFieldI() [2/2]

bool flatbuffers::SetAnyFieldI ( Table *  table,
const reflection::Field &  field,
int64_t  val 
)
inline

Definition at line 320 of file reflection.h.

321{
322 auto field_ptr = table->GetAddressOf(field.offset());
323 if (!field_ptr)
324 return val == GetFieldDefaultI<int64_t>(field);
325 SetAnyValueI(field.type()->base_type(), field_ptr, val);
326 return true;
327}

References SetAnyValueI().

◆ SetAnyFieldS() [1/2]

void flatbuffers::SetAnyFieldS ( Struct *  st,
const reflection::Field &  field,
const char *  val 
)
inline

Definition at line 362 of file reflection.h.

363{
364 SetAnyValueS(field.type()->base_type(), st->GetAddressOf(field.offset()), val);
365}
void SetAnyValueS(reflection::BaseType type, uint8_t *data, const char *val)

References SetAnyValueS().

◆ SetAnyFieldS() [2/2]

bool flatbuffers::SetAnyFieldS ( Table *  table,
const reflection::Field &  field,
const char *  val 
)
inline

Definition at line 340 of file reflection.h.

341{
342 auto field_ptr = table->GetAddressOf(field.offset());
343 if (!field_ptr)
344 return false;
345 SetAnyValueS(field.type()->base_type(), field_ptr, val);
346 return true;
347}

References SetAnyValueS().

◆ SetAnyValueF()

void flatbuffers::SetAnyValueF ( reflection::BaseType  type,
uint8_t *  data,
double  val 
)

◆ SetAnyValueI()

void flatbuffers::SetAnyValueI ( reflection::BaseType  type,
uint8_t *  data,
int64_t  val 
)

◆ SetAnyValueS()

void flatbuffers::SetAnyValueS ( reflection::BaseType  type,
uint8_t *  data,
const char *  val 
)

◆ SetAnyVectorElemF()

void flatbuffers::SetAnyVectorElemF ( VectorOfAny vec,
reflection::BaseType  elem_type,
size_t  i,
double  val 
)
inline

Definition at line 375 of file reflection.h.

377{
378 SetAnyValueF(elem_type, vec->Data() + GetTypeSize(elem_type) * i, val);
379}

References flatbuffers::VectorOfAny::Data(), GetTypeSize(), and SetAnyValueF().

◆ SetAnyVectorElemI()

void flatbuffers::SetAnyVectorElemI ( VectorOfAny vec,
reflection::BaseType  elem_type,
size_t  i,
int64_t  val 
)
inline

Definition at line 368 of file reflection.h.

370{
371 SetAnyValueI(elem_type, vec->Data() + GetTypeSize(elem_type) * i, val);
372}

References flatbuffers::VectorOfAny::Data(), GetTypeSize(), and SetAnyValueI().

◆ SetAnyVectorElemS()

void flatbuffers::SetAnyVectorElemS ( VectorOfAny vec,
reflection::BaseType  elem_type,
size_t  i,
const char *  val 
)
inline

Definition at line 382 of file reflection.h.

384{
385 SetAnyValueS(elem_type, vec->Data() + GetTypeSize(elem_type) * i, val);
386}

References flatbuffers::VectorOfAny::Data(), GetTypeSize(), and SetAnyValueS().

◆ SetField()

template<typename T >
bool flatbuffers::SetField ( Table *  table,
const reflection::Field &  field,
val 
)

Definition at line 290 of file reflection.h.

291{
292 reflection::BaseType type = field.type()->base_type();
293 if (!IsScalar(type))
294 {
295 return false;
296 }
297 FLATBUFFERS_ASSERT(sizeof(T) == GetTypeSize(type));
298 T def;
299 if (IsInteger(type))
300 {
301 def = GetFieldDefaultI<T>(field);
302 }
303 else
304 {
306 def = GetFieldDefaultF<T>(field);
307 }
308 return table->SetField(field.offset(), val, def);
309}
bool IsScalar(BaseType t)
Definition idl.h:132
bool IsFloat(BaseType t)
Definition idl.h:136

References FLATBUFFERS_ASSERT, GetTypeSize(), IsFloat(), IsInteger(), and IsScalar().

◆ SetFieldT()

bool flatbuffers::SetFieldT ( Table *  table,
const reflection::Field &  field,
const uint8_t *  val 
)
inline

Definition at line 490 of file reflection.h.

491{
492 FLATBUFFERS_ASSERT(sizeof(uoffset_t) == GetTypeSize(field.type()->base_type()));
493 return table->SetPointer(field.offset(), val);
494}

References FLATBUFFERS_ASSERT, and GetTypeSize().

◆ SetFileExistsFunction()

FileExistsFunction flatbuffers::SetFileExistsFunction ( FileExistsFunction  file_exists_function)

◆ SetGlobalTestLocale()

bool flatbuffers::SetGlobalTestLocale ( const char *  locale_name,
std::string *  _value = nullptr 
)

◆ SetLoadFileFunction()

LoadFileFunction flatbuffers::SetLoadFileFunction ( LoadFileFunction  load_file_function)

◆ SetString()

void flatbuffers::SetString ( const reflection::Schema &  schema,
const std::string &  val,
const String str,
std::vector< uint8_t > *  flatbuf,
const reflection::Object *  root_table = nullptr 
)

◆ SetupDefaultCRTReportMode()

void flatbuffers::SetupDefaultCRTReportMode ( )

◆ SizeOf()

size_t flatbuffers::SizeOf ( BaseType  t)
inline

Definition at line 155 of file idl.h.

155{ return kTypeSizes[t]; }
const char kTypeSizes[]

References kTypeSizes.

Referenced by InlineAlignment(), and InlineSize().

◆ string_back() [1/2]

char flatbuffers::string_back ( const std::string &  value)
inline

Definition at line 76 of file stl_emulation.h.

76 {
77 return value[value.length() - 1];
78}

◆ string_back() [2/2]

char & flatbuffers::string_back ( std::string &  value)
inline

Definition at line 72 of file stl_emulation.h.

72 {
73 return value[value.length() - 1];
74}

◆ StringToFloatImpl()

template<typename T >
bool flatbuffers::StringToFloatImpl ( T *  val,
const char *const  str 
)
inline

Definition at line 345 of file util.h.

346{
347 // Type T must be either float or double.
348 FLATBUFFERS_ASSERT(str && val);
349 auto end = str;
350 strtoval_impl(val, str, const_cast<char **>(&end));
351 auto done = (end != str) && (*end == '\0');
352 if (!done)
353 *val = 0; // erase partial result
354 return done;
355}
void strtoval_impl(int64_t *val, const char *str, char **endptr, int base)
Definition util.h:274

References FLATBUFFERS_ASSERT, str, and strtoval_impl().

Referenced by StringToNumber(), and StringToNumber().

◆ StringToInt()

int64_t flatbuffers::StringToInt ( const char *  s,
int  base = 10 
)
inline

Definition at line 435 of file util.h.

436{
437 int64_t val;
438 return StringToIntegerImpl(&val, s, base) ? val : 0;
439}
bool StringToIntegerImpl(T *val, const char *const str, const int base=0, const bool check_errno=true)
Definition util.h:312

References StringToIntegerImpl().

Referenced by flexbuffers::Reference::AsInt64().

◆ StringToIntegerImpl()

template<typename T >
bool flatbuffers::StringToIntegerImpl ( T *  val,
const char *const  str,
const int  base = 0,
const bool  check_errno = true 
)
inline

Definition at line 312 of file util.h.

314{
315 // T is int64_t or uint64_T
317 if (base <= 0)
318 {
319 auto s = str;
320 while (*s && !is_digit(*s))
321 s++;
322 if (s[0] == '0' && is_alpha_char(s[1], 'X'))
323 return StringToIntegerImpl(val, str, 16, check_errno);
324 // if a prefix not match, try base=10
325 return StringToIntegerImpl(val, str, 10, check_errno);
326 }
327 else
328 {
329 if (check_errno)
330 errno = 0; // clear thread-local errno
331 auto endptr = str;
332 strtoval_impl(val, str, const_cast<char **>(&endptr), base);
333 if ((*endptr != '\0') || (endptr == str))
334 {
335 *val = 0; // erase partial result
336 return false; // invalid string
337 }
338 // errno is out-of-range, return MAX/MIN
339 if (check_errno && errno)
340 return false;
341 return true;
342 }
343}
bool is_alpha_char(char c, char alpha)
Definition util.h:62

References endptr, FLATBUFFERS_ASSERT, is_alpha_char(), is_digit(), str, StringToIntegerImpl(), and strtoval_impl().

Referenced by StringToInt(), StringToIntegerImpl(), StringToNumber(), StringToNumber< int64_t >(), StringToNumber< uint64_t >(), and StringToUInt().

◆ StringToNumber() [1/3]

template<>
bool flatbuffers::StringToNumber ( const char *  s,
double *  val 
)
inline

Definition at line 430 of file util.h.

431{
432 return StringToFloatImpl(val, s);
433}
bool StringToFloatImpl(T *val, const char *const str)
Definition util.h:345

References StringToFloatImpl().

◆ StringToNumber() [2/3]

template<>
bool flatbuffers::StringToNumber ( const char *  s,
float *  val 
)
inline

Definition at line 425 of file util.h.

426{
427 return StringToFloatImpl(val, s);
428}

References StringToFloatImpl().

◆ StringToNumber() [3/3]

template<typename T >
bool flatbuffers::StringToNumber ( const char *  s,
T *  val 
)
inline

Definition at line 363 of file util.h.

364{
365 // Assert on `unsigned long` and `signed long` on LP64.
366 // If it is necessary, it could be solved with flatbuffers::enable_if<B,T>.
367 static_assert(sizeof(T) < sizeof(int64_t), "unexpected type T");
368 FLATBUFFERS_ASSERT(s && val);
369 int64_t i64;
370 // The errno check isn't needed, will return MAX/MIN on overflow.
371 if (StringToIntegerImpl(&i64, s, 0, false))
372 {
373 const int64_t max = (flatbuffers::numeric_limits<T>::max)();
374 const int64_t min = flatbuffers::numeric_limits<T>::lowest();
375 if (i64 > max)
376 {
377 *val = static_cast<T>(max);
378 return false;
379 }
380 if (i64 < min)
381 {
382 // For unsigned types return max to distinguish from
383 // "no conversion can be performed" when 0 is returned.
384 *val = static_cast<T>(flatbuffers::is_unsigned<T>::value ? max : min);
385 return false;
386 }
387 *val = static_cast<T>(i64);
388 return true;
389 }
390 *val = 0;
391 return false;
392}

References FLATBUFFERS_ASSERT, and StringToIntegerImpl().

Referenced by flexbuffers::Reference::AsDouble().

◆ StringToNumber< int64_t >()

template<>
bool flatbuffers::StringToNumber< int64_t > ( const char *  str,
int64_t *  val 
)
inline

Definition at line 394 of file util.h.

395{
396 return StringToIntegerImpl(val, str);
397}

References str, and StringToIntegerImpl().

◆ StringToNumber< uint64_t >()

template<>
bool flatbuffers::StringToNumber< uint64_t > ( const char *  str,
uint64_t *  val 
)
inline

Definition at line 399 of file util.h.

400{
401 if (!StringToIntegerImpl(val, str))
402 return false;
403 // The strtoull accepts negative numbers:
404 // If the minus sign was part of the input sequence, the numeric value
405 // calculated from the sequence of digits is negated as if by unary minus
406 // in the result type, which applies unsigned integer wraparound rules.
407 // Fix this behaviour (except -0).
408 if (*val)
409 {
410 auto s = str;
411 while (*s && !is_digit(*s))
412 s++;
413 s = (s > str) ? (s - 1) : s; // step back to one symbol
414 if (*s == '-')
415 {
416 // For unsigned types return the max to distinguish from
417 // "no conversion can be performed".
419 return false;
420 }
421 }
422 return true;
423}

References is_digit(), str, and StringToIntegerImpl().

◆ StringToUInt()

uint64_t flatbuffers::StringToUInt ( const char *  s,
int  base = 10 
)
inline

Definition at line 441 of file util.h.

442{
443 uint64_t val;
444 return StringToIntegerImpl(&val, s, base) ? val : 0;
445}

References StringToIntegerImpl().

Referenced by flexbuffers::Reference::AsUInt64().

◆ StripExtension()

std::string flatbuffers::StripExtension ( const std::string &  filepath)

◆ StripFileName()

std::string flatbuffers::StripFileName ( const std::string &  filepath)

◆ StripPath()

std::string flatbuffers::StripPath ( const std::string &  filepath)

◆ strtoval_impl() [1/3]

void flatbuffers::strtoval_impl ( double *  val,
const char *  str,
char **  endptr 
)
inline

Definition at line 284 of file util.h.

284 {
285 *val = __strtod_impl(str, endptr);
286}
#define __strtod_impl(s, pe)
Definition util.h:263

References __strtod_impl, endptr, and str.

◆ strtoval_impl() [2/3]

void flatbuffers::strtoval_impl ( int64_t *  val,
const char *  str,
char **  endptr,
int  base 
)
inline

Definition at line 274 of file util.h.

275 {
276 *val = __strtoll_impl(str, endptr, base);
277}
#define __strtoll_impl(s, pe, b)
Definition util.h:270

References __strtoll_impl, endptr, and str.

Referenced by StringToFloatImpl(), and StringToIntegerImpl().

◆ strtoval_impl() [3/3]

void flatbuffers::strtoval_impl ( uint64_t *  val,
const char *  str,
char **  endptr,
int  base 
)
inline

Definition at line 279 of file util.h.

280 {
281 *val = __strtoull_impl(str, endptr, base);
282}
#define __strtoull_impl(s, pe, b)
Definition util.h:269

References __strtoull_impl, endptr, and str.

◆ TextMakeRule()

std::string flatbuffers::TextMakeRule ( const Parser parser,
const std::string &  path,
const std::string &  file_names 
)
extern

◆ ToUTF8()

int flatbuffers::ToUTF8 ( uint32_t  ucc,
std::string *  out 
)
inline

Definition at line 521 of file util.h.

522{
523 FLATBUFFERS_ASSERT(!(ucc & 0x80000000)); // Top bit can't be set.
524 // 6 possible encodings: http://en.wikipedia.org/wiki/UTF-8
525 for (int i = 0; i < 6; i++)
526 {
527 // Max bits this encoding can represent.
528 uint32_t max_bits = 6 + i * 5 + static_cast<int>(!i);
529 if (ucc < (1u << max_bits))
530 { // does it fit?
531 // Remaining bits not encoded in the first byte, store 6 bits each
532 uint32_t remain_bits = i * 6;
533 // Store first byte:
534 (*out) += static_cast<char>((0xFE << (max_bits - remain_bits)) | (ucc >> remain_bits));
535 // Store remaining bytes:
536 for (int j = i - 1; j >= 0; j--)
537 {
538 (*out) += static_cast<char>(((ucc >> (j * 6)) & 0x3F) | 0x80);
539 }
540 return i + 1; // Return the number of bytes added.
541 }
542 }
543 FLATBUFFERS_ASSERT(0); // Impossible to arrive here.
544 return -1;
545}

References FLATBUFFERS_ASSERT.

◆ TSMakeRule()

std::string flatbuffers::TSMakeRule ( const Parser parser,
const std::string &  path,
const std::string &  file_name 
)
extern

◆ UnionTypeFieldSuffix()

const char * flatbuffers::UnionTypeFieldSuffix ( )
inline

Definition at line 420 of file reflection.h.

420{ return "_type"; }

Referenced by GetUnionType().

◆ vector_data() [1/2]

template<typename T >
const T * flatbuffers::vector_data ( const std::vector< T > &  vector)
inline

Definition at line 88 of file stl_emulation.h.

89 {
90 return vector.empty() ? nullptr : &vector[0];
91}

◆ vector_data() [2/2]

template<typename T >
T * flatbuffers::vector_data ( std::vector< T > &  vector)
inline

Definition at line 82 of file stl_emulation.h.

82 {
83 // In some debug environments, operator[] does bounds checking, so &vector[0]
84 // can't be used.
85 return vector.empty() ? nullptr : &vector[0];
86}

Referenced by flexbuffers::FLATBUFFERS_FINAL_CLASS::Blob(), flexbuffers::FLATBUFFERS_FINAL_CLASS::EndMap(), flexbuffers::GetRoot(), flatbuffers::pointer_inside_vector< T, U >::operator*(), and flexbuffers::FLATBUFFERS_FINAL_CLASS::Vector().

◆ vector_emplace_back()

template<typename T , typename V >
void flatbuffers::vector_emplace_back ( std::vector< T > *  vector,
V &&  data 
)
inline

Definition at line 94 of file stl_emulation.h.

94 {
95 #if defined(FLATBUFFERS_CPP98_STL)
96 vector->push_back(data);
97 #else
98 vector->emplace_back(std::forward<V>(data));
99 #endif // defined(FLATBUFFERS_CPP98_STL)
100}

References data().

Referenced by flatbuffers::SymbolTable< T >::Add().

◆ VectorCast() [1/2]

template<typename T , typename U >
const Vector< Offset< T > > * flatbuffers::VectorCast ( const Vector< Offset< U > > *  ptr)

Definition at line 436 of file flatbuffers.h.

437{
438 static_assert(std::is_base_of<T, U>::value, "Unrelated types");
439 return reinterpret_cast<const Vector<Offset<T>> *>(ptr);
440}

◆ VectorCast() [2/2]

template<typename T , typename U >
Vector< Offset< T > > * flatbuffers::VectorCast ( Vector< Offset< U > > *  ptr)

Definition at line 430 of file flatbuffers.h.

431{
432 static_assert(std::is_base_of<T, U>::value, "Unrelated types");
433 return reinterpret_cast<Vector<Offset<T>> *>(ptr);
434}

◆ Verify()

bool flatbuffers::Verify ( const reflection::Schema &  schema,
const reflection::Object &  root,
const uint8_t *  buf,
size_t  length,
uoffset_t  max_depth = 64,
uoffset_t  max_tables = 1000000 
)

◆ WordWrap()

std::string flatbuffers::WordWrap ( const std::string  in,
size_t  max_length,
const std::string  wrapped_line_prefix,
const std::string  wrapped_line_suffix 
)
inline

Definition at line 624 of file util.h.

627{
628 std::istringstream in_stream(in);
629 std::string wrapped, line, word;
630
631 in_stream >> word;
632 line = word;
633
634 while (in_stream >> word)
635 {
636 if ((line.length() + 1 + word.length() + wrapped_line_suffix.length()) < max_length)
637 {
638 line += " " + word;
639 }
640 else
641 {
642 wrapped += line + wrapped_line_suffix + "\n";
643 line = wrapped_line_prefix + word;
644 }
645 }
646 wrapped += line;
647
648 return wrapped;
649}

Variable Documentation

◆ dynamic_extent

FLATBUFFERS_CONSTEXPR std::size_t flatbuffers::dynamic_extent = static_cast<std::size_t>(-1)

◆ endptr

const char char** flatbuffers::endptr
Initial value:
{
*val = __strtof_impl(str, endptr)
#define __strtof_impl(s, pe)
Definition util.h:264

Definition at line 290 of file util.h.

Referenced by StringToIntegerImpl(), strtoval_impl(), strtoval_impl(), and strtoval_impl().

◆ kHashFunctions16

const NamedHashFunction<uint16_t> flatbuffers::kHashFunctions16[]
Initial value:
= {
{"fnv1_16", HashFnv1<uint16_t>},
{"fnv1a_16", HashFnv1a<uint16_t>},
}

Definition at line 89 of file hash.h.

89 {
90 {"fnv1_16", HashFnv1<uint16_t>},
91 {"fnv1a_16", HashFnv1a<uint16_t>},
92};

Referenced by FindHashFunction16().

◆ kHashFunctions32

const NamedHashFunction<uint32_t> flatbuffers::kHashFunctions32[]
Initial value:
= {
{"fnv1_32", HashFnv1<uint32_t>},
{"fnv1a_32", HashFnv1a<uint32_t>},
}

Definition at line 94 of file hash.h.

94 {
95 {"fnv1_32", HashFnv1<uint32_t>},
96 {"fnv1a_32", HashFnv1a<uint32_t>},
97};

Referenced by FindHashFunction32().

◆ kHashFunctions64

const NamedHashFunction<uint64_t> flatbuffers::kHashFunctions64[]
Initial value:
= {
{"fnv1_64", HashFnv1<uint64_t>},
{"fnv1a_64", HashFnv1a<uint64_t>},
}

Definition at line 99 of file hash.h.

99 {
100 {"fnv1_64", HashFnv1<uint64_t>},
101 {"fnv1a_64", HashFnv1a<uint64_t>},
102};

Referenced by FindHashFunction64().

◆ kPathSeparator

FLATBUFFERS_CONSTEXPR char flatbuffers::kPathSeparator = '/'

Definition at line 488 of file util.h.

◆ kTypeNames

const char* const flatbuffers::kTypeNames[]
extern

◆ kTypeSizes

const char flatbuffers::kTypeSizes[]
extern

Referenced by SizeOf().

◆ str