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< OffsetT< T >, length >
 
class  BaseGenerator
 
struct  bool_constant
 
struct  BufferRef
 
struct  BufferRefBase
 
class  CheckedError
 
class  CodeGenerator
 
struct  CodeGenOptions
 
class  CodeWriter
 
struct  CommentConfig
 
struct  conditional
 
class  DefaultAllocator
 
struct  Definition
 
class  DetachedBuffer
 
struct  EmptyOffset
 
struct  EnumDef
 
struct  EnumVal
 
struct  FieldDef
 
class  FileManager
 
class  FlatBufferBuilderImpl
 
class  FLATBUFFERS_FINAL_CLASS
 
class  FlatCompiler
 
struct  FlatCOption
 
struct  FlatCOptions
 
class  FloatConstantGenerator
 
struct  FnvTraits
 
struct  FnvTraits< uint32_t >
 
struct  FnvTraits< uint64_t >
 
struct  IDLOptions
 
struct  IncludedFile
 
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  NativeTable
 
struct  nullopt_t
 
class  numeric_limits
 
class  Parser
 
struct  ParserState
 
class  pointer_inside_vector
 
class  Registry
 
struct  RPCCall
 
struct  ServiceDef
 
class  SimpleFloatConstantGenerator
 
struct  String
 
struct  StructDef
 
class  SymbolTable
 
class  Table
 
struct  ToStringVisitor
 
struct  Type
 
struct  TypeCode
 
class  TypedFloatConstantGenerator
 
struct  TypeTable
 
class  unique_ptr
 
struct  Value
 
class  Vector
 
class  vector_downward
 
struct  VectorIterator
 
class  VectorOfAny
 
struct  VectorReverseIterator
 

Typedefs

using FlatBufferBuilder = FlatBufferBuilderImpl< false >
 
using FlatBufferBuilder64 = FlatBufferBuilderImpl< true >
 
typedef uint64_t hash_value_t
 Function types to be used with resolving hashes into objects and back again. The resolver gets a pointer to a field inside an object API object that is of the type specified in the schema using the attribute cpp_type (it is thus important whatever you write to this address matches that type). The value of this field is initially null, so you may choose to implement a delayed binding lookup using this function if you wish. The resolver does the opposite lookup, for when the object is being serialized again.
 
typedef std::function< void(void **pointer_adr, hash_value_t hash)> resolver_function_t
 
typedef std::function< hash_value_t(void *pointer)> rehasher_function_t
 
typedef const TypeTable *(* TypeFunction) ()
 
typedef bool_constant< true > true_type
 
typedef bool_constant< false > false_type
 
typedef bool(* LoadFileFunction) (const char *filename, bool binary, std::string *dest)
 
typedef bool(* FileExistsFunction) (const char *filename)
 
template<typename T , typename IT , typename SizeT = uoffset_t>
using VectorConstIterator = VectorIterator< T, IT, const uint8_t *, SizeT >
 
template<typename T >
using Vector64 = Vector< T, uoffset64_t >
 

Enumerations

enum  SequenceType { ST_TABLE , ST_STRUCT , ST_UNION , ST_ENUM }
 
enum  ElementaryType
 
enum  BaseType
 
enum class  Case {
  kUnknown = 0 , kUpperCamel = 1 , kLowerCamel = 2 , kSnake = 3 ,
  kScreamingSnake = 4 , kAllUpper = 5 , kAllLower = 6 , kDasher = 7 ,
  kKeep = 8 , kSnake2 = 9
}
 

Functions

template<class U , uint16_t N>
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span< U, N > make_span (Array< U, N > &arr) FLATBUFFERS_NOEXCEPT
 
template<class U , uint16_t N>
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span< const U, N > make_span (const Array< U, N > &arr) FLATBUFFERS_NOEXCEPT
 
template<class U , uint16_t N>
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span< uint8_t, sizeof(U) *N > make_bytes_span (Array< U, N > &arr) FLATBUFFERS_NOEXCEPT
 
template<class U , uint16_t N>
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span< const uint8_t, sizeof(U) *N > make_bytes_span (const Array< U, N > &arr) FLATBUFFERS_NOEXCEPT
 
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])
 
template<typename T , uint16_t length>
bool operator== (const Array< T, length > &lhs, const Array< T, length > &rhs) noexcept
 
void GenComment (const std::vector< std::string > &dc, std::string *code_ptr, const CommentConfig *config, const char *prefix="")
 
std::string JavaCSharpMakeRule (const bool java, const Parser &parser, const std::string &path, const std::string &file_name)
 
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 = std::allocator<T>>
const T * data (const std::vector< T, Alloc > &v)
 
template<typename T , typename Alloc = std::allocator<T>>
T * data (std::vector< T, Alloc > &v)
 
template<typename T >
T * GetMutableTemporaryPointer (FlatBufferBuilder &fbb, Offset< T > offset)
 
template<typename T >
const T * GetTemporaryPointer (FlatBufferBuilder &fbb, Offset< T > offset)
 
const uint8_t * GetBufferStartFromRootPointer (const void *root)
 This can compute the start of a FlatBuffer from a root pointer, i.e. it is the opposite transformation of GetRoot(). This may be useful if you want to pass on a root and have the recipient delete the buffer afterwards.
 
template<typename SizeT = uoffset_t>
SizeT GetPrefixedSize (const uint8_t *buf)
 This return the prefixed size of a FlatBuffer.
 
template<typename SizeT = uoffset_t>
SizeT GetSizePrefixedBufferLength (const uint8_t *const buf)
 
template<typename T >
bool IsFieldPresent (const T *table, typename T::FlatBuffersVTableOffset field)
 
int LookupEnum (const char **names, const char *name)
 
const char *const * ElementaryTypeNames ()
 
const char * flatbuffers_version_string ()
 
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 IsVector (BaseType t)
 
bool IsUnsigned (BaseType t)
 
size_t SizeOf (const BaseType t)
 
const char * TypeName (const BaseType t)
 
const char * StringOf (const BaseType t)
 
bool operator< (const Namespace &a, const Namespace &b)
 
bool IsString (const Type &type)
 
bool IsStruct (const Type &type)
 
bool IsIncompleteStruct (const Type &type)
 
bool IsTable (const Type &type)
 
bool IsUnion (const Type &type)
 
bool IsUnionType (const Type &type)
 
bool IsVector (const Type &type)
 
bool IsVectorOfStruct (const Type &type)
 
bool IsVectorOfTable (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)
 
bool operator< (const IncludedFile &a, const IncludedFile &b)
 
const char * GenTextFromTable (const Parser &parser, const void *table, const std::string &tablename, std::string *text)
 
const char * GenText (const Parser &parser, const void *flatbuffer, std::string *text)
 
const char * GenTextFile (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, const std::string &indent="")
 
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)
 
TableGetAnyRoot (uint8_t *const flatbuf)
 
const TableGetAnyRoot (const uint8_t *const flatbuf)
 
TableGetAnySizePrefixedRoot (uint8_t *const flatbuf)
 
const TableGetAnySizePrefixedRoot (const uint8_t *const 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)
 
TableGetFieldT (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)
 
void ForAllFields (const reflection::Object *object, bool reverse, std::function< void(const reflection::Field *)> func)
 
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)
 
bool VerifySizePrefixed (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)
 
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)
 
void strtoval_impl (float *val, const char *str, char **endptr)
 
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)
 
bool StringIsFlatbufferNan (const std::string &s)
 
bool StringIsFlatbufferPositiveInfinity (const std::string &s)
 
bool StringIsFlatbufferNegativeInfinity (const std::string &s)
 
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 StripPrefix (const std::string &filepath, const std::string &prefix_to_remove)
 
std::string ConCatPathFileName (const std::string &path, const std::string &filename)
 
std::string PosixPath (const char *path)
 
std::string PosixPath (const std::string &path)
 
void EnsureDirExists (const std::string &filepath)
 
std::string AbsolutePath (const std::string &filepath)
 
std::string RelativeToRootPath (const std::string &project, 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)
 
std::string ConvertCase (const std::string &input, Case output_case, Case input_case=Case::kSnake)
 
template<class U >
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span< U > make_span (Vector< U > &vec) FLATBUFFERS_NOEXCEPT
 
template<class U >
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span< const U > make_span (const Vector< U > &vec) FLATBUFFERS_NOEXCEPT
 
template<class U >
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span< uint8_t > make_bytes_span (Vector< U > &vec) FLATBUFFERS_NOEXCEPT
 
template<class U >
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span< const uint8_t > make_bytes_span (const Vector< U > &vec) FLATBUFFERS_NOEXCEPT
 
template<class U >
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span< U > make_span (Vector< U > *ptr) FLATBUFFERS_NOEXCEPT
 
template<class U >
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span< const U > make_span (const Vector< U > *ptr) FLATBUFFERS_NOEXCEPT
 
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)
 

Variables

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

Typedef Documentation

◆ false_type

Definition at line 108 of file stl_emulation.h.

◆ FileExistsFunction

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

Definition at line 412 of file util.h.

◆ FlatBufferBuilder

Definition at line 1414 of file flatbuffer_builder.h.

◆ FlatBufferBuilder64

Definition at line 1415 of file flatbuffer_builder.h.

◆ hash_value_t

typedef uint64_t flatbuffers::hash_value_t

Function types to be used with resolving hashes into objects and back again. The resolver gets a pointer to a field inside an object API object that is of the type specified in the schema using the attribute cpp_type (it is thus important whatever you write to this address matches that type). The value of this field is initially null, so you may choose to implement a delayed binding lookup using this function if you wish. The resolver does the opposite lookup, for when the object is being serialized again.

Definition at line 108 of file flatbuffers.h.

◆ LoadFileFunction

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

Definition at line 410 of file util.h.

◆ rehasher_function_t

typedef std::function<hash_value_t(void *pointer)> flatbuffers::rehasher_function_t

Definition at line 111 of file flatbuffers.h.

◆ resolver_function_t

typedef std::function<void(void **pointer_adr, hash_value_t hash)> flatbuffers::resolver_function_t

Definition at line 110 of file flatbuffers.h.

◆ true_type

Definition at line 107 of file stl_emulation.h.

◆ TypeFunction

typedef const TypeTable *(* flatbuffers::TypeFunction) ()

Definition at line 230 of file flatbuffers.h.

◆ Vector64

template<typename T >
using flatbuffers::Vector64 = typedef Vector<T, uoffset64_t>

Definition at line 304 of file vector.h.

◆ VectorConstIterator

template<typename T , typename IT , typename SizeT = uoffset_t>
using flatbuffers::VectorConstIterator = typedef VectorIterator<T, IT, const uint8_t *, SizeT>

Definition at line 124 of file vector.h.

Enumeration Type Documentation

◆ BaseType

Definition at line 118 of file idl.h.

118 {
119 #define FLATBUFFERS_TD(ENUM, IDLTYPE, \
120 CTYPE, JTYPE, GTYPE, NTYPE, PTYPE, RTYPE, KTYPE, STYPE, ENUM_VALUE) \
121 BASE_TYPE_ ## ENUM = ENUM_VALUE,
123 #undef FLATBUFFERS_TD
124};
#define FLATBUFFERS_GEN_TYPES(TD)
Definition idl.h:109
#define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, JTYPE, GTYPE, NTYPE, PTYPE, RTYPE, KTYPE, STYPE, ENUM_VALUE)
Definition idl.h:119

◆ Case

enum class flatbuffers::Case
strong
Enumerator
kUnknown 
kUpperCamel 
kLowerCamel 
kSnake 
kScreamingSnake 
kAllUpper 
kAllLower 
kDasher 
kKeep 
kSnake2 

Definition at line 703 of file util.h.

703 {
704 kUnknown = 0,
705 // TheQuickBrownFox
706 kUpperCamel = 1,
707 // theQuickBrownFox
708 kLowerCamel = 2,
709 // the_quick_brown_fox
710 kSnake = 3,
711 // THE_QUICK_BROWN_FOX
712 kScreamingSnake = 4,
713 // THEQUICKBROWNFOX
714 kAllUpper = 5,
715 // thequickbrownfox
716 kAllLower = 6,
717 // the-quick-brown-fox
718 kDasher = 7,
719 // THEQuiCKBr_ownFox (or whatever you want, we won't change it)
720 kKeep = 8,
721 // the_quick_brown_fox123 (as opposed to the_quick_brown_fox_123)
722 kSnake2 = 9,
723};

◆ ElementaryType

Definition at line 196 of file flatbuffers.h.

196 {
197 #define FLATBUFFERS_ET(E) E,
199 #undef FLATBUFFERS_ET
200};
#define FLATBUFFERS_GEN_ELEMENTARY_TYPES(ET)
#define FLATBUFFERS_ET(E)

◆ SequenceType

Enumerator
ST_TABLE 
ST_STRUCT 
ST_UNION 
ST_ENUM 

Definition at line 176 of file flatbuffers.h.

Function Documentation

◆ 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 
)

◆ Allocate()

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

Definition at line 41 of file default_allocator.h.

41 {
42 return allocator ? allocator->allocate(size)
44}
uint8_t * allocate(size_t size) FLATBUFFERS_OVERRIDE
int32_t size[5]
Definition Slice.cpp:35
src_tensor allocator() -> init(p.src_info< NHWC >())

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

◆ 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 664 of file util.h.

667 {
668 std::string text = wrapped_line_prefix;
669 size_t start_offset = 0;
670 const char *s = reinterpret_cast<const char *>(buffer);
671 for (size_t i = 0; s && i < buffer_size; i++) {
672 // Last iteration or do we have more?
673 bool have_more = i + 1 < buffer_size;
674 text += "0x";
675 text += IntToStringHex(static_cast<uint8_t>(s[i]), 2);
676 if (have_more) { text += ','; }
677 // If we have more to process and we reached max_length
678 if (have_more &&
679 text.size() + wrapped_line_suffix.size() >= start_offset + max_length) {
680 text += wrapped_line_suffix;
681 text += '\n';
682 start_offset = text.size();
683 text += wrapped_line_prefix;
684 }
685 }
686 text += wrapped_line_suffix;
687 return text;
688}
std::string IntToStringHex(int i, int xdigits)
Definition util.h:190

References IntToStringHex().

◆ CastToArray() [1/2]

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

Definition at line 230 of file array.h.

230 {
231 return *reinterpret_cast<const Array<T, length> *>(arr);
232}

◆ CastToArray() [2/2]

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

Definition at line 225 of file array.h.

225 {
226 return *reinterpret_cast<Array<T, length> *>(arr);
227}

◆ CastToArrayOfEnum() [1/2]

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

Definition at line 241 of file array.h.

241 {
242 static_assert(sizeof(E) == sizeof(T), "invalid enum type E");
243 return *reinterpret_cast<const Array<E, length> *>(arr);
244}

◆ CastToArrayOfEnum() [2/2]

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

Definition at line 235 of file array.h.

235 {
236 static_assert(sizeof(E) == sizeof(T), "invalid enum type E");
237 return *reinterpret_cast<Array<E, length> *>(arr);
238}

◆ CharToLower()

char flatbuffers::CharToLower ( char  c)
inline

Definition at line 86 of file util.h.

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

◆ CharToUpper()

char flatbuffers::CharToUpper ( char  c)
inline

Definition at line 82 of file util.h.

82 {
83 return static_cast<char>(::toupper(static_cast<unsigned char>(c)));
84}

◆ check_ascii_range()

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

Definition at line 44 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:21

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 
)

◆ ConvertCase()

std::string flatbuffers::ConvertCase ( const std::string &  input,
Case  output_case,
Case  input_case = Case::kSnake 
)

◆ CopyTable()

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

◆ data() [1/2]

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

Definition at line 52 of file flatbuffer_builder.h.

52 {
53 // Eventually the returned pointer gets passed down to memcpy, so
54 // we need it to be non-null to avoid undefined behavior.
55 static uint8_t t;
56 return v.empty() ? reinterpret_cast<const T *>(&t) : &v.front();
57}

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::cal_minmax_per_channel(), luci_interpreter::RuntimeGraph::configureGraphInput(), luci_interpreter::RuntimeGraph::configureGraphInput(), flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateVector(), flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateVector64(), flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateVectorOfNativeStructs(), flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateVectorOfNativeStructs(), flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateVectorOfSortedNativeStructs(), flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateVectorOfSortedStructs(), flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateVectorOfSortedTables(), flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateVectorOfStructs(), flatbuffers::FlatBufferBuilderImpl< Is64Aware >::CreateVectorOfStructs64(), 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(), luci::compute::FullyConnected::weights(), and luci_interpreter::Interpreter::writeInputTensor().

◆ data() [2/2]

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

Definition at line 59 of file flatbuffer_builder.h.

59 {
60 // Eventually the returned pointer gets passed down to memcpy, so
61 // we need it to be non-null to avoid undefined behavior.
62 static uint8_t t;
63 return v.empty() ? reinterpret_cast<T *>(&t) : &v.front();
64}

◆ Deallocate()

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

Definition at line 46 of file default_allocator.h.

46 {
47 if (allocator)
48 allocator->deallocate(p, size);
49 else
51}
void deallocate(uint8_t *p, size_t) FLATBUFFERS_OVERRIDE
Configuration p

References allocator(), flatbuffers::DefaultAllocator::deallocate(), p, and size.

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

◆ DirExists()

bool flatbuffers::DirExists ( const char *  name)

◆ ElementaryTypeNames()

const char *const * flatbuffers::ElementaryTypeNames ( )
inline

Definition at line 202 of file flatbuffers.h.

202 {
203 static const char * const names[] = {
204 #define FLATBUFFERS_ET(E) #E,
206 #undef FLATBUFFERS_ET
207 };
208 return names;
209}

References FLATBUFFERS_ET, and FLATBUFFERS_GEN_ELEMENTARY_TYPES.

◆ EnsureDirExists()

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

◆ EnumName()

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

Definition at line 108 of file minireflect.h.

108 {
109 if (!type_table || !type_table->names) return nullptr;
110 auto i = LookupEnum(static_cast<int64_t>(tval), type_table->values,
111 type_table->num_elems);
112 if (i >= 0 && i < static_cast<int64_t>(type_table->num_elems)) {
113 return type_table->names[i];
114 }
115 return nullptr;
116}
int LookupEnum(const char **names, const char *name)
const char *const * names
const int64_t * values

References LookupEnum(), flatbuffers::TypeTable::names, flatbuffers::TypeTable::num_elems, and flatbuffers::TypeTable::values.

Referenced by IterateValue().

◆ EqualByName()

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

Definition at line 584 of file idl.h.

584 {
585 return a.base_type == b.base_type && a.element == b.element &&
586 (a.struct_def == b.struct_def ||
587 (a.struct_def != nullptr && b.struct_def != nullptr &&
588 a.struct_def->name == b.struct_def->name)) &&
589 (a.enum_def == b.enum_def ||
590 (a.enum_def != nullptr && b.enum_def != nullptr &&
591 a.enum_def->name == b.enum_def->name));
592}
std::string name
Definition idl.h:312
BaseType element
Definition idl.h:216
StructDef * struct_def
Definition idl.h:218
BaseType base_type
Definition idl.h:215
EnumDef * enum_def
Definition idl.h:219

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 594 of file util.h.

595 {
596 std::string &text = *_text;
597 text += "\"";
598 for (uoffset_t i = 0; i < length; i++) {
599 char c = s[i];
600 switch (c) {
601 case '\n': text += "\\n"; break;
602 case '\t': text += "\\t"; break;
603 case '\r': text += "\\r"; break;
604 case '\b': text += "\\b"; break;
605 case '\f': text += "\\f"; break;
606 case '\"': text += "\\\""; break;
607 case '\\': text += "\\\\"; break;
608 default:
609 if (c >= ' ' && c <= '~') {
610 text += c;
611 } else {
612 // Not printable ASCII data. Let's see if it's valid UTF-8 first:
613 const char *utf8 = s + i;
614 int ucc = FromUTF8(&utf8);
615 if (ucc < 0) {
616 if (allow_non_utf8) {
617 text += "\\x";
618 text += IntToStringHex(static_cast<uint8_t>(c), 2);
619 } else {
620 // There are two cases here:
621 //
622 // 1) We reached here by parsing an IDL file. In that case,
623 // we previously checked for non-UTF-8, so we shouldn't reach
624 // here.
625 //
626 // 2) We reached here by someone calling GenText()
627 // on a previously-serialized flatbuffer. The data might have
628 // non-UTF-8 Strings, or might be corrupt.
629 //
630 // In both cases, we have to give up and inform the caller
631 // they have no JSON.
632 return false;
633 }
634 } else {
635 if (natural_utf8) {
636 // utf8 points to past all utf-8 bytes parsed
637 text.append(s + i, static_cast<size_t>(utf8 - s - i));
638 } else if (ucc <= 0xFFFF) {
639 // Parses as Unicode within JSON's \uXXXX range, so use that.
640 text += "\\u";
641 text += IntToStringHex(ucc, 4);
642 } else if (ucc <= 0x10FFFF) {
643 // Encode Unicode SMP values to a surrogate pair using two \u
644 // escapes.
645 uint32_t base = ucc - 0x10000;
646 auto high_surrogate = (base >> 10) + 0xD800;
647 auto low_surrogate = (base & 0x03FF) + 0xDC00;
648 text += "\\u";
649 text += IntToStringHex(high_surrogate, 4);
650 text += "\\u";
651 text += IntToStringHex(low_surrogate, 4);
652 }
653 // Skip past characters recognized.
654 i = static_cast<uoffset_t>(utf8 - s - 1);
655 }
656 }
657 break;
658 }
659 }
660 text += "\"";
661 return true;
662}

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 44 of file flatbuffer_builder.h.

44 {
45 // Should correspond to what EndTable() below builds up.
46 const voffset_t fixed_fields =
47 2 * sizeof(voffset_t); // Vtable size and Object Size.
48 return fixed_fields + field_id * sizeof(voffset_t);
49}

Referenced by IterateObject().

◆ FileExists()

bool flatbuffers::FileExists ( const char *  name)

◆ FindHashFunction16()

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

Definition at line 92 of file hash.h.

93 {
94 std::size_t size = sizeof(kHashFunctions16) / sizeof(kHashFunctions16[0]);
95 for (std::size_t i = 0; i < size; ++i) {
96 if (std::strcmp(name, kHashFunctions16[i].name) == 0) {
97 return kHashFunctions16[i].function;
98 }
99 }
100 return nullptr;
101}
const NamedHashFunction< uint16_t > kHashFunctions16[]
Definition hash.h:77

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

◆ FindHashFunction32()

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

Definition at line 103 of file hash.h.

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

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

◆ FindHashFunction64()

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

Definition at line 114 of file hash.h.

115 {
116 std::size_t size = sizeof(kHashFunctions64) / sizeof(kHashFunctions64[0]);
117 for (std::size_t i = 0; i < size; ++i) {
118 if (std::strcmp(name, kHashFunctions64[i].name) == 0) {
119 return kHashFunctions64[i].function;
120 }
121 }
122 return nullptr;
123}
const NamedHashFunction< uint64_t > kHashFunctions64[]
Definition hash.h:87

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

◆ flatbuffers_version_string()

const char * flatbuffers::flatbuffers_version_string ( )
inline

Definition at line 243 of file flatbuffers.h.

243 {
244 return "FlatBuffers " FLATBUFFERS_STRING(FLATBUFFERS_VERSION_MAJOR) "."
245 FLATBUFFERS_STRING(FLATBUFFERS_VERSION_MINOR) "."
246 FLATBUFFERS_STRING(FLATBUFFERS_VERSION_REVISION);
247}

◆ FlatBufferToString()

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

Definition at line 407 of file minireflect.h.

411 {
412 ToStringVisitor tostring_visitor(multi_line ? "\n" : " ", false, indent,
413 vector_delimited);
414 IterateFlatBuffer(buffer, type_table, &tostring_visitor);
415 return tostring_visitor.s;
416}
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 153 of file util.h.

153 {
154 // clang-format off
155
156 #ifndef FLATBUFFERS_PREFER_PRINTF
157 // to_string() prints different numbers of digits for floats depending on
158 // platform and isn't available on Android, so we use stringstream
159 std::stringstream ss;
160 // Use std::fixed to suppress scientific notation.
161 ss << std::fixed;
162 // Default precision is 6, we want that to be higher for doubles.
163 ss << std::setprecision(precision);
164 ss << t;
165 auto s = ss.str();
166 #else // FLATBUFFERS_PREFER_PRINTF
167 auto v = static_cast<double>(t);
168 auto s = NumToStringImplWrapper(v, "%0.*f", precision);
169 #endif // FLATBUFFERS_PREFER_PRINTF
170 // clang-format on
171 // Sadly, std::fixed turns "1" into "1.00000", so here we undo that.
172 auto p = s.find_last_not_of('0');
173 if (p != std::string::npos) {
174 // Strip trailing zeroes. If it is a whole number, keep one zero.
175 s.resize(p + (s[p] == '.' ? 2 : 1));
176 }
177 return s;
178}

References p.

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

◆ ForAllFields()

void flatbuffers::ForAllFields ( const reflection::Object *  object,
bool  reverse,
std::function< void(const reflection::Field *)>  func 
)

◆ FromUTF8()

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

Definition at line 522 of file util.h.

522 {
523 int len = 0;
524 // Count leading 1 bits.
525 for (int mask = 0x80; mask >= 0x04; mask >>= 1) {
526 if (**in & mask) {
527 len++;
528 } else {
529 break;
530 }
531 }
532 if ((static_cast<unsigned char>(**in) << len) & 0x80)
533 return -1; // Bit after leading 1's must be 0.
534 if (!len) return *(*in)++;
535 // UTF-8 encoded values with a length are between 2 and 4 bytes.
536 if (len < 2 || len > 4) { return -1; }
537 // Grab initial bits of the code.
538 int ucc = *(*in)++ & ((1 << (7 - len)) - 1);
539 for (int i = 0; i < len - 1; i++) {
540 if ((**in & 0xC0) != 0x80) return -1; // Upper bits must 1 0.
541 ucc <<= 6;
542 ucc |= *(*in)++ & 0x3F; // Grab 6 more bits of the code.
543 }
544 // UTF-8 cannot encode values between 0xD800 and 0xDFFF (reserved for
545 // UTF-16 surrogate pairs).
546 if (ucc >= 0xD800 && ucc <= 0xDFFF) { return -1; }
547 // UTF-8 must represent code points in their shortest possible encoding.
548 switch (len) {
549 case 2:
550 // Two bytes of UTF-8 can represent code points from U+0080 to U+07FF.
551 if (ucc < 0x0080 || ucc > 0x07FF) { return -1; }
552 break;
553 case 3:
554 // Three bytes of UTF-8 can represent code points from U+0800 to U+FFFF.
555 if (ucc < 0x0800 || ucc > 0xFFFF) { return -1; }
556 break;
557 case 4:
558 // Four bytes of UTF-8 can represent code points from U+10000 to U+10FFFF.
559 if (ucc < 0x10000 || ucc > 0x10FFFF) { return -1; }
560 break;
561 }
562 return ucc;
563}

Referenced by EscapeString().

◆ GenComment()

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

◆ GenerateCppGRPC()

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

◆ GenerateGoGRPC()

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

◆ GenerateJavaGRPC()

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

◆ GeneratePythonGRPC()

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

◆ GenerateSwiftGRPC()

bool flatbuffers::GenerateSwiftGRPC ( 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

◆ GenText()

const char * flatbuffers::GenText ( const Parser parser,
const void *  flatbuffer,
std::string *  text 
)
extern

◆ GenTextFile()

const char * flatbuffers::GenTextFile ( const Parser parser,
const std::string &  path,
const std::string &  file_name 
)
extern

◆ GenTextFromTable()

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

◆ GetAnyFieldAddressOf() [1/2]

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

Definition at line 288 of file reflection.h.

288 {
289 return reinterpret_cast<T *>(st.GetAddressOf(field.offset()));
290}

◆ GetAnyFieldAddressOf() [2/2]

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

Definition at line 282 of file reflection.h.

282 {
283 return reinterpret_cast<T *>(table.GetAddressOf(field.offset()));
284}
uint8_t * GetAddressOf(voffset_t field)
Definition table.h:105

References flatbuffers::Table::GetAddressOf().

◆ GetAnyFieldF() [1/2]

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

Definition at line 229 of file reflection.h.

229 {
230 return GetAnyValueF(field.type()->base_type(),
231 st.GetAddressOf(field.offset()));
232}
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 204 of file reflection.h.

204 {
205 auto field_ptr = table.GetAddressOf(field.offset());
206 return field_ptr ? GetAnyValueF(field.type()->base_type(), field_ptr)
207 : field.default_real();
208}

References flatbuffers::Table::GetAddressOf(), and GetAnyValueF().

◆ GetAnyFieldI() [1/2]

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

Definition at line 223 of file reflection.h.

223 {
224 return GetAnyValueI(field.type()->base_type(),
225 st.GetAddressOf(field.offset()));
226}
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 196 of file reflection.h.

197 {
198 auto field_ptr = table.GetAddressOf(field.offset());
199 return field_ptr ? GetAnyValueI(field.type()->base_type(), field_ptr)
200 : field.default_integer();
201}

References flatbuffers::Table::GetAddressOf(), and GetAnyValueI().

◆ GetAnyFieldS() [1/2]

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

Definition at line 235 of file reflection.h.

236 {
237 return GetAnyValueS(field.type()->base_type(),
238 st.GetAddressOf(field.offset()), nullptr, -1);
239}
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 213 of file reflection.h.

215 {
216 auto field_ptr = table.GetAddressOf(field.offset());
217 return field_ptr ? GetAnyValueS(field.type()->base_type(), field_ptr, schema,
218 field.type()->index())
219 : "";
220}

References flatbuffers::Table::GetAddressOf(), and GetAnyValueS().

◆ GetAnyRoot() [1/2]

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

Definition at line 96 of file reflection.h.

96 {
97 return GetRoot<Table>(flatbuf);
98}

◆ GetAnyRoot() [2/2]

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

Definition at line 92 of file reflection.h.

92 {
93 return GetMutableRoot<Table>(flatbuf);
94}

◆ GetAnySizePrefixedRoot() [1/2]

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

Definition at line 104 of file reflection.h.

104 {
105 return GetSizePrefixedRoot<Table>(flatbuf);
106}

◆ GetAnySizePrefixedRoot() [2/2]

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

Definition at line 100 of file reflection.h.

100 {
101 return GetMutableSizePrefixedRoot<Table>(flatbuf);
102}

◆ 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 275 of file reflection.h.

276 {
277 return reinterpret_cast<T *>(vec->Data() + elem_size * i);
278}
const uint8_t * Data() const
Definition vector.h:362

References flatbuffers::VectorOfAny::Data().

◆ GetAnyVectorElemF()

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

Definition at line 248 of file reflection.h.

249 {
250 return GetAnyValueF(elem_type, vec->Data() + GetTypeSize(elem_type) * i);
251}
size_t GetTypeSize(reflection::BaseType base_type)
Definition reflection.h:47

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 242 of file reflection.h.

243 {
244 return GetAnyValueI(elem_type, vec->Data() + GetTypeSize(elem_type) * i);
245}

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

◆ GetAnyVectorElemPointer()

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

Definition at line 264 of file reflection.h.

264 {
265 auto elem_ptr = vec->Data() + sizeof(uoffset_t) * i;
266 return reinterpret_cast<T *>(elem_ptr + ReadScalar<uoffset_t>(elem_ptr));
267}

References flatbuffers::VectorOfAny::Data().

◆ GetAnyVectorElemS()

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

Definition at line 254 of file reflection.h.

255 {
256 return GetAnyValueS(elem_type, vec->Data() + GetTypeSize(elem_type) * i,
257 nullptr, -1);
258}

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

◆ GetBufferStartFromRootPointer()

const uint8_t * flatbuffers::GetBufferStartFromRootPointer ( const void *  root)
inline

This can compute the start of a FlatBuffer from a root pointer, i.e. it is the opposite transformation of GetRoot(). This may be useful if you want to pass on a root and have the recipient delete the buffer afterwards.

Definition at line 44 of file flatbuffers.h.

44 {
45 auto table = reinterpret_cast<const Table *>(root);
46 auto vtable = table->GetVTable();
47 // Either the vtable is before the root or after the root.
48 auto start = (std::min)(vtable, reinterpret_cast<const uint8_t *>(root));
49 // Align to at least sizeof(uoffset_t).
50 start = reinterpret_cast<const uint8_t *>(reinterpret_cast<uintptr_t>(start) &
51 ~(sizeof(uoffset_t) - 1));
52 // Additionally, there may be a file_identifier in the buffer, and the root
53 // offset. The buffer may have been aligned to any size between
54 // sizeof(uoffset_t) and FLATBUFFERS_MAX_ALIGNMENT (see "force_align").
55 // Sadly, the exact alignment is only known when constructing the buffer,
56 // since it depends on the presence of values with said alignment properties.
57 // So instead, we simply look at the next uoffset_t values (root,
58 // file_identifier, and alignment padding) to see which points to the root.
59 // None of the other values can "impersonate" the root since they will either
60 // be 0 or four ASCII characters.
61 static_assert(flatbuffers::kFileIdentifierLength == sizeof(uoffset_t),
62 "file_identifier is assumed to be the same size as uoffset_t");
63 for (auto possible_roots = FLATBUFFERS_MAX_ALIGNMENT / sizeof(uoffset_t) + 1;
64 possible_roots; possible_roots--) {
65 start -= sizeof(uoffset_t);
66 if (ReadScalar<uoffset_t>(start) + start ==
67 reinterpret_cast<const uint8_t *>(root))
68 return start;
69 }
70 // We didn't find the root, either the "root" passed isn't really a root,
71 // or the buffer is corrupt.
72 // Assert, because calling this function with bad data may cause reads
73 // outside of buffer boundaries.
74 FLATBUFFERS_ASSERT(false);
75 return nullptr;
76}
const uint8_t * GetVTable() const
Definition table.h:29

References FLATBUFFERS_ASSERT, and flatbuffers::Table::GetVTable().

◆ GetExtension()

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

◆ GetFieldAnyV()

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

Definition at line 154 of file reflection.h.

155 {
156 return table.GetPointer<VectorOfAny *>(field.offset());
157}
P GetPointer(voffset_t field)
Definition table.h:51

References flatbuffers::Table::GetPointer().

◆ GetFieldDefaultF()

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

Definition at line 115 of file reflection.h.

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

References FLATBUFFERS_ASSERT, and GetTypeSize().

◆ GetFieldDefaultI()

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

Definition at line 109 of file reflection.h.

109 {
110 FLATBUFFERS_ASSERT(sizeof(T) == GetTypeSize(field.type()->base_type()));
111 return static_cast<T>(field.default_integer());
112}

References FLATBUFFERS_ASSERT, and GetTypeSize().

◆ GetFieldF()

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

Definition at line 130 of file reflection.h.

130 {
131 FLATBUFFERS_ASSERT(sizeof(T) == GetTypeSize(field.type()->base_type()));
132 return table.GetField<T>(field.offset(),
133 static_cast<T>(field.default_real()));
134}
T GetField(voffset_t field, T defaultval) const
Definition table.h:45

References FLATBUFFERS_ASSERT, flatbuffers::Table::GetField(), and GetTypeSize().

◆ GetFieldI()

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

Definition at line 122 of file reflection.h.

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

References FLATBUFFERS_ASSERT, flatbuffers::Table::GetField(), and GetTypeSize().

◆ GetFieldS()

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

Definition at line 137 of file reflection.h.

138 {
139 FLATBUFFERS_ASSERT(field.type()->base_type() == reflection::String);
140 return table.GetPointer<const String *>(field.offset());
141}

References FLATBUFFERS_ASSERT, and flatbuffers::Table::GetPointer().

◆ GetFieldStruct() [1/2]

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

Definition at line 176 of file reflection.h.

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

References FLATBUFFERS_ASSERT.

◆ GetFieldStruct() [2/2]

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

Definition at line 167 of file reflection.h.

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

References FLATBUFFERS_ASSERT, and flatbuffers::Table::GetStruct().

◆ GetFieldT()

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

Definition at line 160 of file reflection.h.

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

References FLATBUFFERS_ASSERT, and flatbuffers::Table::GetPointer().

◆ GetFieldV()

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

Definition at line 145 of file reflection.h.

145 {
146 FLATBUFFERS_ASSERT(field.type()->base_type() == reflection::Vector &&
147 sizeof(T) == GetTypeSize(field.type()->element()));
148 return table.GetPointer<Vector<T> *>(field.offset());
149}

References FLATBUFFERS_ASSERT, flatbuffers::Table::GetPointer(), and GetTypeSize().

◆ GetMutableTemporaryPointer()

template<typename T >
T * flatbuffers::GetMutableTemporaryPointer ( FlatBufferBuilder fbb,
Offset< T >  offset 
)

Helpers to get a typed pointer to objects that are currently being built.

Warning
Creating new objects will lead to reallocations and invalidates the pointer!

Definition at line 1453 of file flatbuffer_builder.h.

1453 {
1454 return reinterpret_cast<T *>(fbb.GetCurrentBufferPointer() + fbb.GetSize() -
1455 offset.o);
1456}
uint8_t * GetCurrentBufferPointer() const
Get a pointer to an unfinished buffer.
SizeT GetSize() const
The current size of the serialized buffer, counting from the end.
__global uchar * offset(const Image *img, int x, int y)
Definition helpers.h:540

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

◆ GetPrefixedSize()

template<typename SizeT = uoffset_t>
SizeT flatbuffers::GetPrefixedSize ( const uint8_t *  buf)
inline

This return the prefixed size of a FlatBuffer.

Definition at line 80 of file flatbuffers.h.

80 {
81 return ReadScalar<SizeT>(buf);
82}

◆ GetSizePrefixedBufferLength()

template<typename SizeT = uoffset_t>
SizeT flatbuffers::GetSizePrefixedBufferLength ( const uint8_t *const  buf)
inline

Definition at line 91 of file flatbuffers.h.

91 {
92 return ReadScalar<SizeT>(buf) + sizeof(SizeT);
93}

◆ GetTemporaryPointer()

template<typename T >
const T * flatbuffers::GetTemporaryPointer ( FlatBufferBuilder fbb,
Offset< T >  offset 
)

Definition at line 1459 of file flatbuffer_builder.h.

1459 {
1460 return GetMutableTemporaryPointer<T>(fbb, offset);
1461}

References offset().

◆ GetTypeSize()

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

Definition at line 47 of file reflection.h.

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

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 81 of file reflection.h.

82 {
83 if (base_type == reflection::Obj &&
84 schema.objects()->Get(type_index)->is_struct()) {
85 return schema.objects()->Get(type_index)->bytesize();
86 } else {
87 return GetTypeSize(base_type);
88 }
89}

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 421 of file reflection.h.

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

References FLATBUFFERS_ASSERT, and UnionTypeFieldSuffix().

◆ HashFnv1()

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

Definition at line 42 of file hash.h.

42 {
44 for (const char *c = input; *c; ++c) {
46 hash ^= static_cast<unsigned char>(*c);
47 }
48 return hash;
49}

◆ HashFnv1< uint16_t >()

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

Definition at line 60 of file hash.h.

60 {
61 uint32_t hash = HashFnv1<uint32_t>(input);
62 return (hash >> 16) ^ (hash & 0xffff);
63}

◆ HashFnv1a()

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

Definition at line 51 of file hash.h.

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

◆ HashFnv1a< uint16_t >()

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

Definition at line 65 of file hash.h.

65 {
66 uint32_t hash = HashFnv1a<uint32_t>(input);
67 return (hash >> 16) ^ (hash & 0xffff);
68}

◆ InlineAlignment()

size_t flatbuffers::InlineAlignment ( const Type type)
inline

Definition at line 567 of file idl.h.

567 {
568 if (IsStruct(type)) {
569 return type.struct_def->minalign;
570 } else if (IsArray(type)) {
571 return IsStruct(type.VectorType()) ? type.struct_def->minalign
572 : SizeOf(type.element);
573 } else {
574 return SizeOf(type.base_type);
575 }
576}
int32_t type
bool IsStruct(const Type &type)
Definition idl.h:517
size_t SizeOf(const BaseType t)
Definition idl.h:152

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

◆ InlineSize() [1/2]

size_t flatbuffers::InlineSize ( const Type type)
inline

Definition at line 559 of file idl.h.

559 {
560 return IsStruct(type)
561 ? type.struct_def->bytesize
562 : (IsArray(type)
563 ? InlineSize(type.VectorType()) * type.fixed_length
564 : SizeOf(type.base_type));
565}
bool IsArray(const Type &type)
Definition idl.h:547
size_t InlineSize(const Type &type)
Definition idl.h:559

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

Referenced by InlineSize(), and IterateObject().

◆ InlineSize() [2/2]

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

Definition at line 72 of file minireflect.h.

72 {
73 switch (type) {
74 case ET_UTYPE:
75 case ET_BOOL:
76 case ET_CHAR:
77 case ET_UCHAR: return 1;
78 case ET_SHORT:
79 case ET_USHORT: return 2;
80 case ET_INT:
81 case ET_UINT:
82 case ET_FLOAT:
83 case ET_STRING: return 4;
84 case ET_LONG:
85 case ET_ULONG:
86 case ET_DOUBLE: return 8;
87 case ET_SEQUENCE:
88 switch (type_table->st) {
89 case ST_TABLE:
90 case ST_UNION: return 4;
91 case ST_STRUCT:
92 return static_cast<size_t>(type_table->values[type_table->num_elems]);
93 default: FLATBUFFERS_ASSERT(false); return 1;
94 }
95 default: FLATBUFFERS_ASSERT(false); return 1;
96 }
97}

References FLATBUFFERS_ASSERT, flatbuffers::TypeTable::num_elems, flatbuffers::TypeTable::st, ST_STRUCT, ST_TABLE, ST_UNION, type, and flatbuffers::TypeTable::values.

◆ IntToStringHex()

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

Definition at line 190 of file util.h.

190 {
191 FLATBUFFERS_ASSERT(i >= 0);
192 // clang-format off
193
194 #ifndef FLATBUFFERS_PREFER_PRINTF
195 std::stringstream ss;
196 ss << std::setw(xdigits) << std::setfill('0') << std::hex << std::uppercase
197 << i;
198 return ss.str();
199 #else // FLATBUFFERS_PREFER_PRINTF
200 return NumToStringImplWrapper(i, "%.*X", xdigits);
201 #endif // FLATBUFFERS_PREFER_PRINTF
202 // clang-format on
203}

References FLATBUFFERS_ASSERT.

Referenced by BufferToHexText(), and EscapeString().

◆ is_alnum()

bool flatbuffers::is_alnum ( char  c)
inline

Definition at line 80 of file util.h.

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

References is_alpha(), and is_digit().

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

◆ is_alpha()

bool flatbuffers::is_alpha ( char  c)
inline

Definition at line 52 of file util.h.

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

References check_ascii_range().

Referenced by is_alnum(), is_alpha_char(), and flexbuffers::Reference::ToString().

◆ is_alpha_char()

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

Definition at line 61 of file util.h.

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

References FLATBUFFERS_ASSERT, and is_alpha().

Referenced by StringToIntegerImpl().

◆ is_alpha_upper()

bool flatbuffers::is_alpha_upper ( char  c)
inline

Definition at line 58 of file util.h.

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

References check_ascii_range().

◆ is_digit()

bool flatbuffers::is_digit ( char  c)
inline

Definition at line 72 of file util.h.

72{ 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 74 of file util.h.

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

References check_ascii_range(), and is_digit().

◆ IsArray()

bool flatbuffers::IsArray ( const Type type)
inline

Definition at line 547 of file idl.h.

547 {
548 return type.base_type == BASE_TYPE_ARRAY;
549}

References type.

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 555 of file idl.h.

555 {
556 return type.enum_def != nullptr && IsInteger(type.base_type);
557}
bool IsInteger(BaseType t)
Definition idl.h:134

References IsInteger(), and type.

◆ IsFieldPresent()

template<typename T >
bool flatbuffers::IsFieldPresent ( const T *  table,
typename T::FlatBuffersVTableOffset  field 
)

Definition at line 121 of file flatbuffers.h.

121 {
122 // Cast, since Table is a private baseclass of any table types.
123 return reinterpret_cast<const Table *>(table)->CheckField(
124 static_cast<voffset_t>(field));
125}

◆ 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 39 of file reflection.h.

39 {
40 return t == reflection::Float || t == reflection::Double;
41}

◆ IsIncompleteStruct()

bool flatbuffers::IsIncompleteStruct ( const Type type)
inline

Definition at line 521 of file idl.h.

521 {
522 return type.base_type == BASE_TYPE_STRUCT && type.struct_def->predecl;
523}

References type.

◆ 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(), IsUnionType(), and SetField().

◆ IsInteger() [2/2]

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

Definition at line 36 of file reflection.h.

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

◆ 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 42 of file reflection.h.

42 {
43 return t == reflection::Long || t == reflection::ULong;
44}

◆ 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; }

◆ 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 33 of file reflection.h.

33 {
34 return t >= reflection::UType && t <= reflection::Double;
35}

◆ IsSeries()

bool flatbuffers::IsSeries ( const Type type)
inline

Definition at line 551 of file idl.h.

551 {
552 return IsVector(type) || IsArray(type);
553}
bool IsVector(BaseType t)
Definition idl.h:143

References IsArray(), IsVector(), and type.

◆ IsString()

bool flatbuffers::IsString ( const Type type)
inline

Definition at line 513 of file idl.h.

513 {
514 return type.base_type == BASE_TYPE_STRING;
515}

References type.

◆ IsStruct()

bool flatbuffers::IsStruct ( const Type type)
inline

Definition at line 517 of file idl.h.

517 {
518 return type.base_type == BASE_TYPE_STRUCT && type.struct_def->fixed;
519}

References type.

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

◆ IsTable()

bool flatbuffers::IsTable ( const Type type)
inline

Definition at line 525 of file idl.h.

525 {
526 return type.base_type == BASE_TYPE_STRUCT && !type.struct_def->fixed;
527}

References type.

Referenced by IsVectorOfTable().

◆ IsUnion()

bool flatbuffers::IsUnion ( const Type type)
inline

Definition at line 529 of file idl.h.

529 {
530 return type.enum_def != nullptr && type.enum_def->is_union;
531}

References type.

Referenced by IsUnionType().

◆ IsUnionType()

bool flatbuffers::IsUnionType ( const Type type)
inline

Definition at line 533 of file idl.h.

533 {
534 return IsUnion(type) && IsInteger(type.base_type);
535}
bool IsUnion(const Type &type)
Definition idl.h:529

References IsInteger(), IsUnion(), and type.

◆ IsUnsigned()

bool flatbuffers::IsUnsigned ( BaseType  t)
inline

Definition at line 146 of file idl.h.

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

◆ IsVector() [1/2]

bool flatbuffers::IsVector ( BaseType  t)
inline

Definition at line 143 of file idl.h.

143 { return t == BASE_TYPE_VECTOR ||
144 t == BASE_TYPE_VECTOR64; }

Referenced by IsSeries(), IsVector(), IsVectorOfStruct(), and IsVectorOfTable().

◆ IsVector() [2/2]

bool flatbuffers::IsVector ( const Type type)
inline

Definition at line 537 of file idl.h.

537{ return IsVector(type.base_type); }

References IsVector(), and type.

◆ IsVectorOfStruct()

bool flatbuffers::IsVectorOfStruct ( const Type type)
inline

Definition at line 539 of file idl.h.

539 {
540 return IsVector(type) && IsStruct(type.VectorType());
541}

References IsStruct(), IsVector(), and type.

◆ IsVectorOfTable()

bool flatbuffers::IsVectorOfTable ( const Type type)
inline

Definition at line 543 of file idl.h.

543 {
544 return IsVector(type) && IsTable(type.VectorType());
545}
bool IsTable(const Type &type)
Definition idl.h:525

References IsTable(), IsVector(), and type.

◆ IterateFlatBuffer()

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

Definition at line 287 of file minireflect.h.

289 {
290 IterateObject(GetRoot<uint8_t>(buffer), type_table, callback);
291}
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 232 of file minireflect.h.

233 {
234 visitor->StartSequence();
235 const uint8_t *prev_val = nullptr;
236 size_t set_idx = 0;
237 size_t array_idx = 0;
238 for (size_t i = 0; i < type_table->num_elems; i++) {
239 auto type_code = type_table->type_codes[i];
240 auto type = static_cast<ElementaryType>(type_code.base_type);
241 auto is_repeating = type_code.is_repeating != 0;
242 auto ref_idx = type_code.sequence_ref;
243 const TypeTable *ref = nullptr;
244 if (ref_idx >= 0) { ref = type_table->type_refs[ref_idx](); }
245 auto name = type_table->names ? type_table->names[i] : nullptr;
246 const uint8_t *val = nullptr;
247 if (type_table->st == ST_TABLE) {
248 val = reinterpret_cast<const Table *>(obj)->GetAddressOf(
249 FieldIndexToOffset(static_cast<voffset_t>(i)));
250 } else {
251 val = obj + type_table->values[i];
252 }
253 visitor->Field(i, set_idx, type, is_repeating, ref, name, val);
254 if (val) {
255 set_idx++;
256 if (is_repeating) {
257 auto elem_ptr = val;
258 size_t size = 0;
259 if (type_table->st == ST_TABLE) {
260 // variable length vector
261 val += ReadScalar<uoffset_t>(val);
262 auto vec = reinterpret_cast<const Vector<uint8_t> *>(val);
263 elem_ptr = vec->Data();
264 size = vec->size();
265 } else {
266 // otherwise fixed size array
267 size = type_table->array_sizes[array_idx];
268 ++array_idx;
269 }
270 visitor->StartVector();
271 for (size_t j = 0; j < size; j++) {
272 visitor->Element(j, type, ref, elem_ptr);
273 IterateValue(type, elem_ptr, ref, prev_val, static_cast<soffset_t>(j),
274 visitor);
275 elem_ptr += InlineSize(type, ref);
276 }
277 visitor->EndVector();
278 } else {
279 IterateValue(type, val, ref, prev_val, -1, visitor);
280 }
281 }
282 prev_val = val;
283 }
284 visitor->EndSequence();
285}
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:43
virtual void Element(size_t, ElementaryType, const TypeTable *, const uint8_t *)
Definition minireflect.h:66
unsigned short is_repeating
const int16_t * array_sizes
const TypeFunction * type_refs
const TypeCode * type_codes

References flatbuffers::TypeTable::array_sizes, flatbuffers::Vector< T, SizeT >::Data(), flatbuffers::IterationVisitor::Element(), flatbuffers::IterationVisitor::EndSequence(), flatbuffers::IterationVisitor::EndVector(), flatbuffers::IterationVisitor::Field(), FieldIndexToOffset(), InlineSize(), flatbuffers::TypeCode::is_repeating, IterateValue(), flatbuffers::TypeTable::names, flatbuffers::TypeTable::num_elems, size, flatbuffers::TypeTable::st, ST_TABLE, flatbuffers::IterationVisitor::StartSequence(), flatbuffers::IterationVisitor::StartVector(), type, flatbuffers::TypeTable::type_codes, flatbuffers::TypeTable::type_refs, and flatbuffers::TypeTable::values.

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 121 of file minireflect.h.

123 {
124 switch (type) {
125 case ET_UTYPE: {
126 auto tval = ReadScalar<uint8_t>(val);
127 visitor->UType(tval, EnumName(tval, type_table));
128 break;
129 }
130 case ET_BOOL: {
131 visitor->Bool(ReadScalar<uint8_t>(val) != 0);
132 break;
133 }
134 case ET_CHAR: {
135 auto tval = ReadScalar<int8_t>(val);
136 visitor->Char(tval, EnumName(tval, type_table));
137 break;
138 }
139 case ET_UCHAR: {
140 auto tval = ReadScalar<uint8_t>(val);
141 visitor->UChar(tval, EnumName(tval, type_table));
142 break;
143 }
144 case ET_SHORT: {
145 auto tval = ReadScalar<int16_t>(val);
146 visitor->Short(tval, EnumName(tval, type_table));
147 break;
148 }
149 case ET_USHORT: {
150 auto tval = ReadScalar<uint16_t>(val);
151 visitor->UShort(tval, EnumName(tval, type_table));
152 break;
153 }
154 case ET_INT: {
155 auto tval = ReadScalar<int32_t>(val);
156 visitor->Int(tval, EnumName(tval, type_table));
157 break;
158 }
159 case ET_UINT: {
160 auto tval = ReadScalar<uint32_t>(val);
161 visitor->UInt(tval, EnumName(tval, type_table));
162 break;
163 }
164 case ET_LONG: {
165 visitor->Long(ReadScalar<int64_t>(val));
166 break;
167 }
168 case ET_ULONG: {
169 visitor->ULong(ReadScalar<uint64_t>(val));
170 break;
171 }
172 case ET_FLOAT: {
173 visitor->Float(ReadScalar<float>(val));
174 break;
175 }
176 case ET_DOUBLE: {
177 visitor->Double(ReadScalar<double>(val));
178 break;
179 }
180 case ET_STRING: {
181 val += ReadScalar<uoffset_t>(val);
182 visitor->String(reinterpret_cast<const String *>(val));
183 break;
184 }
185 case ET_SEQUENCE: {
186 switch (type_table->st) {
187 case ST_TABLE:
188 val += ReadScalar<uoffset_t>(val);
189 IterateObject(val, type_table, visitor);
190 break;
191 case ST_STRUCT: IterateObject(val, type_table, visitor); break;
192 case ST_UNION: {
193 val += ReadScalar<uoffset_t>(val);
194 FLATBUFFERS_ASSERT(prev_val);
195 auto union_type = *prev_val; // Always a uint8_t.
196 if (vector_index >= 0) {
197 auto type_vec = reinterpret_cast<const Vector<uint8_t> *>(prev_val);
198 union_type = type_vec->Get(static_cast<uoffset_t>(vector_index));
199 }
200 auto type_code_idx =
201 LookupEnum(union_type, type_table->values, type_table->num_elems);
202 if (type_code_idx >= 0 &&
203 type_code_idx < static_cast<int32_t>(type_table->num_elems)) {
204 auto type_code = type_table->type_codes[type_code_idx];
205 switch (type_code.base_type) {
206 case ET_SEQUENCE: {
207 auto ref = type_table->type_refs[type_code.sequence_ref]();
208 IterateObject(val, ref, visitor);
209 break;
210 }
211 case ET_STRING:
212 visitor->String(reinterpret_cast<const String *>(val));
213 break;
214 default: visitor->Unknown(val);
215 }
216 } else {
217 visitor->Unknown(val);
218 }
219 break;
220 }
221 case ST_ENUM: FLATBUFFERS_ASSERT(false); break;
222 }
223 break;
224 }
225 default: {
226 visitor->Unknown(val);
227 break;
228 }
229 }
230}
const char * EnumName(T tval, const TypeTable *type_table)
virtual void Long(int64_t)
Definition minireflect.h:57
virtual void Int(int32_t, const char *)
Definition minireflect.h:55
virtual void Char(int8_t, const char *)
Definition minireflect.h:51
virtual void UType(uint8_t, const char *)
Definition minireflect.h:49
virtual void UShort(uint16_t, const char *)
Definition minireflect.h:54
virtual void Float(float)
Definition minireflect.h:59
virtual void UInt(uint32_t, const char *)
Definition minireflect.h:56
virtual void Bool(bool)
Definition minireflect.h:50
virtual void Double(double)
Definition minireflect.h:60
virtual void ULong(uint64_t)
Definition minireflect.h:58
virtual void Unknown(const uint8_t *)
Definition minireflect.h:62
virtual void String(const String *)
Definition minireflect.h:61
virtual void Short(int16_t, const char *)
Definition minireflect.h:53
virtual void UChar(uint8_t, const char *)
Definition minireflect.h:52

References flatbuffers::IterationVisitor::Bool(), flatbuffers::IterationVisitor::Char(), flatbuffers::IterationVisitor::Double(), EnumName(), FLATBUFFERS_ASSERT, flatbuffers::IterationVisitor::Float(), flatbuffers::Vector< T, SizeT >::Get(), flatbuffers::IterationVisitor::Int(), IterateObject(), flatbuffers::IterationVisitor::Long(), LookupEnum(), flatbuffers::TypeTable::num_elems, flatbuffers::IterationVisitor::Short(), flatbuffers::TypeTable::st, ST_ENUM, ST_STRUCT, ST_TABLE, ST_UNION, flatbuffers::IterationVisitor::String(), type, flatbuffers::TypeTable::type_codes, flatbuffers::TypeTable::type_refs, flatbuffers::IterationVisitor::UChar(), flatbuffers::IterationVisitor::UInt(), flatbuffers::IterationVisitor::ULong(), flatbuffers::IterationVisitor::Unknown(), flatbuffers::IterationVisitor::UShort(), flatbuffers::IterationVisitor::UType(), and flatbuffers::TypeTable::values.

Referenced by IterateObject().

◆ JavaCSharpMakeRule()

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

◆ 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() [1/2]

int flatbuffers::LookupEnum ( const char **  names,
const char *  name 
)
inline

Definition at line 130 of file flatbuffers.h.

130 {
131 for (const char **p = names; *p; p++)
132 if (!strcmp(*p, name)) return static_cast<int>(p - names);
133 return -1;
134}

References p.

Referenced by EnumName(), and IterateValue().

◆ LookupEnum() [2/2]

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

Definition at line 99 of file minireflect.h.

100 {
101 if (!values) return enum_val;
102 for (size_t i = 0; i < num_values; i++) {
103 if (enum_val == values[i]) return static_cast<int64_t>(i);
104 }
105 return -1; // Unknown enum value.
106}

◆ make_bytes_span() [1/4]

template<class U , uint16_t N>
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span< uint8_t, sizeof(U) *N > flatbuffers::make_bytes_span ( Array< U, N > &  arr)

Definition at line 207 of file array.h.

207 {
209 "internal error, Array<T> might hold only scalars or structs");
210 return span<uint8_t, sizeof(U) * N>(arr.Data(), sizeof(U) * N);
211}

◆ make_bytes_span() [2/4]

template<class U , uint16_t N>
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span< const uint8_t, sizeof(U) *N > flatbuffers::make_bytes_span ( const Array< U, N > &  arr)

Definition at line 215 of file array.h.

215 {
217 "internal error, Array<T> might hold only scalars or structs");
218 return span<const uint8_t, sizeof(U) * N>(arr.Data(), sizeof(U) * N);
219}

◆ make_bytes_span() [3/4]

template<class U >
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span< const uint8_t > flatbuffers::make_bytes_span ( const Vector< U > &  vec)

Definition at line 331 of file vector.h.

332 {
333 static_assert(Vector<U>::scalar_tag::value,
334 "wrong type U, only LE-scalar, or byte types are allowed");
335 return span<const uint8_t>(vec.Data(), vec.size() * sizeof(U));
336}
SizeT size() const
Definition vector.h:164
const uint8_t * Data() const
Definition vector.h:253

◆ make_bytes_span() [4/4]

template<class U >
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span< uint8_t > flatbuffers::make_bytes_span ( Vector< U > &  vec)

Definition at line 323 of file vector.h.

324 {
325 static_assert(Vector<U>::scalar_tag::value,
326 "wrong type U, only LE-scalar, or byte types are allowed");
327 return span<uint8_t>(vec.Data(), vec.size() * sizeof(U));
328}

◆ make_span() [1/6]

template<class U , uint16_t N>
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span< U, N > flatbuffers::make_span ( Array< U, N > &  arr)

Definition at line 188 of file array.h.

189 {
190 static_assert(
192 "wrong type U, only plain struct, LE-scalar, or byte types are allowed");
193 return span<U, N>(arr.data(), N);
194}

Referenced by make_span(), and make_span().

◆ make_span() [2/6]

template<class U , uint16_t N>
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span< const U, N > flatbuffers::make_span ( const Array< U, N > &  arr)

Definition at line 197 of file array.h.

198 {
199 static_assert(
201 "wrong type U, only plain struct, LE-scalar, or byte types are allowed");
202 return span<const U, N>(arr.data(), N);
203}

◆ make_span() [3/6]

template<class U >
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span< const U > flatbuffers::make_span ( const Vector< U > &  vec)

Definition at line 315 of file vector.h.

316 {
317 static_assert(Vector<U>::is_span_observable,
318 "wrong type U, only LE-scalar, or byte types are allowed");
319 return span<const U>(vec.data(), vec.size());
320}
const T * data() const
Definition vector.h:260

◆ make_span() [4/6]

template<class U >
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span< const U > flatbuffers::make_span ( const Vector< U > *  ptr)

Definition at line 349 of file vector.h.

350 {
351 static_assert(Vector<U>::is_span_observable,
352 "wrong type U, only LE-scalar, or byte types are allowed");
353 return ptr ? make_span(*ptr) : span<const U>();
354}
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span< U, N > make_span(Array< U, N > &arr) FLATBUFFERS_NOEXCEPT
Definition array.h:188

References make_span().

◆ make_span() [5/6]

template<class U >
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span< U > flatbuffers::make_span ( Vector< U > &  vec)

Definition at line 307 of file vector.h.

308 {
309 static_assert(Vector<U>::is_span_observable,
310 "wrong type U, only LE-scalar, or byte types are allowed");
311 return span<U>(vec.data(), vec.size());
312}

◆ make_span() [6/6]

template<class U >
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span< U > flatbuffers::make_span ( Vector< U > *  ptr)

Definition at line 341 of file vector.h.

342 {
343 static_assert(Vector<U>::is_span_observable,
344 "wrong type U, only LE-scalar, or byte types are allowed");
345 return ptr ? make_span(*ptr) : span<U>();
346}

References make_span().

◆ NumToString()

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

Definition at line 128 of file util.h.

128 {
129 // clang-format off
130
131 #ifndef FLATBUFFERS_PREFER_PRINTF
132 std::stringstream ss;
133 ss << t;
134 return ss.str();
135 #else // FLATBUFFERS_PREFER_PRINTF
136 auto v = static_cast<long long>(t);
137 return NumToStringImplWrapper(v, "%.*lld");
138 #endif // FLATBUFFERS_PREFER_PRINTF
139 // clang-format on
140}

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 148 of file util.h.

148 {
149 return NumToString(static_cast<int>(t));
150}
std::string NumToString(T t)
Definition util.h:128

References NumToString().

◆ NumToString< double >()

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

Definition at line 180 of file util.h.

180 {
181 return FloatToString(t, 12);
182}
std::string FloatToString(T t, int precision)
Definition util.h:153

References FloatToString().

◆ NumToString< float >()

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

Definition at line 183 of file util.h.

183 {
184 return FloatToString(t, 6);
185}

References FloatToString().

◆ NumToString< signed char >()

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

Definition at line 142 of file util.h.

142 {
143 return NumToString(static_cast<int>(t));
144}

References NumToString().

◆ NumToString< unsigned char >()

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

Definition at line 145 of file util.h.

145 {
146 return NumToString(static_cast<int>(t));
147}

References NumToString().

◆ operator!=()

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

Definition at line 580 of file idl.h.

580 {
581 return !(lhs == rhs);
582}

◆ operator<() [1/2]

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

Definition at line 625 of file idl.h.

625 {
626 return a.filename < b.filename;
627}
std::string filename
Definition idl.h:621

References flatbuffers::IncludedFile::filename.

◆ operator<() [2/2]

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

Definition at line 286 of file idl.h.

286 {
287 size_t min_size = std::min(a.components.size(), b.components.size());
288 for (size_t i = 0; i < min_size; ++i) {
289 if (a.components[i] != b.components[i])
290 return a.components[i] < b.components[i];
291 }
292 return a.components.size() < b.components.size();
293}
std::vector< std::string > components
Definition idl.h:282

References flatbuffers::Namespace::components.

◆ operator==() [1/7]

template<typename T , uint16_t length>
bool flatbuffers::operator== ( const Array< T, length > &  lhs,
const Array< T, length > &  rhs 
)
noexcept

Definition at line 247 of file array.h.

248 {
249 return std::addressof(lhs) == std::addressof(rhs) ||
250 (lhs.size() == rhs.size() &&
251 std::memcmp(lhs.Data(), rhs.Data(), rhs.size() * sizeof(T)) == 0);
252}
FLATBUFFERS_CONSTEXPR uint16_t size() const
Definition array.h:49
const uint8_t * Data() const
Definition array.h:96

◆ operator==() [2/7]

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

Definition at line 577 of file idl.h.

577 {
578 return lhs.value == rhs.value;
579}

◆ operator==() [3/7]

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

Definition at line 272 of file stl_emulation.h.

272 {
273 return static_cast<bool>(lhs) != static_cast<bool>(rhs)
274 ? false
275 : !static_cast<bool>(lhs) ? false : (*lhs == *rhs);
276}

◆ operator==() [4/7]

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

Definition at line 262 of file stl_emulation.h.

262 {
263 return static_cast<bool>(lhs) && (*lhs == rhs);
264}

◆ operator==() [5/7]

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

Definition at line 253 of file stl_emulation.h.

253 {
254 return !opt;
255}

◆ operator==() [6/7]

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

Definition at line 267 of file stl_emulation.h.

267 {
268 return static_cast<bool>(rhs) && (lhs == *rhs);
269}

◆ operator==() [7/7]

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

Definition at line 257 of file stl_emulation.h.

257 {
258 return !opt;
259}

◆ piv()

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

Definition at line 414 of file reflection.h.

◆ PosixPath() [1/2]

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

◆ PosixPath() [2/2]

std::string flatbuffers::PosixPath ( const std::string &  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 53 of file default_allocator.h.

55 {
56 return allocator ? allocator->reallocate_downward(old_p, old_size, new_size,
57 in_use_back, in_use_front)
59 old_p, old_size, new_size, in_use_back, in_use_front);
60}
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)
Definition allocator.h:41

References allocator(), and flatbuffers::Allocator::reallocate_downward().

◆ RelativeToRootPath()

std::string flatbuffers::RelativeToRootPath ( const std::string &  project,
const std::string &  filepath 
)

◆ 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 454 of file reflection.h.

456 {
457 auto delta_elem = static_cast<int>(newsize) - static_cast<int>(vec->size());
458 auto newelems = ResizeAnyVector(
459 schema, newsize, reinterpret_cast<const VectorOfAny *>(vec), vec->size(),
460 static_cast<uoffset_t>(sizeof(T)), flatbuf, root_table);
461 // Set new elements to "val".
462 for (int i = 0; i < delta_elem; i++) {
463 auto loc = newelems + i * sizeof(T);
465 if (is_scalar) {
466 WriteScalar(loc, val);
467 } else { // struct
468 *reinterpret_cast<T *>(loc) = val;
469 }
470 }
471}
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, SizeT >::size().

◆ 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 442 of file util.h.

442 {
443 return SaveFile(name, buf.c_str(), buf.size(), binary);
444}
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 359 of file reflection.h.

360 {
361 SetAnyValueF(field.type()->base_type(), st->GetAddressOf(field.offset()),
362 val);
363}
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 334 of file reflection.h.

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

References flatbuffers::Table::GetAddressOf(), and SetAnyValueF().

◆ SetAnyFieldI() [1/2]

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

Definition at line 352 of file reflection.h.

353 {
354 SetAnyValueI(field.type()->base_type(), st->GetAddressOf(field.offset()),
355 val);
356}
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 325 of file reflection.h.

326 {
327 auto field_ptr = table->GetAddressOf(field.offset());
328 if (!field_ptr) return val == GetFieldDefaultI<int64_t>(field);
329 SetAnyValueI(field.type()->base_type(), field_ptr, val);
330 return true;
331}

References flatbuffers::Table::GetAddressOf(), and SetAnyValueI().

◆ SetAnyFieldS() [1/2]

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

Definition at line 366 of file reflection.h.

367 {
368 SetAnyValueS(field.type()->base_type(), st->GetAddressOf(field.offset()),
369 val);
370}
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 343 of file reflection.h.

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

References flatbuffers::Table::GetAddressOf(), and 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 379 of file reflection.h.

380 {
381 SetAnyValueF(elem_type, vec->Data() + GetTypeSize(elem_type) * i, val);
382}

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 373 of file reflection.h.

374 {
375 SetAnyValueI(elem_type, vec->Data() + GetTypeSize(elem_type) * i, val);
376}

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 385 of file reflection.h.

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

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

◆ SetField()

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

Definition at line 302 of file reflection.h.

302 {
303 reflection::BaseType type = field.type()->base_type();
304 if (!IsScalar(type)) { return false; }
305 FLATBUFFERS_ASSERT(sizeof(T) == GetTypeSize(type));
306 T def;
307 if (IsInteger(type)) {
308 def = GetFieldDefaultI<T>(field);
309 } else {
311 def = GetFieldDefaultF<T>(field);
312 }
313 return table->SetField(field.offset(), val, def);
314}
bool SetField(voffset_t field, T val, T def)
Definition table.h:84
bool IsScalar(BaseType t)
Definition idl.h:132
bool IsFloat(BaseType t)
Definition idl.h:136

References FLATBUFFERS_ASSERT, GetTypeSize(), IsFloat(), IsInteger(), IsScalar(), flatbuffers::Table::SetField(), and type.

◆ SetFieldT()

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

Definition at line 484 of file reflection.h.

485 {
486 FLATBUFFERS_ASSERT(sizeof(uoffset_t) ==
487 GetTypeSize(field.type()->base_type()));
488 return table->SetPointer(field.offset(), val);
489}
bool SetPointer(voffset_t field, const uint8_t *val)
Definition table.h:97

References FLATBUFFERS_ASSERT, GetTypeSize(), and flatbuffers::Table::SetPointer().

◆ 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 
)

◆ SizeOf()

size_t flatbuffers::SizeOf ( const BaseType  t)
inline

Definition at line 152 of file idl.h.

152 {
153 switch (t) {
154 #define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, ...) \
155 case BASE_TYPE_##ENUM: return sizeof(CTYPE);
157 #undef FLATBUFFERS_TD
158 default: FLATBUFFERS_ASSERT(0);
159 }
160 return 0;
161}

References FLATBUFFERS_ASSERT, FLATBUFFERS_GEN_TYPES, and FLATBUFFERS_TD.

Referenced by InlineAlignment(), and InlineSize().

◆ StringIsFlatbufferNan()

bool flatbuffers::StringIsFlatbufferNan ( const std::string &  s)
inline

Definition at line 398 of file util.h.

398 {
399 return s == "nan" || s == "+nan" || s == "-nan";
400}

◆ StringIsFlatbufferNegativeInfinity()

bool flatbuffers::StringIsFlatbufferNegativeInfinity ( const std::string &  s)
inline

Definition at line 406 of file util.h.

406 {
407 return s == "-inf" || s == "-infinity";
408}

◆ StringIsFlatbufferPositiveInfinity()

bool flatbuffers::StringIsFlatbufferPositiveInfinity ( const std::string &  s)
inline

Definition at line 402 of file util.h.

402 {
403 return s == "inf" || s == "+inf" || s == "infinity" || s == "+infinity";
404}

◆ StringOf()

const char * flatbuffers::StringOf ( const BaseType  t)
inline

Definition at line 174 of file idl.h.

174 {
175 switch (t) {
176 #define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, ...) \
177 case BASE_TYPE_##ENUM: return #CTYPE;
179 #undef FLATBUFFERS_TD
180 default: FLATBUFFERS_ASSERT(0);
181 }
182 return "";
183}

References FLATBUFFERS_ASSERT, FLATBUFFERS_GEN_TYPES, and FLATBUFFERS_TD.

◆ StringToFloatImpl()

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

Definition at line 310 of file util.h.

310 {
311 // Type T must be either float or double.
312 FLATBUFFERS_ASSERT(str && val);
313 auto end = str;
314 strtoval_impl(val, str, const_cast<char **>(&end));
315 auto done = (end != str) && (*end == '\0');
316 if (!done) *val = 0; // erase partial result
317 if (done && std::isnan(*val)) { *val = std::numeric_limits<T>::quiet_NaN(); }
318 return done;
319}
void strtoval_impl(int64_t *val, const char *str, char **endptr, int base)
Definition util.h:245

References FLATBUFFERS_ASSERT, and strtoval_impl().

Referenced by StringToNumber(), and StringToNumber().

◆ StringToInt()

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

Definition at line 388 of file util.h.

388 {
389 int64_t val;
390 return StringToIntegerImpl(&val, s, base) ? val : 0;
391}
bool StringToIntegerImpl(T *val, const char *const str, const int base=0, const bool check_errno=true)
Definition util.h:283

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 283 of file util.h.

285 {
286 // T is int64_t or uint64_T
288 if (base <= 0) {
289 auto s = str;
290 while (*s && !is_digit(*s)) s++;
291 if (s[0] == '0' && is_alpha_char(s[1], 'X'))
292 return StringToIntegerImpl(val, str, 16, check_errno);
293 // if a prefix not match, try base=10
294 return StringToIntegerImpl(val, str, 10, check_errno);
295 } else {
296 if (check_errno) errno = 0; // clear thread-local errno
297 auto endptr = str;
298 strtoval_impl(val, str, const_cast<char **>(&endptr), base);
299 if ((*endptr != '\0') || (endptr == str)) {
300 *val = 0; // erase partial result
301 return false; // invalid string
302 }
303 // errno is out-of-range, return MAX/MIN
304 if (check_errno && errno) return false;
305 return true;
306 }
307}
bool is_alpha_char(char c, char alpha)
Definition util.h:61

References FLATBUFFERS_ASSERT, is_alpha_char(), is_digit(), 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 384 of file util.h.

384 {
385 return StringToFloatImpl(val, s);
386}
bool StringToFloatImpl(T *val, const char *const str)
Definition util.h:310

References StringToFloatImpl().

◆ StringToNumber() [2/3]

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

Definition at line 380 of file util.h.

380 {
381 return StringToFloatImpl(val, s);
382}

References StringToFloatImpl().

◆ StringToNumber() [3/3]

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

Definition at line 327 of file util.h.

327 {
328 // Assert on `unsigned long` and `signed long` on LP64.
329 // If it is necessary, it could be solved with flatbuffers::enable_if<B,T>.
330 static_assert(sizeof(T) < sizeof(int64_t), "unexpected type T");
331 FLATBUFFERS_ASSERT(s && val);
332 int64_t i64;
333 // The errno check isn't needed, will return MAX/MIN on overflow.
334 if (StringToIntegerImpl(&i64, s, 0, false)) {
335 const int64_t max = (flatbuffers::numeric_limits<T>::max)();
336 const int64_t min = flatbuffers::numeric_limits<T>::lowest();
337 if (i64 > max) {
338 *val = static_cast<T>(max);
339 return false;
340 }
341 if (i64 < min) {
342 // For unsigned types return max to distinguish from
343 // "no conversion can be performed" when 0 is returned.
344 *val = static_cast<T>(flatbuffers::is_unsigned<T>::value ? max : min);
345 return false;
346 }
347 *val = static_cast<T>(i64);
348 return true;
349 }
350 *val = 0;
351 return false;
352}

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 354 of file util.h.

354 {
355 return StringToIntegerImpl(val, str);
356}

References StringToIntegerImpl().

◆ StringToNumber< uint64_t >()

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

Definition at line 359 of file util.h.

359 {
360 if (!StringToIntegerImpl(val, str)) return false;
361 // The strtoull accepts negative numbers:
362 // If the minus sign was part of the input sequence, the numeric value
363 // calculated from the sequence of digits is negated as if by unary minus
364 // in the result type, which applies unsigned integer wraparound rules.
365 // Fix this behaviour (except -0).
366 if (*val) {
367 auto s = str;
368 while (*s && !is_digit(*s)) s++;
369 s = (s > str) ? (s - 1) : s; // step back to one symbol
370 if (*s == '-') {
371 // For unsigned types return the max to distinguish from
372 // "no conversion can be performed".
374 return false;
375 }
376 }
377 return true;
378}

References is_digit(), and StringToIntegerImpl().

◆ StringToUInt()

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

Definition at line 393 of file util.h.

393 {
394 uint64_t val;
395 return StringToIntegerImpl(&val, s, base) ? val : 0;
396}

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)

◆ StripPrefix()

std::string flatbuffers::StripPrefix ( const std::string &  filepath,
const std::string &  prefix_to_remove 
)

◆ strtoval_impl() [1/4]

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

Definition at line 255 of file util.h.

255 {
256 *val = __strtod_impl(str, endptr);
257}
#define __strtod_impl(s, pe)
Definition util.h:234

References __strtod_impl.

◆ strtoval_impl() [2/4]

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

Definition at line 261 of file util.h.

261 {
262 *val = __strtof_impl(str, endptr);
263}
#define __strtof_impl(s, pe)
Definition util.h:235

References __strtof_impl.

◆ strtoval_impl() [3/4]

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

Definition at line 245 of file util.h.

246 {
247 *val = __strtoll_impl(str, endptr, base);
248}
#define __strtoll_impl(s, pe, b)
Definition util.h:241

References __strtoll_impl.

Referenced by StringToFloatImpl(), and StringToIntegerImpl().

◆ strtoval_impl() [4/4]

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

Definition at line 250 of file util.h.

251 {
252 *val = __strtoull_impl(str, endptr, base);
253}
#define __strtoull_impl(s, pe, b)
Definition util.h:240

References __strtoull_impl.

◆ ToUTF8()

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

Definition at line 494 of file util.h.

494 {
495 FLATBUFFERS_ASSERT(!(ucc & 0x80000000)); // Top bit can't be set.
496 // 6 possible encodings: http://en.wikipedia.org/wiki/UTF-8
497 for (int i = 0; i < 6; i++) {
498 // Max bits this encoding can represent.
499 uint32_t max_bits = 6 + i * 5 + static_cast<int>(!i);
500 if (ucc < (1u << max_bits)) { // does it fit?
501 // Remaining bits not encoded in the first byte, store 6 bits each
502 uint32_t remain_bits = i * 6;
503 // Store first byte:
504 (*out) += static_cast<char>((0xFE << (max_bits - remain_bits)) |
505 (ucc >> remain_bits));
506 // Store remaining bytes:
507 for (int j = i - 1; j >= 0; j--) {
508 (*out) += static_cast<char>(((ucc >> (j * 6)) & 0x3F) | 0x80);
509 }
510 return i + 1; // Return the number of bytes added.
511 }
512 }
513 FLATBUFFERS_ASSERT(0); // Impossible to arrive here.
514 return -1;
515}

References FLATBUFFERS_ASSERT.

◆ TypeName()

const char * flatbuffers::TypeName ( const BaseType  t)
inline

Definition at line 163 of file idl.h.

163 {
164 switch (t) {
165 #define FLATBUFFERS_TD(ENUM, IDLTYPE, ...) \
166 case BASE_TYPE_##ENUM: return IDLTYPE;
168 #undef FLATBUFFERS_TD
169 default: FLATBUFFERS_ASSERT(0);
170 }
171 return nullptr;
172}

References FLATBUFFERS_ASSERT, FLATBUFFERS_GEN_TYPES, and FLATBUFFERS_TD.

◆ UnionTypeFieldSuffix()

const char * flatbuffers::UnionTypeFieldSuffix ( )
inline

Definition at line 418 of file reflection.h.

418{ return "_type"; }

Referenced by GetUnionType().

◆ VectorCast() [1/2]

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

Definition at line 384 of file vector.h.

384 {
385 static_assert(std::is_base_of<T, U>::value, "Unrelated types");
386 return reinterpret_cast<const Vector<Offset<T>> *>(ptr);
387}

◆ VectorCast() [2/2]

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

Definition at line 378 of file vector.h.

378 {
379 static_assert(std::is_base_of<T, U>::value, "Unrelated types");
380 return reinterpret_cast<Vector<Offset<T>> *>(ptr);
381}

◆ Verify()

◆ VerifySizePrefixed()

bool flatbuffers::VerifySizePrefixed ( 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 570 of file util.h.

572 {
573 std::istringstream in_stream(in);
574 std::string wrapped, line, word;
575
576 in_stream >> word;
577 line = word;
578
579 while (in_stream >> word) {
580 if ((line.length() + 1 + word.length() + wrapped_line_suffix.length()) <
581 max_length) {
582 line += " " + word;
583 } else {
584 wrapped += line + wrapped_line_suffix + "\n";
585 line = wrapped_line_prefix + word;
586 }
587 }
588 wrapped += line;
589
590 return wrapped;
591}

Variable Documentation

◆ dynamic_extent

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

◆ kHashFunctions16

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

Definition at line 77 of file hash.h.

77 {
78 { "fnv1_16", HashFnv1<uint16_t> },
79 { "fnv1a_16", HashFnv1a<uint16_t> },
80};

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 82 of file hash.h.

82 {
83 { "fnv1_32", HashFnv1<uint32_t> },
84 { "fnv1a_32", HashFnv1a<uint32_t> },
85};

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 87 of file hash.h.

87 {
88 { "fnv1_64", HashFnv1<uint64_t> },
89 { "fnv1a_64", HashFnv1a<uint64_t> },
90};

Referenced by FindHashFunction64().

◆ kPathSeparator

FLATBUFFERS_CONSTEXPR char flatbuffers::kPathSeparator = '/'

Definition at line 452 of file util.h.