|
Cogs.Core
|
Represents a non-copyable immutable string. More...
#include <ImmutableString.h>
Public Member Functions | |
| constexpr | ImmutableString () noexcept=default |
| Create an empty string. | |
| ImmutableString (const ImmutableString &)=delete | |
| Non-copyable. | |
| ImmutableString & | operator= (const ImmutableString &)=delete |
| Non-copyable. | |
| constexpr | ImmutableString (ImmutableString &&other) noexcept |
| Take ownership of another string. | |
| constexpr ImmutableString & | operator= (ImmutableString &&other) noexcept |
| Take ownership of another string. | |
| COGSFOUNDATION_API | ImmutableString (const Cogs::StringView &view) |
| Create a new unique immutable string from a string view. | |
| ~ImmutableString () | |
| Destructor. | |
| constexpr | operator const char * () const noexcept |
| View the string as C-string. | |
| constexpr | operator Cogs::StringView () const noexcept |
| View the string as a string view. | |
| constexpr void | swap (ImmutableString &other) noexcept |
| Swap contents with another string. | |
| constexpr Cogs::StringView | asView () const noexcept |
| Explicitly view the string as a string view. | |
| constexpr bool | empty () const noexcept |
| Check if string is empty. | |
| void | clear () |
| Set contents to the empty string. | |
| constexpr const char * | c_str () const noexcept |
| Get the string as C-string. | |
| constexpr size_t | size () const noexcept |
| Get the string length. | |
Private Member Functions | |
| COGSFOUNDATION_API void | release () |
Private Attributes | |
| char * | ptr = nullptr |
Represents a non-copyable immutable string.
Essentially a heap-allocated string with unique_ptr-semantics.
Optimized for representing empty strings, in that case the object has the memory footprint of a single pointer.
Definition at line 21 of file ImmutableString.h.
|
inlineconstexprnoexcept |
Take ownership of another string.
Definition at line 35 of file ImmutableString.h.
References swap().
| Cogs::ImmutableString::ImmutableString | ( | const Cogs::StringView & | view | ) |
Create a new unique immutable string from a string view.
Definition at line 37 of file ImmutableString.cpp.
References Cogs::StringView::data(), Cogs::StringView::empty(), and Cogs::StringView::size().
|
inline |
|
inlineconstexprnoexcept |
Explicitly view the string as a string view.
Definition at line 56 of file ImmutableString.h.
Referenced by operator Cogs::StringView().
|
inlineconstexprnoexcept |
Get the string as C-string.
Definition at line 65 of file ImmutableString.h.
Referenced by operator const char *().
|
inline |
Set contents to the empty string.
Definition at line 62 of file ImmutableString.h.
Referenced by ~ImmutableString().
|
inlineconstexprnoexcept |
Check if string is empty.
Definition at line 59 of file ImmutableString.h.
|
inlineconstexprnoexcept |
View the string as a string view.
Definition at line 50 of file ImmutableString.h.
References asView().
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
Take ownership of another string.
Definition at line 38 of file ImmutableString.h.
References swap().
|
private |
Definition at line 62 of file ImmutableString.cpp.
|
inlineconstexprnoexcept |
Get the string length.
Definition at line 68 of file ImmutableString.h.
References size().
Referenced by size().
|
inlineconstexprnoexcept |
Swap contents with another string.
Definition at line 53 of file ImmutableString.h.
Referenced by ImmutableString(), and operator=().
|
private |
Definition at line 74 of file ImmutableString.h.