25 , const_str_(str ? str :
"")
26 , length_(str ? ecs_os_strlen(str) : 0) { }
43 const_str_ = str.const_str_;
44 length_ = str.length_;
49 operator const char*()
const {
57 const_str_ = str.const_str_;
58 length_ = str.length_;
70 if (str.const_str_ == const_str_) {
74 if (!const_str_ || !str.const_str_) {
78 if (str.length_ != length_) {
82 return ecs_os_strcmp(str, const_str_) == 0;
87 return !(*
this == str);
92 if (const_str_ == str) {
96 if (!const_str_ || !str) {
100 return ecs_os_strcmp(str, const_str_) == 0;
105 return !(*
this == str);
115 return static_cast<std::size_t
>(length_);
120 static constexpr size_t length(
char const (&)[N] ) {
133 const_str_ =
nullptr;
139 return strstr(const_str_, substr) !=
nullptr;
155 , const_str_(str ? str :
"")
156 , length_(str ? ecs_os_strlen(str) : 0) { }
158 char *str_ =
nullptr;
159 const char *const_str_;
string_view(const char *str)
Construct from a C string (non-owning).
static constexpr size_t length(char const (&)[N])
Return the length of a string literal at compile time.
bool operator!=(const char *str) const
Inequality operator for a C string.
string(const char *str)
Construct from a non-owned C string.
string & operator=(const string &str)=delete
Ban implicit copies/allocations.
bool contains(const char *substr)
Check if the string contains a substring.
string()
Default constructor.
string(string &&str) noexcept
Move constructor.
std::size_t length() const
Return the string length.
string(const string &str)=delete
Ban implicit copies/allocations.
string & operator=(string &&str) noexcept
Move assignment operator.
const char * c_str() const
Return the C string.
void clear()
Clear the string, freeing the owned memory.
bool operator==(const flecs::string &str) const
Equality operator.
string(char *str)
Construct from an owned char pointer.
bool operator!=(const flecs::string &str) const
Inequality operator.
std::size_t size() const
Return the string size (same as length).
bool operator==(const char *str) const
Equality operator for a C string.