Flecs v4.1
A fast entity component system (ECS) for C & C++
Loading...
Searching...
No Matches
flecs::string_view Struct Reference

Non-owning string view. More...

#include <string.hpp>

Inheritance diagram for flecs::string_view:
[legend]

Public Member Functions

 string_view (const char *str)
 Construct from a C string (non-owning).
Public Member Functions inherited from flecs::string
 string ()
 Default constructor.
 string (char *str)
 Construct from an owned char pointer.
 ~string ()
 Destructor.
 string (string &&str) noexcept
 Move constructor.
 operator const char * () const
 Implicit conversion to const char*.
stringoperator= (string &&str) noexcept
 Move assignment operator.
stringoperator= (const string &str)=delete
 Ban implicit copies/allocations.
 string (const string &str)=delete
 Ban implicit copies/allocations.
bool operator== (const flecs::string &str) const
 Equality operator.
bool operator!= (const flecs::string &str) const
 Inequality operator.
bool operator== (const char *str) const
 Equality operator for a C string.
bool operator!= (const char *str) const
 Inequality operator for a C string.
const char * c_str () const
 Return the C string.
std::size_t length () const
 Return the string length.
std::size_t size () const
 Return the string size (same as length).
void clear ()
 Clear the string, freeing the owned memory.
bool contains (const char *substr)
 Check if the string contains a substring.

Additional Inherited Members

Static Public Member Functions inherited from flecs::string
template<size_t N>
static constexpr size_t length (char const (&)[N])
 Return the length of a string literal at compile time.
Protected Member Functions inherited from flecs::string
 string (const char *str)
 Construct from a non-owned C string.
Protected Attributes inherited from flecs::string
char * str_ = nullptr
const char * const_str_
ecs_size_t length_

Detailed Description

Non-owning string view.

For consistency, the API returns a string_view where it could have returned a const char*, so an application won't have to think about whether to call c_str() or not. The string_view is a thin wrapper around a string that forces the API to indicate explicitly when a string is owned or not.

Definition at line 169 of file string.hpp.

Constructor & Destructor Documentation

◆ string_view()

flecs::string_view::string_view ( const char * str)
inlineexplicit

Construct from a C string (non-owning).

Definition at line 171 of file string.hpp.


The documentation for this struct was generated from the following file: