diff options
author | thegeorg <thegeorg@yandex-team.com> | 2024-03-16 14:05:11 +0300 |
---|---|---|
committer | thegeorg <thegeorg@yandex-team.com> | 2024-03-16 14:20:39 +0300 |
commit | 4e3ee6b12c3dacb5d556e9afad35dcd6efe58fa1 (patch) | |
tree | 7415c5c5bea98154299213abb536d01bcee6c8af /contrib/libs/flatbuffers/include | |
parent | d83e7ea91cbc5e5d4ea49195eeab84c364dba4bb (diff) | |
download | ydb-4e3ee6b12c3dacb5d556e9afad35dcd6efe58fa1.tar.gz |
Update contrib/libs/flatbuffers to 24.3.7
ba53b58280bb890a80379f491d436458add8f0ed
Diffstat (limited to 'contrib/libs/flatbuffers/include')
9 files changed, 159 insertions, 67 deletions
diff --git a/contrib/libs/flatbuffers/include/flatbuffers/base.h b/contrib/libs/flatbuffers/include/flatbuffers/base.h index 506fd545d1..43cfae7fe5 100644 --- a/contrib/libs/flatbuffers/include/flatbuffers/base.h +++ b/contrib/libs/flatbuffers/include/flatbuffers/base.h @@ -139,9 +139,9 @@ #endif #endif // !defined(FLATBUFFERS_LITTLEENDIAN) -#define FLATBUFFERS_VERSION_MAJOR 23 -#define FLATBUFFERS_VERSION_MINOR 5 -#define FLATBUFFERS_VERSION_REVISION 26 +#define FLATBUFFERS_VERSION_MAJOR 24 +#define FLATBUFFERS_VERSION_MINOR 3 +#define FLATBUFFERS_VERSION_REVISION 7 #define FLATBUFFERS_STRING_EXPAND(X) #X #define FLATBUFFERS_STRING(X) FLATBUFFERS_STRING_EXPAND(X) namespace flatbuffers { @@ -155,7 +155,7 @@ namespace flatbuffers { #define FLATBUFFERS_FINAL_CLASS final #define FLATBUFFERS_OVERRIDE override #define FLATBUFFERS_EXPLICIT_CPP11 explicit - #define FLATBUFFERS_VTABLE_UNDERLYING_TYPE : flatbuffers::voffset_t + #define FLATBUFFERS_VTABLE_UNDERLYING_TYPE : ::flatbuffers::voffset_t #else #define FLATBUFFERS_FINAL_CLASS #define FLATBUFFERS_OVERRIDE @@ -289,12 +289,12 @@ namespace flatbuffers { #define FLATBUFFERS_SUPPRESS_UBSAN(type) #endif -// This is constexpr function used for checking compile-time constants. -// Avoid `#pragma warning(disable: 4127) // C4127: expression is constant`. namespace flatbuffers { -template<typename T> FLATBUFFERS_CONSTEXPR inline bool IsConstTrue(T t) { - return !!t; -} + // This is constexpr function used for checking compile-time constants. + // Avoid `#pragma warning(disable: 4127) // C4127: expression is constant`. + template<typename T> FLATBUFFERS_CONSTEXPR inline bool IsConstTrue(T t) { + return !!t; + } } // Enable C++ attribute [[]] if std:c++17 or higher. @@ -363,7 +363,6 @@ inline bool VerifyAlignmentRequirements(size_t align, size_t min_align = 1) { } #if defined(_MSC_VER) - #pragma warning(disable: 4351) // C4351: new behavior: elements of array ... will be default initialized #pragma warning(push) #pragma warning(disable: 4127) // C4127: conditional expression is constant #endif diff --git a/contrib/libs/flatbuffers/include/flatbuffers/flatbuffer_builder.h b/contrib/libs/flatbuffers/include/flatbuffers/flatbuffer_builder.h index f97daa4046..774b6bdba6 100644 --- a/contrib/libs/flatbuffers/include/flatbuffers/flatbuffer_builder.h +++ b/contrib/libs/flatbuffers/include/flatbuffers/flatbuffer_builder.h @@ -45,8 +45,9 @@ inline voffset_t FieldIndexToOffset(voffset_t field_id) { // Should correspond to what EndTable() below builds up. const voffset_t fixed_fields = 2 * sizeof(voffset_t); // Vtable size and Object Size. - return fixed_fields + field_id * sizeof(voffset_t); -} + size_t offset = fixed_fields + field_id * sizeof(voffset_t); + FLATBUFFERS_ASSERT(offset < std::numeric_limits<voffset_t>::max()); + return static_cast<voffset_t>(offset);} template<typename T, typename Alloc = std::allocator<T>> const T *data(const std::vector<T, Alloc> &v) { @@ -220,21 +221,13 @@ template<bool Is64Aware = false> class FlatBufferBuilderImpl { /// @return Returns a `uint8_t` pointer to the unfinished buffer. uint8_t *GetCurrentBufferPointer() const { return buf_.data(); } - /// @brief Get the released pointer to the serialized buffer. - /// @warning Do NOT attempt to use this FlatBufferBuilder afterwards! - /// @return A `FlatBuffer` that owns the buffer and its allocator and - /// behaves similar to a `unique_ptr` with a deleter. - FLATBUFFERS_ATTRIBUTE([[deprecated("use Release() instead")]]) - DetachedBuffer ReleaseBufferPointer() { - Finished(); - return buf_.release(); - } - /// @brief Get the released DetachedBuffer. /// @return A `DetachedBuffer` that owns the buffer and its allocator. DetachedBuffer Release() { Finished(); - return buf_.release(); + DetachedBuffer buffer = buf_.release(); + Clear(); + return buffer; } /// @brief Get the released pointer to the serialized buffer. @@ -245,10 +238,12 @@ template<bool Is64Aware = false> class FlatBufferBuilderImpl { /// @return A raw pointer to the start of the memory block containing /// the serialized `FlatBuffer`. /// @remark If the allocator is owned, it gets deleted when the destructor is - /// called.. + /// called. uint8_t *ReleaseRaw(size_t &size, size_t &offset) { Finished(); - return buf_.release_raw(size, offset); + uint8_t* raw = buf_.release_raw(size, offset); + Clear(); + return raw; } /// @brief get the minimum alignment this buffer needs to be accessed @@ -566,7 +561,7 @@ template<bool Is64Aware = false> class FlatBufferBuilderImpl { return CreateString<OffsetT>(str.c_str(), str.length()); } - // clang-format off +// clang-format off #ifdef FLATBUFFERS_HAS_STRING_VIEW /// @brief Store a string in the buffer, which can contain any binary data. /// @param[in] str A const string_view to copy in to the buffer. @@ -588,7 +583,7 @@ template<bool Is64Aware = false> class FlatBufferBuilderImpl { /// @brief Store a string in the buffer, which can contain any binary data. /// @param[in] str A const reference to a std::string like type with support - /// of T::c_str() and T::length() to store in the buffer. + /// of T::data() and T::length() to store in the buffer. /// @return Returns the offset in the buffer where the string starts. template<template<typename> class OffsetT = Offset, // No need to explicitly declare the T type, let the compiler deduce @@ -698,12 +693,27 @@ template<bool Is64Aware = false> class FlatBufferBuilderImpl { // normally dictate. // This is useful when storing a nested_flatbuffer in a vector of bytes, // or when storing SIMD floats, etc. - void ForceVectorAlignment(size_t len, size_t elemsize, size_t alignment) { + void ForceVectorAlignment(const size_t len, const size_t elemsize, + const size_t alignment) { if (len == 0) return; FLATBUFFERS_ASSERT(VerifyAlignmentRequirements(alignment)); PreAlign(len * elemsize, alignment); } + template<bool is_64 = Is64Aware> + typename std::enable_if<is_64, void>::type ForceVectorAlignment64( + const size_t len, const size_t elemsize, const size_t alignment) { + // If you hit this assertion, you are trying to force alignment on a + // vector with offset64 after serializing a 32-bit offset. + FLATBUFFERS_ASSERT(GetSize() == length_of_64_bit_region_); + + // Call through. + ForceVectorAlignment(len, elemsize, alignment); + + // Update the 64 bit region. + length_of_64_bit_region_ = GetSize(); + } + // Similar to ForceVectorAlignment but for String fields. void ForceStringAlignment(size_t len, size_t alignment) { if (len == 0) return; @@ -733,7 +743,7 @@ template<bool Is64Aware = false> class FlatBufferBuilderImpl { AssertScalarT<T>(); StartVector<T, OffsetT, LenT>(len); if (len > 0) { - // clang-format off +// clang-format off #if FLATBUFFERS_LITTLEENDIAN PushBytes(reinterpret_cast<const uint8_t *>(v), len * sizeof(T)); #else @@ -864,7 +874,9 @@ template<bool Is64Aware = false> class FlatBufferBuilderImpl { /// where the vector is stored. template<class It> Offset<Vector<Offset<String>>> CreateVectorOfStrings(It begin, It end) { - auto size = std::distance(begin, end); + auto distance = std::distance(begin, end); + FLATBUFFERS_ASSERT(distance >= 0); + auto size = static_cast<size_t>(distance); auto scratch_buffer_usage = size * sizeof(Offset<String>); // If there is not enough space to store the offsets, there definitely won't // be enough space to store all the strings. So ensuring space for the @@ -874,7 +886,7 @@ template<bool Is64Aware = false> class FlatBufferBuilderImpl { buf_.scratch_push_small(CreateString(*it)); } StartVector<Offset<String>>(size); - for (auto i = 1; i <= size; i++) { + for (size_t i = 1; i <= size; i++) { // Note we re-evaluate the buf location each iteration to account for any // underlying buffer resizing that may occur. PushElement(*reinterpret_cast<Offset<String> *>( @@ -898,8 +910,7 @@ template<bool Is64Aware = false> class FlatBufferBuilderImpl { typedef typename VectorT<T>::size_type LenT; typedef typename OffsetT<VectorT<const T *>>::offset_type offset_type; - StartVector<OffsetT, LenT>(len * sizeof(T) / AlignOf<T>(), sizeof(T), - AlignOf<T>()); + StartVector<OffsetT, LenT>(len, sizeof(T), AlignOf<T>()); if (len > 0) { PushBytes(reinterpret_cast<const uint8_t *>(v), sizeof(T) * len); } @@ -1244,6 +1255,9 @@ template<bool Is64Aware = false> class FlatBufferBuilderImpl { FlatBufferBuilderImpl &operator=(const FlatBufferBuilderImpl &); void Finish(uoffset_t root, const char *file_identifier, bool size_prefix) { + // A buffer can only be finished once. To reuse a builder use `clear()`. + FLATBUFFERS_ASSERT(!finished); + NotNested(); buf_.clear_scratch(); @@ -1369,8 +1383,7 @@ template<bool Is64Aware = false> class FlatBufferBuilderImpl { // Must be completed with EndVectorOfStructs(). template<typename T, template<typename> class OffsetT = Offset> T *StartVectorOfStructs(size_t vector_size) { - StartVector<OffsetT>(vector_size * sizeof(T) / AlignOf<T>(), sizeof(T), - AlignOf<T>()); + StartVector<OffsetT>(vector_size, sizeof(T), AlignOf<T>()); return reinterpret_cast<T *>(buf_.make_space(vector_size * sizeof(T))); } @@ -1456,7 +1469,7 @@ T *GetMutableTemporaryPointer(FlatBufferBuilder &fbb, Offset<T> offset) { } template<typename T> -const T *GetTemporaryPointer(FlatBufferBuilder &fbb, Offset<T> offset) { +const T *GetTemporaryPointer(const FlatBufferBuilder &fbb, Offset<T> offset) { return GetMutableTemporaryPointer<T>(fbb, offset); } diff --git a/contrib/libs/flatbuffers/include/flatbuffers/flatbuffers.h b/contrib/libs/flatbuffers/include/flatbuffers/flatbuffers.h index 952ea3bcdf..1a81821b54 100644 --- a/contrib/libs/flatbuffers/include/flatbuffers/flatbuffers.h +++ b/contrib/libs/flatbuffers/include/flatbuffers/flatbuffers.h @@ -248,31 +248,31 @@ inline const char *flatbuffers_version_string() { // clang-format off #define FLATBUFFERS_DEFINE_BITMASK_OPERATORS(E, T)\ - inline E operator | (E lhs, E rhs){\ + inline FLATBUFFERS_CONSTEXPR_CPP11 E operator | (E lhs, E rhs){\ return E(T(lhs) | T(rhs));\ }\ - inline E operator & (E lhs, E rhs){\ + inline FLATBUFFERS_CONSTEXPR_CPP11 E operator & (E lhs, E rhs){\ return E(T(lhs) & T(rhs));\ }\ - inline E operator ^ (E lhs, E rhs){\ + inline FLATBUFFERS_CONSTEXPR_CPP11 E operator ^ (E lhs, E rhs){\ return E(T(lhs) ^ T(rhs));\ }\ - inline E operator ~ (E lhs){\ + inline FLATBUFFERS_CONSTEXPR_CPP11 E operator ~ (E lhs){\ return E(~T(lhs));\ }\ - inline E operator |= (E &lhs, E rhs){\ + inline FLATBUFFERS_CONSTEXPR_CPP11 E operator |= (E &lhs, E rhs){\ lhs = lhs | rhs;\ return lhs;\ }\ - inline E operator &= (E &lhs, E rhs){\ + inline FLATBUFFERS_CONSTEXPR_CPP11 E operator &= (E &lhs, E rhs){\ lhs = lhs & rhs;\ return lhs;\ }\ - inline E operator ^= (E &lhs, E rhs){\ + inline FLATBUFFERS_CONSTEXPR_CPP11 E operator ^= (E &lhs, E rhs){\ lhs = lhs ^ rhs;\ return lhs;\ }\ - inline bool operator !(E rhs) \ + inline FLATBUFFERS_CONSTEXPR_CPP11 bool operator !(E rhs) \ {\ return !bool(T(rhs)); \ } diff --git a/contrib/libs/flatbuffers/include/flatbuffers/flexbuffers.h b/contrib/libs/flatbuffers/include/flatbuffers/flexbuffers.h index 1fdffb424e..7b5b20b701 100644 --- a/contrib/libs/flatbuffers/include/flatbuffers/flexbuffers.h +++ b/contrib/libs/flatbuffers/include/flatbuffers/flexbuffers.h @@ -360,16 +360,40 @@ class Map : public Vector { bool IsTheEmptyMap() const { return data_ == EmptyMap().data_; } }; +inline void IndentString(std::string &s, int indent, + const char *indent_string) { + for (int i = 0; i < indent; i++) s += indent_string; +} + template<typename T> -void AppendToString(std::string &s, T &&v, bool keys_quoted) { - s += "[ "; +void AppendToString(std::string &s, T &&v, bool keys_quoted, bool indented, + int cur_indent, const char *indent_string) { + s += "["; + s += indented ? "\n" : " "; for (size_t i = 0; i < v.size(); i++) { - if (i) s += ", "; - v[i].ToString(true, keys_quoted, s); + if (i) { + s += ","; + s += indented ? "\n" : " "; + } + if (indented) IndentString(s, cur_indent, indent_string); + v[i].ToString(true, keys_quoted, s, indented, cur_indent, + indent_string); } - s += " ]"; + if (indented) { + s += "\n"; + IndentString(s, cur_indent - 1, indent_string); + } else { + s += " "; + } + s += "]"; } +template<typename T> +void AppendToString(std::string &s, T &&v, bool keys_quoted) { + AppendToString(s, v, keys_quoted); +} + + class Reference { public: Reference() @@ -542,8 +566,13 @@ class Reference { // Convert any type to a JSON-like string. strings_quoted determines if // string values at the top level receive "" quotes (inside other values // they always do). keys_quoted determines if keys are quoted, at any level. - // TODO(wvo): add further options to have indentation/newlines. void ToString(bool strings_quoted, bool keys_quoted, std::string &s) const { + ToString(strings_quoted, keys_quoted, s, false, 0, ""); + } + + // This version additionally allow you to specify if you want indentation. + void ToString(bool strings_quoted, bool keys_quoted, std::string &s, + bool indented, int cur_indent, const char *indent_string) const { if (type_ == FBT_STRING) { String str(Indirect(), byte_width_); if (strings_quoted) { @@ -569,7 +598,8 @@ class Reference { } else if (IsBool()) { s += AsBool() ? "true" : "false"; } else if (IsMap()) { - s += "{ "; + s += "{"; + s += indented ? "\n" : " "; auto m = AsMap(); auto keys = m.Keys(); auto vals = m.Values(); @@ -590,18 +620,28 @@ class Reference { } } } + if (indented) IndentString(s, cur_indent + 1, indent_string); keys[i].ToString(true, kq, s); s += ": "; - vals[i].ToString(true, keys_quoted, s); - if (i < keys.size() - 1) s += ", "; + vals[i].ToString(true, keys_quoted, s, indented, cur_indent + 1, indent_string); + if (i < keys.size() - 1) { + s += ","; + if (!indented) s += " "; + } + if (indented) s += "\n"; } - s += " }"; + if (!indented) s += " "; + if (indented) IndentString(s, cur_indent, indent_string); + s += "}"; } else if (IsVector()) { - AppendToString<Vector>(s, AsVector(), keys_quoted); + AppendToString<Vector>(s, AsVector(), keys_quoted, indented, + cur_indent + 1, indent_string); } else if (IsTypedVector()) { - AppendToString<TypedVector>(s, AsTypedVector(), keys_quoted); + AppendToString<TypedVector>(s, AsTypedVector(), keys_quoted, indented, + cur_indent + 1, indent_string); } else if (IsFixedTypedVector()) { - AppendToString<FixedTypedVector>(s, AsFixedTypedVector(), keys_quoted); + AppendToString<FixedTypedVector>(s, AsFixedTypedVector(), keys_quoted, + indented, cur_indent + 1, indent_string); } else if (IsBlob()) { auto blob = AsBlob(); flatbuffers::EscapeString(reinterpret_cast<const char *>(blob.data()), @@ -1128,10 +1168,7 @@ class Builder FLATBUFFERS_FINAL_CLASS { size_t EndMap(size_t start) { // We should have interleaved keys and values on the stack. - // Make sure it is an even number: - auto len = stack_.size() - start; - FLATBUFFERS_ASSERT(!(len & 1)); - len /= 2; + auto len = MapElementCount(start); // Make sure keys are all strings: for (auto key = start; key < stack_.size(); key += 2) { FLATBUFFERS_ASSERT(stack_[key].type_ == FBT_KEY); @@ -1289,6 +1326,14 @@ class Builder FLATBUFFERS_FINAL_CLASS { EndMap(start); } + size_t MapElementCount(size_t start) { + // Make sure it is an even number: + auto len = stack_.size() - start; + FLATBUFFERS_ASSERT(!(len & 1)); + len /= 2; + return len; + } + // If you wish to share a value explicitly (a value not shared automatically // through one of the BUILDER_FLAG_SHARE_* flags) you can do so with these // functions. Or if you wish to turn those flags off for performance reasons @@ -1307,6 +1352,12 @@ class Builder FLATBUFFERS_FINAL_CLASS { ReuseValue(v); } + // Undo the last element serialized. Call once for a value and once for a + // key. + void Undo() { + stack_.pop_back(); + } + // Overloaded Add that tries to call the correct function above. void Add(int8_t i) { Int(i); } void Add(int16_t i) { Int(i); } @@ -1669,7 +1720,7 @@ class Verifier FLATBUFFERS_FINAL_CLASS { max_vectors_(buf_len), check_alignment_(_check_alignment), reuse_tracker_(reuse_tracker) { - FLATBUFFERS_ASSERT(size_ < FLATBUFFERS_MAX_BUFFER_SIZE); + FLATBUFFERS_ASSERT(static_cast<int32_t>(size_) < FLATBUFFERS_MAX_BUFFER_SIZE); if (reuse_tracker_) { reuse_tracker_->clear(); reuse_tracker_->resize(size_, PackedType(BIT_WIDTH_8, FBT_NULL)); diff --git a/contrib/libs/flatbuffers/include/flatbuffers/idl.h b/contrib/libs/flatbuffers/include/flatbuffers/idl.h index f65f18a9ab..9b9e98fcf4 100644 --- a/contrib/libs/flatbuffers/include/flatbuffers/idl.h +++ b/contrib/libs/flatbuffers/include/flatbuffers/idl.h @@ -342,7 +342,10 @@ struct FieldDef : public Definition { bool Deserialize(Parser &parser, const reflection::Field *field); bool IsScalarOptional() const { - return IsScalar(value.type.base_type) && IsOptional(); + return IsScalar() && IsOptional(); + } + bool IsScalar() const { + return ::flatbuffers::IsScalar(value.type.base_type); } bool IsOptional() const { return presence == kOptional; } bool IsRequired() const { return presence == kRequired; } @@ -673,6 +676,7 @@ struct IDLOptions { bool binary_schema_comments; bool binary_schema_builtins; bool binary_schema_gen_embed; + bool binary_schema_absolute_paths; std::string go_import; std::string go_namespace; std::string go_module_name; @@ -703,6 +707,7 @@ struct IDLOptions { bool keep_proto_id; bool python_no_type_prefix_suffix; bool python_typing; + bool ts_omit_entrypoint; ProtoIdGapAction proto_id_gap_action; // Possible options for the more general generator below. @@ -726,6 +731,7 @@ struct IDLOptions { kCppYandexMapsIter = 1 << 19, kNim = 1 << 17, kProto = 1 << 18, + kKotlinKmp = 1 << 19, kMAX }; @@ -792,6 +798,7 @@ struct IDLOptions { binary_schema_comments(false), binary_schema_builtins(false), binary_schema_gen_embed(false), + binary_schema_absolute_paths(false), protobuf_ascii_alike(false), size_prefixed(false), force_defaults(false), @@ -815,6 +822,7 @@ struct IDLOptions { keep_proto_id(false), python_no_type_prefix_suffix(false), python_typing(false), + ts_omit_entrypoint(false), proto_id_gap_action(ProtoIdGapAction::WARNING), mini_reflect(IDLOptions::kNone), require_explicit_ids(false), @@ -1215,6 +1223,16 @@ class Parser : public ParserState { // These functions return nullptr on success, or an error string, // which may happen if the flatbuffer cannot be encoded in JSON (e.g., // it contains non-UTF-8 byte arrays in String values). +extern bool GenerateTextFromTable(const Parser &parser, + const void *table, + const std::string &tablename, + std::string *text); +extern const char *GenerateText(const Parser &parser, const void *flatbuffer, + std::string *text); +extern const char *GenerateTextFile(const Parser &parser, + const std::string &path, + const std::string &file_name); + extern const char *GenTextFromTable(const Parser &parser, const void *table, const std::string &tablename, std::string *text); diff --git a/contrib/libs/flatbuffers/include/flatbuffers/reflection_generated.h b/contrib/libs/flatbuffers/include/flatbuffers/reflection_generated.h index 4690434db6..9f83dcb5d4 100644 --- a/contrib/libs/flatbuffers/include/flatbuffers/reflection_generated.h +++ b/contrib/libs/flatbuffers/include/flatbuffers/reflection_generated.h @@ -8,9 +8,9 @@ // Ensure the included flatbuffers.h is the same version as when this file was // generated, otherwise it may not be compatible. -static_assert(FLATBUFFERS_VERSION_MAJOR == 23 && - FLATBUFFERS_VERSION_MINOR == 5 && - FLATBUFFERS_VERSION_REVISION == 26, +static_assert(FLATBUFFERS_VERSION_MAJOR == 24 && + FLATBUFFERS_VERSION_MINOR == 3 && + FLATBUFFERS_VERSION_REVISION == 7, "Non-compatible flatbuffers version included"); namespace reflection { diff --git a/contrib/libs/flatbuffers/include/flatbuffers/stl_emulation.h b/contrib/libs/flatbuffers/include/flatbuffers/stl_emulation.h index c085952b60..6054f78fa6 100644 --- a/contrib/libs/flatbuffers/include/flatbuffers/stl_emulation.h +++ b/contrib/libs/flatbuffers/include/flatbuffers/stl_emulation.h @@ -45,7 +45,8 @@ // Testing __cpp_lib_span requires including either <version> or <span>, // both of which were added in C++20. // See: https://en.cppreference.com/w/cpp/utility/feature_test - #if defined(__cplusplus) && __cplusplus >= 202002L + #if defined(__cplusplus) && __cplusplus >= 202002L \ + || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L) #define FLATBUFFERS_USE_STD_SPAN 1 #endif #endif // FLATBUFFERS_USE_STD_SPAN diff --git a/contrib/libs/flatbuffers/include/flatbuffers/string.h b/contrib/libs/flatbuffers/include/flatbuffers/string.h index e6b98f0c9f..d33fbfaa88 100644 --- a/contrib/libs/flatbuffers/include/flatbuffers/string.h +++ b/contrib/libs/flatbuffers/include/flatbuffers/string.h @@ -31,6 +31,11 @@ struct String : public Vector<char> { flatbuffers::string_view string_view() const { return flatbuffers::string_view(c_str(), size()); } + + /* implicit */ + operator flatbuffers::string_view() const { + return flatbuffers::string_view(c_str(), size()); + } #endif // FLATBUFFERS_HAS_STRING_VIEW // clang-format on diff --git a/contrib/libs/flatbuffers/include/flatbuffers/util.h b/contrib/libs/flatbuffers/include/flatbuffers/util.h index c781b7e233..6151f4e025 100644 --- a/contrib/libs/flatbuffers/include/flatbuffers/util.h +++ b/contrib/libs/flatbuffers/include/flatbuffers/util.h @@ -479,6 +479,11 @@ std::string PosixPath(const std::string &path); // creating dirs for any parts of the path that don't exist yet. void EnsureDirExists(const std::string &filepath); +// Obtains the relative or absolute path. +std::string FilePath(const std::string &project, + const std::string &filePath, + bool absolute); + // Obtains the absolute path from any other path. // Returns the input path if the absolute path couldn't be resolved. std::string AbsolutePath(const std::string &filepath); |