File indexing completed on 2025-08-27 09:30:28
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #ifndef FLATBUFFERS_STRING_H_
0018 #define FLATBUFFERS_STRING_H_
0019
0020 #include "flatbuffers/base.h"
0021 #include "flatbuffers/vector.h"
0022
0023 namespace flatbuffers {
0024
0025 struct String : public Vector<char> {
0026 const char *c_str() const { return reinterpret_cast<const char *>(Data()); }
0027 std::string str() const { return std::string(c_str(), size()); }
0028
0029
0030 #ifdef FLATBUFFERS_HAS_STRING_VIEW
0031 flatbuffers::string_view string_view() const {
0032 return flatbuffers::string_view(c_str(), size());
0033 }
0034
0035
0036 operator flatbuffers::string_view() const {
0037 return flatbuffers::string_view(c_str(), size());
0038 }
0039 #endif
0040
0041
0042 bool operator<(const String &o) const {
0043 return StringLessThan(this->data(), this->size(), o.data(), o.size());
0044 }
0045 };
0046
0047
0048
0049 static inline std::string GetString(const String *str) {
0050 return str ? str->str() : "";
0051 }
0052
0053
0054
0055 static inline const char *GetCstring(const String *str) {
0056 return str ? str->c_str() : "";
0057 }
0058
0059 #ifdef FLATBUFFERS_HAS_STRING_VIEW
0060
0061
0062 static inline flatbuffers::string_view GetStringView(const String *str) {
0063 return str ? str->string_view() : flatbuffers::string_view();
0064 }
0065 #endif
0066
0067 }
0068
0069 #endif