| 23 | namespace flatbuffers { |
| 24 | |
| 25 | struct String : public Vector<char> { |
| 26 | const char *c_str() const { return reinterpret_cast<const char *>(Data()); } |
| 27 | std::string str() const { return std::string(c_str(), size()); } |
| 28 | |
| 29 | // clang-format off |
| 30 | #ifdef FLATBUFFERS_HAS_STRING_VIEW |
| 31 | flatbuffers::string_view string_view() const { |
| 32 | return flatbuffers::string_view(c_str(), size()); |
| 33 | } |
| 34 | |
| 35 | /* implicit */ |
| 36 | operator flatbuffers::string_view() const { |
| 37 | return flatbuffers::string_view(c_str(), size()); |
| 38 | } |
| 39 | #endif // FLATBUFFERS_HAS_STRING_VIEW |
| 40 | // clang-format on |
| 41 | |
| 42 | bool operator<(const String &o) const { |
| 43 | return StringLessThan(this->data(), this->size(), o.data(), o.size()); |
| 44 | } |
| 45 | }; |
| 46 | |
| 47 | // Convenience function to get std::string from a String returning an empty |
| 48 | // string on null pointer. |
no test coverage detected