ludus::foundation::String¶
Ludus Wiki · API overview · Browse API
Class
Declared in modules/foundation/strings/include/ludus/foundation/strings/string.hpp
#include <ludus/foundation/strings/string.hpp>
class ludus::foundation::String final
Static fields¶
kInlineCapacity¶
static constexpr usize ludus::foundation::String::kInlineCapacity = 23
Related types: usize
Declared in modules/foundation/strings/include/ludus/foundation/strings/string.hpp
Methods¶
String¶
explicit ludus::foundation::String::String(const AllocationDomain &domain=GetSystemAllocationDomain()) noexcept
domain; does not allocate. | Parameter | Description |
|---|---|
domain |
Allocation domain for later growth. It is borrowed and must outlive this owner.
|
Related types: AllocationDomain
Declared in modules/foundation/strings/include/ludus/foundation/strings/string.hpp
~String¶
ludus::foundation::String::~String() noexcept
Declared in modules/foundation/strings/include/ludus/foundation/strings/string.hpp
String¶
ludus::foundation::String::String(String &&other) noexcept
other's bytes, storage and domain without allocating. other becomes empty and inline and keeps its domain, so it remains usable. Declared in modules/foundation/strings/include/ludus/foundation/strings/string.hpp
operator=¶
String & ludus::foundation::String::operator=(String &&other) noexcept
other's bytes, storage and domain. other becomes empty and inline and keeps its domain. Self-move does nothing. Related types: String
Declared in modules/foundation/strings/include/ludus/foundation/strings/string.hpp
String¶
ludus::foundation::String::String(const String &)=delete
Declared in modules/foundation/strings/include/ludus/foundation/strings/string.hpp
operator=¶
String & ludus::foundation::String::operator=(const String &)=delete
Related types: String
Declared in modules/foundation/strings/include/ludus/foundation/strings/string.hpp
GetSize¶
usize ludus::foundation::String::GetSize() const noexcept
Related types: usize
Declared in modules/foundation/strings/include/ludus/foundation/strings/string.hpp
GetCapacity¶
usize ludus::foundation::String::GetCapacity() const noexcept
Related types: usize
Declared in modules/foundation/strings/include/ludus/foundation/strings/string.hpp
IsEmpty¶
bool ludus::foundation::String::IsEmpty() const noexcept
Declared in modules/foundation/strings/include/ludus/foundation/strings/string.hpp
GetDomain¶
const AllocationDomain & ludus::foundation::String::GetDomain() const noexcept
Related types: AllocationDomain
Declared in modules/foundation/strings/include/ludus/foundation/strings/string.hpp
GetView¶
std::string_view ludus::foundation::String::GetView() const &noexcept
Declared in modules/foundation/strings/include/ludus/foundation/strings/string.hpp
GetView¶
std::string_view ludus::foundation::String::GetView() const &&=delete
Declared in modules/foundation/strings/include/ludus/foundation/strings/string.hpp
GetData¶
const char * ludus::foundation::String::GetData() const &noexcept
GetData()[GetSize()] is always zero, including for an empty owner, but embedded zero bytes may end a C-string reading early. Valid until the next non-const call on this owner, a move from it, or its destruction. Declared in modules/foundation/strings/include/ludus/foundation/strings/string.hpp
GetData¶
const char * ludus::foundation::String::GetData() const &&=delete
Declared in modules/foundation/strings/include/ludus/foundation/strings/string.hpp
TryAssign¶
StringStatus ludus::foundation::String::TryAssign(std::string_view value) noexcept
value. value fits the current capacity. Otherwise allocates grown storage (the larger of the request and twice the current capacity, clamped to the maximum), copies value into it and only then frees the old storage. value may therefore borrow this owner's own bytes. | Parameter | Description |
|---|---|
value |
Bytes to copy; it may alias this owner's contents.
|
Returns
value exceeds the maximum capacity (just under half the address space); OutOfMemory when the domain cannot supply the storage. Failure leaves the owner unchanged. Related types: StringStatus
Declared in modules/foundation/strings/include/ludus/foundation/strings/string.hpp
TryAppend¶
StringStatus ludus::foundation::String::TryAppend(std::string_view value) noexcept
value; equivalent to TryAppendMany with one view. | Parameter | Description |
|---|---|
value |
Bytes to append; it may alias this owner's contents.
|
Returns
Related types: StringStatus
Declared in modules/foundation/strings/include/ludus/foundation/strings/string.hpp
TryAppendMany¶
StringStatus ludus::foundation::String::TryAppendMany(std::span< const std::string_view > values) noexcept
| Parameter | Description |
|---|---|
values |
Views to append; each may alias this owner's contents.
|
Returns
Related types: StringStatus
Declared in modules/foundation/strings/include/ludus/foundation/strings/string.hpp
TryEnsureCapacity¶
StringStatus ludus::foundation::String::TryEnsureCapacity(usize capacity) noexcept
capacity bytes, excluding the terminating zero. | Parameter | Description |
|---|---|
capacity |
Requested capacity in bytes.
|
Returns
capacity exceeds the maximum capacity; OutOfMemory when the domain cannot supply the storage. Failure leaves the owner unchanged. Related types: StringStatus · usize
Declared in modules/foundation/strings/include/ludus/foundation/strings/string.hpp
CloneTo¶
StringStatus ludus::foundation::String::CloneTo(const AllocationDomain &domain, String &output) const noexcept
domain, then moves it into output. output's previous storage is released and output takes domain. output may be this owner. | Parameter | Description |
|---|---|
domain |
Domain for the copy; borrowed and must outlive
output. |
output |
Receives the copy.
|
Returns
domain cannot supply the storage. Failure leaves output unchanged. Related types: AllocationDomain · String · StringStatus
Declared in modules/foundation/strings/include/ludus/foundation/strings/string.hpp
Clear¶
void ludus::foundation::String::Clear() noexcept
Declared in modules/foundation/strings/include/ludus/foundation/strings/string.hpp