18#ifndef FLATBUFFERS_FLEXBUFFERS_H_
19#define FLATBUFFERS_FLEXBUFFERS_H_
33#pragma warning(disable : 4127)
132 *len =
static_cast<uint8_t
>(fixed_type / 3 + 2);
133 return static_cast<Type>(fixed_type % 3 +
FBT_INT);
146template <
typename R,
typename T1,
typename T2,
typename T4,
typename T8>
149 return byte_width < 4 ? (byte_width < 2 ? static_cast<R>(flatbuffers::ReadScalar<T1>(data))
150 :
static_cast<R
>(flatbuffers::ReadScalar<T2>(data)))
151 : (byte_width < 8 ? static_cast<R>(flatbuffers::ReadScalar<T4>(data))
152 :
static_cast<R
>(flatbuffers::ReadScalar<T8>(data)));
155inline int64_t
ReadInt64(
const uint8_t *data, uint8_t byte_width)
157 return ReadSizedScalar<int64_t, int8_t, int16_t, int32_t, int64_t>(data, byte_width);
160inline uint64_t
ReadUInt64(
const uint8_t *data, uint8_t byte_width)
162#if defined(_MSC_VER) && ((defined(_M_X64) && !defined(_M_ARM64EC)) || defined _M_IX86)
164 __movsb(
reinterpret_cast<uint8_t *
>(&u),
reinterpret_cast<const uint8_t *
>(data), byte_width);
165 return flatbuffers::EndianScalar(u);
167 return ReadSizedScalar<uint64_t, uint8_t, uint16_t, uint32_t, uint64_t>(data, byte_width);
172inline double ReadDouble(
const uint8_t *data, uint8_t byte_width)
174 return ReadSizedScalar<double, quarter, half, float, double>(data, byte_width);
189#define FLATBUFFERS_GET_FIELD_BIT_WIDTH(value, width) \
191 if (!((u) & ~((1ULL << (width)) - 1ULL))) \
192 return BIT_WIDTH_##width; \
197#undef FLATBUFFERS_GET_FIELD_BIT_WIDTH
203 auto u =
static_cast<uint64_t
>(i) << 1;
204 return WidthU(i >= 0 ? u : ~u);
231 Sized(
const uint8_t *data, uint8_t byte_width,
size_t sz) :
Object(data, byte_width),
size_(sz) {}
247 String(
const uint8_t *data, uint8_t byte_width) :
Sized(data, byte_width) {}
249 String(
const uint8_t *data, uint8_t byte_width,
size_t sz) :
Sized(data, byte_width, sz) {}
252 const char *
c_str()
const {
return reinterpret_cast<const char *
>(
data_); }
257 static const char *empty_string =
"";
258 return String(
reinterpret_cast<const uint8_t *
>(empty_string), 1, 0);
266 Blob(
const uint8_t *data_buf, uint8_t byte_width) :
Sized(data_buf, byte_width) {}
270 static const uint8_t empty_blob[] = {0 };
271 return Blob(empty_blob + 1, 1);
280 Vector(
const uint8_t *data, uint8_t byte_width) :
Sized(data, byte_width) {}
286 static const uint8_t empty_vector[] = {0 };
287 return Vector(empty_vector + 1, 1);
296 :
Sized(data, byte_width), type_(element_type)
304 static const uint8_t empty_typed_vector[] = {0 };
323 :
Object(data, byte_width), type_(element_type), len_(len)
331 static const uint8_t fixed_empty_vector[] = {0 };
340 uint8_t
size() {
return len_; }
350 Map(
const uint8_t *data, uint8_t byte_width) :
Vector(data, byte_width) {}
359 const size_t num_prefixed_fields = 3;
368 static const uint8_t empty_map[] = {
371 return Map(empty_map + 4, 1);
377template <
typename T>
void AppendToString(std::string &s, T &&v,
bool keys_quoted)
380 for (
size_t i = 0; i < v.size(); i++)
384 v[i].ToString(
true, keys_quoted, s);
394 Reference(
const uint8_t *data, uint8_t parent_width, uint8_t byte_width,
Type type)
395 : data_(data), parent_width_(parent_width), byte_width_(byte_width), type_(type)
399 Reference(
const uint8_t *data, uint8_t parent_width, uint8_t packed_type)
400 : data_(data), parent_width_(parent_width)
402 byte_width_ = 1U <<
static_cast<BitWidth>(packed_type & 3);
403 type_ =
static_cast<Type>(packed_type >> 2);
443 return ReadInt64(Indirect(), byte_width_);
449 return static_cast<int64_t
>(
ReadDouble(data_, parent_width_));
451 return static_cast<int64_t
>(
ReadDouble(Indirect(), byte_width_));
487 return ReadInt64(Indirect(), byte_width_);
489 return static_cast<uint64_t
>(
ReadDouble(data_, parent_width_));
491 return static_cast<uint64_t
>(
ReadDouble(Indirect(), byte_width_));
523 return static_cast<double>(
ReadInt64(data_, parent_width_));
525 return static_cast<double>(
ReadUInt64(data_, parent_width_));
527 return static_cast<double>(
ReadInt64(Indirect(), byte_width_));
529 return static_cast<double>(
ReadUInt64(Indirect(), byte_width_));
541 return static_cast<double>(
ReadUInt64(data_, parent_width_));
554 return reinterpret_cast<const char *
>(Indirect());
568 return String(Indirect(), byte_width_);
572 auto key = Indirect();
573 return String(key, byte_width_, strlen(
reinterpret_cast<const char *
>(key)));
593 void ToString(
bool strings_quoted,
bool keys_quoted, std::string &s)
const
597 String str(Indirect(), byte_width_);
604 s.append(str.c_str(), str.length());
637 s +=
AsBool() ?
"true" :
"false";
643 auto keys =
m.Keys();
644 auto vals =
m.Values();
645 for (
size_t i = 0; i < keys.size(); i++)
647 keys[i].ToString(
true, keys_quoted, s);
649 vals[i].ToString(
true, keys_quoted, s);
650 if (i < keys.size() - 1)
657 AppendToString<Vector>(s,
AsVector(), keys_quoted);
661 AppendToString<TypedVector>(s,
AsTypedVector(), keys_quoted);
685 return Blob(Indirect(), byte_width_);
699 return Vector(Indirect(), byte_width_);
703 return Vector::EmptyVector();
748 return Map(Indirect(), byte_width_);
756 template <
typename T> T
As()
const;
768 return Mutate(data_, i, parent_width_,
WidthI(i));
772 return Mutate(Indirect(), i, byte_width_,
WidthI(i));
776 auto u =
static_cast<uint64_t
>(i);
777 return Mutate(data_, u, parent_width_,
WidthU(u));
781 auto u =
static_cast<uint64_t
>(i);
782 return Mutate(Indirect(), u, byte_width_,
WidthU(u));
799 return Mutate(data_, u, parent_width_,
WidthU(u));
803 return Mutate(Indirect(), u, byte_width_,
WidthU(u));
807 auto i =
static_cast<int64_t
>(u);
808 return Mutate(data_, i, parent_width_,
WidthI(i));
812 auto i =
static_cast<int64_t
>(u);
813 return Mutate(Indirect(), i, byte_width_,
WidthI(i));
829 return MutateF(Indirect(), f, byte_width_,
BIT_WIDTH_32);
841 return MutateF(data_, d, parent_width_,
WidthF(d));
845 return MutateF(Indirect(), d, byte_width_,
WidthF(d));
856 if (s.IsTheEmptyString())
860 if (s.length() != len)
862 memcpy(
const_cast<char *
>(s.c_str()), str, len);
871 template <
typename T>
872 bool Mutate(
const uint8_t *dest, T t,
size_t byte_width,
BitWidth value_width)
874 auto fits =
static_cast<size_t>(
static_cast<size_t>(1U) << value_width) <= byte_width;
877 t = flatbuffers::EndianScalar(t);
878 memcpy(
const_cast<uint8_t *
>(dest), &t, byte_width);
883 template <
typename T>
884 bool MutateF(
const uint8_t *dest, T t,
size_t byte_width,
BitWidth value_width)
886 if (byte_width ==
sizeof(
double))
887 return Mutate(dest,
static_cast<double>(t), byte_width, value_width);
888 if (byte_width ==
sizeof(
float))
889 return Mutate(dest,
static_cast<float>(t), byte_width, value_width);
894 const uint8_t *data_;
895 uint8_t parent_width_;
901template <>
inline bool Reference::As<bool>()
const {
return AsBool(); }
903template <>
inline int8_t Reference::As<int8_t>()
const {
return AsInt8(); }
904template <>
inline int16_t Reference::As<int16_t>()
const {
return AsInt16(); }
905template <>
inline int32_t Reference::As<int32_t>()
const {
return AsInt32(); }
906template <>
inline int64_t Reference::As<int64_t>()
const {
return AsInt64(); }
908template <>
inline uint8_t Reference::As<uint8_t>()
const {
return AsUInt8(); }
909template <>
inline uint16_t Reference::As<uint16_t>()
const {
return AsUInt16(); }
910template <>
inline uint32_t Reference::As<uint32_t>()
const {
return AsUInt32(); }
911template <>
inline uint64_t Reference::As<uint64_t>()
const {
return AsUInt64(); }
913template <>
inline double Reference::As<double>()
const {
return AsDouble(); }
914template <>
inline float Reference::As<float>()
const {
return AsFloat(); }
917template <>
inline std::string Reference::As<std::string>()
const {
return AsString().str(); }
919template <>
inline Blob Reference::As<Blob>()
const {
return AsBlob(); }
926template <>
inline Map Reference::As<Map>()
const {
return AsMap(); }
930 return static_cast<uint8_t
>(bit_width | (type << 2));
969template <
typename T>
int KeyCompare(
const void *key,
const void *elem)
972 reinterpret_cast<const char *
>(Indirect<T>(
reinterpret_cast<const uint8_t *
>(elem)));
973 auto skey =
reinterpret_cast<const char *
>(key);
974 return strcmp(skey, str_elem);
982 int (*comp)(
const void *,
const void *) =
nullptr;
983 switch (keys.byte_width_)
986 comp = KeyCompare<uint8_t>;
989 comp = KeyCompare<uint16_t>;
992 comp = KeyCompare<uint32_t>;
995 comp = KeyCompare<uint64_t>;
998 auto res = std::bsearch(key, keys.data_, keys.size(), keys.byte_width_, comp);
1001 auto i = (
reinterpret_cast<uint8_t *
>(res) - keys.data_) / keys.byte_width_;
1002 return (*
static_cast<const Vector *
>(
this))[i];
1011 auto end = buffer +
size;
1012 auto byte_width = *--end;
1013 auto packed_type = *--end;
1015 return Reference(end, byte_width, packed_type);
1047 : buf_(initial_size), finished_(false), has_duplicate_keys_(false), flags_(flags),
1048 force_min_bit_width_(
BIT_WIDTH_8), key_pool(KeyOffsetCompare(buf_)),
1049 string_pool(StringOffsetCompare(buf_))
1054#ifdef FLATBUFFERS_DEFAULT_DECLARATION
1055 Builder(Builder &&) =
default;
1056 Builder &operator=(Builder &&) =
default;
1079 string_pool.clear();
1094 void Int(
const char *key, int64_t i)
1101 void UInt(
const char *key, uint64_t u)
1156 size_t Key(
const char *str,
size_t len)
1158 auto sloc = buf_.size();
1159 WriteBytes(str, len + 1);
1162 auto it = key_pool.find(sloc);
1163 if (it != key_pool.end())
1172 key_pool.insert(sloc);
1179 size_t Key(
const char *str) {
return Key(str, strlen(str)); }
1180 size_t Key(
const std::string &str) {
return Key(str.c_str(), str.size()); }
1184 auto reset_to = buf_.size();
1185 auto sloc = CreateBlob(str, len, 1,
FBT_STRING);
1188 StringOffset so(sloc, len);
1189 auto it = string_pool.find(so);
1190 if (it != string_pool.end())
1194 buf_.resize(reset_to);
1196 stack_.back().u_ = sloc;
1200 string_pool.insert(so);
1206 size_t String(
const std::string &str) {
return String(str.c_str(), str.size()); }
1209 void String(
const char *key,
const char *str)
1214 void String(
const char *key,
const std::string &str)
1225 size_t Blob(
const void *data,
size_t len) {
return CreateBlob(data, len, 0,
FBT_BLOB); }
1226 size_t Blob(
const std::vector<uint8_t> &v)
1239 return stack_.size();
1245 return stack_.size();
1252 auto vec = CreateVector(start, stack_.size() - start, 1, typed, fixed);
1254 stack_.resize(start);
1255 stack_.push_back(vec);
1256 return static_cast<size_t>(vec.u_);
1263 auto len = stack_.size() - start;
1267 for (
auto key = start; key < stack_.size(); key += 2)
1288 std::sort(dict, dict + len, [&](
const TwoValue &a,
const TwoValue &b) ->
bool {
1291 auto comp = strcmp(as, bs);
1301 if (!comp && &a != &b)
1302 has_duplicate_keys_ =
true;
1308 auto keys = CreateVector(start, len, 2,
true,
false);
1309 auto vec = CreateVector(start + 1, len, 2,
false,
false, &keys);
1311 stack_.resize(start);
1312 stack_.push_back(vec);
1313 return static_cast<size_t>(vec.u_);
1322 auto start = StartVector();
1324 return EndVector(start,
false,
false);
1326 template <
typename F,
typename T>
size_t Vector(F f, T &state)
1328 auto start = StartVector();
1330 return EndVector(start,
false,
false);
1332 template <
typename F>
size_t Vector(
const char *key, F f)
1334 auto start = StartVector(key);
1336 return EndVector(start,
false,
false);
1338 template <
typename F,
typename T>
size_t Vector(
const char *key, F f, T &state)
1340 auto start = StartVector(key);
1342 return EndVector(start,
false,
false);
1345 template <
typename T>
void Vector(
const T *elems,
size_t len)
1350 ScalarVector(elems, len,
false);
1354 auto start = StartVector();
1355 for (
size_t i = 0; i < len; i++)
1357 EndVector(start,
false,
false);
1360 template <
typename T>
void Vector(
const char *key,
const T *elems,
size_t len)
1365 template <
typename T>
void Vector(
const std::vector<T> &vec)
1372 auto start = StartVector();
1374 return EndVector(start,
true,
false);
1378 auto start = StartVector();
1380 return EndVector(start,
true,
false);
1384 auto start = StartVector(key);
1386 return EndVector(start,
true,
false);
1388 template <
typename F,
typename T>
size_t TypedVector(
const char *key, F f, T &state)
1390 auto start = StartVector(key);
1392 return EndVector(start,
true,
false);
1402 return ScalarVector(elems, len,
true);
1411 template <
typename F>
size_t Map(F f)
1413 auto start = StartMap();
1415 return EndMap(start);
1417 template <
typename F,
typename T>
size_t Map(F f, T &state)
1419 auto start = StartMap();
1421 return EndMap(start);
1423 template <
typename F>
size_t Map(
const char *key, F f)
1425 auto start = StartMap(key);
1427 return EndMap(start);
1429 template <
typename F,
typename T>
size_t Map(
const char *key, F f, T &state)
1431 auto start = StartMap(key);
1433 return EndMap(start);
1435 template <
typename T>
void Map(
const std::map<std::string, T> &map)
1437 auto start = StartMap();
1438 for (
auto it = map.begin(); it != map.end(); ++it)
1439 Add(it->first.c_str(), it->second);
1463 void Add(int8_t i) { Int(i); }
1464 void Add(int16_t i) { Int(i); }
1465 void Add(int32_t i) { Int(i); }
1466 void Add(int64_t i) { Int(i); }
1467 void Add(uint8_t u) { UInt(u); }
1468 void Add(uint16_t u) { UInt(u); }
1469 void Add(uint32_t u) { UInt(u); }
1470 void Add(uint64_t u) { UInt(u); }
1471 void Add(
float f) { Float(f); }
1472 void Add(
double d) { Double(d); }
1478 template <
typename T>
void Add(
const std::vector<T> &vec) {
Vector(vec); }
1480 template <
typename T>
void Add(
const char *key,
const T &t)
1486 template <
typename T>
void Add(
const std::map<std::string, T> &map) {
Map(map); }
1505 auto byte_width = Align(stack_[0].ElemWidth(buf_.size(), 0));
1506 WriteAny(stack_[0], byte_width);
1508 Write(stack_[0].StoredPackedType(), 1);
1510 Write(byte_width, 1);
1516 void Finished()
const
1525 uint8_t Align(BitWidth alignment)
1527 auto byte_width = 1U << alignment;
1528 buf_.insert(buf_.end(), flatbuffers::PaddingBytes(buf_.size(), byte_width), 0);
1529 return static_cast<uint8_t
>(byte_width);
1532 void WriteBytes(
const void *val,
size_t size)
1534 buf_.insert(buf_.end(),
reinterpret_cast<const uint8_t *
>(val),
1535 reinterpret_cast<const uint8_t *
>(val) +
size);
1538 template <
typename T>
void Write(T val,
size_t byte_width)
1541 val = flatbuffers::EndianScalar(val);
1542 WriteBytes(&val, byte_width);
1545 void WriteDouble(
double f, uint8_t byte_width)
1550 Write(f, byte_width);
1553 Write(
static_cast<float>(f), byte_width);
1562 void WriteOffset(uint64_t o, uint8_t byte_width)
1564 auto reloff = buf_.size() - o;
1566 Write(reloff, byte_width);
1569 template <
typename T>
void PushIndirect(T val, Type type, BitWidth bit_width)
1571 auto byte_width = Align(bit_width);
1572 auto iloc = buf_.size();
1573 Write(val, byte_width);
1574 stack_.push_back(Value(
static_cast<uint64_t
>(iloc), type, bit_width));
1577 static BitWidth WidthB(
size_t byte_width)
1595 template <
typename T>
static Type GetScalarType()
1632 return PackedType(StoredWidth(parent_bit_width_), type_);
1639 return min_bit_width_;
1648 for (
size_t byte_width = 1; byte_width <=
sizeof(flatbuffers::largest_scalar_t);
1653 buf_size + flatbuffers::PaddingBytes(buf_size, byte_width) + elem_index * byte_width;
1655 auto offset = offset_loc - u_;
1658 if (
static_cast<size_t>(
static_cast<size_t>(1U) << bit_width) == byte_width)
1670 return (std::max)(min_bit_width_, parent_bit_width_);
1674 return min_bit_width_;
1680 void WriteAny(
const Value &val, uint8_t byte_width)
1686 Write(val.i_, byte_width);
1690 Write(val.u_, byte_width);
1693 WriteDouble(val.f_, byte_width);
1696 WriteOffset(val.u_, byte_width);
1701 size_t CreateBlob(
const void *data,
size_t len,
size_t trailing, Type type)
1703 auto bit_width =
WidthU(len);
1704 auto byte_width = Align(bit_width);
1705 Write<uint64_t>(len, byte_width);
1706 auto sloc = buf_.size();
1707 WriteBytes(data, len + trailing);
1708 stack_.push_back(Value(
static_cast<uint64_t
>(sloc), type, bit_width));
1712 template <
typename T>
size_t ScalarVector(
const T *elems,
size_t len,
bool fixed)
1714 auto vector_type = GetScalarType<T>();
1715 auto byte_width =
sizeof(T);
1716 auto bit_width = WidthB(byte_width);
1725 Write<uint64_t>(len, byte_width);
1726 auto vloc = buf_.size();
1727 for (
size_t i = 0; i < len; i++)
1728 Write(elems[i], byte_width);
1730 Value(
static_cast<uint64_t
>(vloc),
ToTypedVector(vector_type, fixed ? len : 0), bit_width));
1734 Value CreateVector(
size_t start,
size_t vec_len,
size_t step,
bool typed,
bool fixed,
1735 const Value *keys =
nullptr)
1739 auto bit_width = (std::max)(force_min_bit_width_,
WidthU(vec_len));
1740 auto prefix_elems = 1;
1745 bit_width = (std::max)(bit_width, keys->ElemWidth(buf_.size(), 0));
1750 for (
size_t i = start; i < stack_.size(); i += step)
1752 auto elem_width = stack_[i].ElemWidth(buf_.size(), i - start + prefix_elems);
1753 bit_width = (std::max)(bit_width, elem_width);
1758 vector_type = stack_[i].type_;
1771 auto byte_width = Align(bit_width);
1775 WriteOffset(keys->u_, byte_width);
1776 Write<uint64_t>(1ULL << keys->min_bit_width_, byte_width);
1779 Write<uint64_t>(vec_len, byte_width);
1781 auto vloc = buf_.size();
1782 for (
size_t i = start; i < stack_.size(); i += step)
1784 WriteAny(stack_[i], byte_width);
1789 for (
size_t i = start; i < stack_.size(); i += step)
1791 buf_.push_back(stack_[i].StoredPackedType(bit_width));
1794 return Value(
static_cast<uint64_t
>(vloc),
1801 Builder(
const Builder &);
1802 Builder &operator=(
const Builder &);
1804 std::vector<uint8_t> buf_;
1805 std::vector<Value> stack_;
1808 bool has_duplicate_keys_;
1814 struct KeyOffsetCompare
1816 explicit KeyOffsetCompare(
const std::vector<uint8_t> &buf) : buf_(&
buf) {}
1817 bool operator()(
size_t a,
size_t b)
const
1821 return strcmp(stra, strb) < 0;
1823 const std::vector<uint8_t> *buf_;
1826 typedef std::pair<size_t, size_t> StringOffset;
1827 struct StringOffsetCompare
1829 explicit StringOffsetCompare(
const std::vector<uint8_t> &buf) : buf_(&
buf) {}
1830 bool operator()(
const StringOffset &a,
const StringOffset &b)
const
1834 return strncmp(stra, strb, (std::min)(a.second,
b.second) + 1) < 0;
1836 const std::vector<uint8_t> *buf_;
1839 typedef std::set<size_t, KeyOffsetCompare> KeyOffsetMap;
1840 typedef std::set<StringOffset, StringOffsetCompare> StringOffsetMap;
1842 KeyOffsetMap key_pool;
1843 StringOffsetMap string_pool;
1848#if defined(_MSC_VER)
void Add(const float *input1_data, const Dims< 4 > &input1_dims, const float *input2_data, const Dims< 4 > &input2_dims, float *output_data, const Dims< 4 > &output_dims)
#define FLATBUFFERS_ASSERT
Blob(const uint8_t *data_buf, uint8_t byte_width)
const uint8_t * data() const
bool IsTheEmptyBlob() const
size_t StartMap(const char *key)
void IndirectFloat(const char *key, float f)
void ReuseValue(const char *key, Value v)
size_t TypedVector(const char *key, F f)
size_t Map(const char *key, F f)
size_t Vector(const char *key, F f)
void Vector(const std::vector< T > &vec)
void Float(const char *key, float f)
void String(const flexbuffers::String &str)
void Null(const char *key)
size_t Key(const std::string &str)
bool HasDuplicateKeys() const
size_t Key(const char *str)
void IndirectInt(const char *key, int64_t i)
size_t EndMap(size_t start)
size_t TypedVector(F f, T &state)
size_t Map(const char *key, F f, T &state)
void ForceMinimumBitWidth(BitWidth bw=BIT_WIDTH_8)
void String(const char *key, const flexbuffers::String &str)
void Int(const char *key, int64_t i)
void Bool(const char *key, bool b)
void IndirectUInt(uint64_t u)
void Add(const flexbuffers::String &str)
size_t StartVector(const char *key)
void Add(const std::vector< T > &vec)
void IndirectInt(int64_t i)
void Vector(const T *elems, size_t len)
void Add(const char *str)
void Map(const std::map< std::string, T > &map)
size_t String(const char *str, size_t len)
size_t Key(const char *str, size_t len)
void IndirectDouble(double f)
size_t TypedVector(const char *key, F f, T &state)
void UInt(const char *key, uint64_t u)
void IndirectUInt(const char *key, uint64_t u)
void Double(const char *key, double d)
size_t Map(F f, T &state)
size_t Vector(F f, T &state)
void String(const char *key, const std::string &str)
void Add(const std::string &str)
size_t EndVector(size_t start, bool typed, bool fixed)
size_t String(const char *str)
size_t String(const std::string &str)
void Add(const char *key, const T &t)
void IndirectDouble(const char *key, double d)
void Vector(const char *key, const T *elems, size_t len)
size_t Blob(const std::vector< uint8_t > &v)
Builder(size_t initial_size=256, BuilderFlag flags=BUILDER_FLAG_SHARE_KEYS)
size_t Blob(const void *data, size_t len)
void IndirectFloat(float f)
size_t Vector(const char *key, F f, T &state)
void Add(const std::map< std::string, T > &map)
size_t FixedTypedVector(const T *elems, size_t len)
void operator+=(const T &t)
const std::vector< uint8_t > & GetBuffer() const
Get the serialized buffer (after you call Finish()).
size_t FixedTypedVector(const char *key, const T *elems, size_t len)
void String(const char *key, const char *str)
Reference operator[](size_t i) const
static FixedTypedVector EmptyFixedTypedVector()
FixedTypedVector(const uint8_t *data, uint8_t byte_width, Type element_type, uint8_t len)
bool IsTheEmptyFixedTypedVector() const
Map(const uint8_t *data, uint8_t byte_width)
bool IsTheEmptyMap() const
Reference operator[](const char *key) const
Object(const uint8_t *data, uint8_t byte_width)
bool MutateString(const char *str, size_t len)
bool MutateString(const std::string &str)
std::string ToString() const
bool MutateFloat(float f)
bool MutateFloat(double d)
Reference(const uint8_t *data, uint8_t parent_width, uint8_t byte_width, Type type)
TypedVector AsTypedVector() const
void ToString(bool strings_quoted, bool keys_quoted, std::string &s) const
uint32_t AsUInt32() const
bool MutateUInt(uint64_t u)
const char * AsKey() const
bool IsFixedTypedVector() const
uint16_t AsUInt16() const
FixedTypedVector AsFixedTypedVector() const
uint64_t AsUInt64() const
bool MutateInt(int64_t i)
bool IsTypedVector() const
bool MutateString(const char *str)
Reference(const uint8_t *data, uint8_t parent_width, uint8_t packed_type)
bool IsUntypedVector() const
Sized(const uint8_t *data, uint8_t byte_width)
Sized(const uint8_t *data, uint8_t byte_width, size_t sz)
String(const uint8_t *data, uint8_t byte_width, size_t sz)
bool IsTheEmptyString() const
String(const uint8_t *data, uint8_t byte_width)
static String EmptyString()
const char * c_str() const
Reference operator[](size_t i) const
static TypedVector EmptyTypedVector()
bool IsTheEmptyVector() const
TypedVector(const uint8_t *data, uint8_t byte_width, Type element_type)
static Vector EmptyVector()
Vector(const uint8_t *data, uint8_t byte_width)
Reference operator[](size_t i) const
bool IsTheEmptyVector() const
#define FLATBUFFERS_GET_FIELD_BIT_WIDTH(value, width)
__global uchar * offset(const Image *img, int x, int y)
std::string NumToString(T t)
int64_t StringToInt(const char *s, int base=10)
bool EscapeString(const char *s, size_t length, std::string *_text, bool allow_non_utf8, bool natural_utf8)
bool StringToNumber(const char *s, T *val)
T * vector_data(std::vector< T > &vector)
uint64_t StringToUInt(const char *s, int base=10)
BitWidth WidthI(int64_t i)
@ BUILDER_FLAG_SHARE_KEY_VECTORS
@ BUILDER_FLAG_SHARE_KEYS_AND_STRINGS
@ BUILDER_FLAG_SHARE_KEYS
@ BUILDER_FLAG_SHARE_STRINGS
Reference GetRoot(const uint8_t *buffer, size_t size)
double ReadDouble(const uint8_t *data, uint8_t byte_width)
int KeyCompare(const void *key, const void *elem)
BitWidth WidthF(double f)
Type ToTypedVector(Type t, size_t fixed_len=0)
bool IsTypedVectorElementType(Type t)
Type ToFixedTypedVectorElementType(Type t, uint8_t *len)
Type ToTypedVectorElementType(Type t)
uint64_t ReadUInt64(const uint8_t *data, uint8_t byte_width)
bool IsTypedVector(Type t)
@ FBT_VECTOR_STRING_DEPRECATED
int64_t ReadInt64(const uint8_t *data, uint8_t byte_width)
bool IsFixedTypedVector(Type t)
R ReadSizedScalar(const uint8_t *data, uint8_t byte_width)
void AppendToString(std::string &s, T &&v, bool keys_quoted)
uint8_t PackedType(BitWidth bit_width, Type type)
const uint8_t * Indirect(const uint8_t *offset, uint8_t byte_width)
BitWidth WidthU(uint64_t u)
BitWidth ElemWidth(size_t buf_size, size_t elem_index) const
BitWidth StoredWidth(BitWidth parent_bit_width_=BIT_WIDTH_8) const
Value(uint64_t u, Type t, BitWidth bw)
uint8_t StoredPackedType(BitWidth parent_bit_width_=BIT_WIDTH_8) const
Value(int64_t i, Type t, BitWidth bw)