![]() |
Flecs v4.1
A fast entity component system (ECS) for C & C++
|
Owned string wrapper. More...
#include <string.hpp>
Public Member Functions | |
| 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*. | |
| string & | operator= (string &&str) noexcept |
| Move assignment operator. | |
| string & | operator= (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. | |
Static Public Member Functions | |
| 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 | |
| string (const char *str) | |
| Construct from a non-owned C string. | |
Protected Attributes | |
| char * | str_ = nullptr |
| const char * | const_str_ |
| ecs_size_t | length_ |
Owned string wrapper.
This removes dependencies on std::string (and therefore STL) and allows the API to return allocated strings without incurring additional allocations when wrapping in an std::string.
Definition at line 15 of file string.hpp.
|
inlineexplicit |
Default constructor.
Definition at line 17 of file string.hpp.
|
inlineexplicit |
Construct from an owned char pointer.
Definition at line 23 of file string.hpp.
|
inline |
|
inlinenoexcept |
Move constructor.
Definition at line 40 of file string.hpp.
|
inlineprotected |
Construct from a non-owned C string.
Must be constructed through string_view. This allows for using the string class for both owned and non-owned strings, which can reduce allocations when code conditionally should store a literal or an owned string. Making this constructor protected forces the code to explicitly create a string_view, which emphasizes that the string won't be freed by the class.
Definition at line 153 of file string.hpp.
|
inline |
Return the C string.
Definition at line 109 of file string.hpp.
|
inline |
Clear the string, freeing the owned memory.
Definition at line 130 of file string.hpp.
|
inline |
Check if the string contains a substring.
Definition at line 137 of file string.hpp.
|
inline |
Return the string length.
Definition at line 114 of file string.hpp.
|
inlinestaticconstexpr |
Return the length of a string literal at compile time.
Definition at line 120 of file string.hpp.
|
inline |
Implicit conversion to const char*.
Definition at line 49 of file string.hpp.
|
inline |
Inequality operator for a C string.
Definition at line 104 of file string.hpp.
|
inline |
Inequality operator.
Definition at line 86 of file string.hpp.
Move assignment operator.
Definition at line 54 of file string.hpp.
|
inline |
Equality operator for a C string.
Definition at line 91 of file string.hpp.
|
inline |
Equality operator.
Definition at line 69 of file string.hpp.
|
inline |
Return the string size (same as length).
Definition at line 125 of file string.hpp.
|
protected |
Definition at line 159 of file string.hpp.
|
protected |
Definition at line 160 of file string.hpp.
|
protected |
Definition at line 158 of file string.hpp.