Skip to content

ludus::foundation::StaticString

Ludus Wiki · API overview · Browse API

Class

Fixed-capacity inline bytes; Capacity excludes the extra terminator.
Holds up to Capacity bytes plus a terminating zero in Capacity + 1 inline bytes and never allocates; Capacity zero is valid and holds only empty text. Sizes count bytes, not Unicode scalars, and contents are not validated as UTF-8. Counted operations preserve embedded zero bytes. Overflow preserves the entire old value; no silent truncation. Copies are plain value copies. Not internally synchronized: concurrent const calls are safe, and any non-const call needs exclusive access.
Template parameterDescription
Capacity
Maximum number of stored bytes, excluding the terminator.

Declared in modules/foundation/strings/include/ludus/foundation/strings/static_string.hpp

#include <ludus/foundation/strings/static_string.hpp>
template <usize Capacity>
class ludus::foundation::StaticString final

Methods

GetSize

constexpr usize ludus::foundation::StaticString< Capacity >::GetSize() const noexcept
Number of stored bytes, excluding the terminating zero.

Related types: usize

Declared in modules/foundation/strings/include/ludus/foundation/strings/static_string.hpp

IsEmpty

constexpr bool ludus::foundation::StaticString< Capacity >::IsEmpty() const noexcept
True when GetSize is zero.

Declared in modules/foundation/strings/include/ludus/foundation/strings/static_string.hpp

GetView

std::string_view ludus::foundation::StaticString< Capacity >::GetView() const &noexcept
Borrowed counted view of the stored bytes, which may contain zero bytes.
Points into this object: valid until the next non-const call on it or its destruction.

Declared in modules/foundation/strings/include/ludus/foundation/strings/static_string.hpp

GetView

std::string_view ludus::foundation::StaticString< Capacity >::GetView() const &&=delete
Deleted so a view cannot outlive a temporary that is destroyed at the end of the expression.

Declared in modules/foundation/strings/include/ludus/foundation/strings/static_string.hpp

GetData

const char * ludus::foundation::StaticString< Capacity >::GetData() const &noexcept
Borrowed pointer to the inline bytes; never null.
GetData()[GetSize()] is always zero, but embedded zero bytes may end a C-string reading early. Lifetime is the same as GetView.

Declared in modules/foundation/strings/include/ludus/foundation/strings/static_string.hpp

GetData

const char * ludus::foundation::StaticString< Capacity >::GetData() const &&=delete
Deleted so a pointer cannot outlive a temporary that is destroyed at the end of the expression.

Declared in modules/foundation/strings/include/ludus/foundation/strings/static_string.hpp

TryAssign

StringStatus ludus::foundation::StaticString< Capacity >::TryAssign(std::string_view value) noexcept
Replaces the contents with a copy of value, overlap-safe.
ParameterDescription
value
Bytes to copy; it may borrow this object's own bytes.

Returns

Ok; CapacityExceeded when value is longer than Capacity, leaving the old value unchanged.

Related types: StringStatus

Declared in modules/foundation/strings/include/ludus/foundation/strings/static_string.hpp

TryAppend

StringStatus ludus::foundation::StaticString< Capacity >::TryAppend(std::string_view value) noexcept
Appends a copy of value, overlap-safe.
ParameterDescription
value
Bytes to append; it may borrow this object's own bytes.

Returns

Ok; CapacityExceeded when value does not fit the remaining capacity, leaving the old value unchanged.

Related types: StringStatus

Declared in modules/foundation/strings/include/ludus/foundation/strings/static_string.hpp

Clear

void ludus::foundation::StaticString< Capacity >::Clear() noexcept
Sets the size to zero and writes the terminating zero at the start.

Declared in modules/foundation/strings/include/ludus/foundation/strings/static_string.hpp

Static methods

GetCapacity

static constexpr usize ludus::foundation::StaticString< Capacity >::GetCapacity() noexcept
Maximum number of stored bytes, Capacity, excluding the terminating zero.

Related types: usize

Declared in modules/foundation/strings/include/ludus/foundation/strings/static_string.hpp