Helios Engine 0.1.0
A modular ECS based data-oriented C++23 game engine
 
Loading...
Searching...
No Matches
helios::container::BasicStaticString< StrCapacity, CharT, Traits > Class Template Referencefinal

A fixed-capacity string class that owns its storage. More...

#include <static_string.hpp>

Public Types

using traits_type = Traits
 
using value_type = CharT
 
using pointer = CharT *
 
using const_pointer = const CharT *
 
using reference = CharT &
 
using const_reference = const CharT &
 
using iterator = CharT *
 
using const_iterator = const CharT *
 
using reverse_iterator = std::reverse_iterator< iterator >
 
using const_reverse_iterator = std::reverse_iterator< const_iterator >
 
using size_type = size_t
 
using difference_type = ptrdiff_t
 

Public Member Functions

constexpr BasicStaticString () noexcept
 Default constructor. Creates an empty string.
 
constexpr BasicStaticString (std::basic_string_view< CharT, Traits > sv) noexcept
 Constructs from a string_view.
 
constexpr BasicStaticString (std::basic_string_view< CharT, Traits > sv, size_type pos, size_type count=npos) noexcept
 Constructs a substring from a string_view with position and count.
 
constexpr BasicStaticString (const CharT *str) noexcept
 Constructs from a null-terminated C string.
 
template<size_t N>
requires (N <= StrCapacity + 1)
constexpr explicit (false) BasicStaticString(const CharT(&str)[N]) noexcept
 Constructs from a character array of known size.
 
constexpr BasicStaticString (size_type count, CharT ch) noexcept
 Constructs from count copies of character ch.
 
constexpr BasicStaticString (const CharT *str, size_type len) noexcept
 Constructs from a pointer and length.
 
template<std::input_iterator InputIt>
requires (StrCapacity > 0)
constexpr BasicStaticString (InputIt first, InputIt last) noexcept
 Constructs from an iterator range.
 
template<std::ranges::input_range Range>
requires std::convertible_to<std::ranges::range_value_t<Range>, CharT>
constexpr BasicStaticString (std::from_range_t, Range &&rg) noexcept
 Constructs from a range using std::from_range_t (C++23).
 
constexpr BasicStaticString (std::initializer_list< CharT > ilist) noexcept
 Constructs from an initializer list.
 
 BasicStaticString (std::nullptr_t)=delete
 Explicitly delete construction from nullptr.
 
constexpr BasicStaticString (const BasicStaticString &) noexcept=default
 
constexpr BasicStaticString (BasicStaticString &&) noexcept=default
 
template<size_t OtherCapacity>
requires (OtherCapacity < StrCapacity)
constexpr BasicStaticString (const BasicStaticString< OtherCapacity, CharT, Traits > &other) noexcept
 Copy constructor from smaller capacity string.
 
template<size_t OtherCapacity>
requires (OtherCapacity < StrCapacity)
constexpr BasicStaticString (BasicStaticString< OtherCapacity, CharT, Traits > &&other) noexcept
 Move constructor from smaller capacity string.
 
constexpr BasicStaticString (const BasicStaticString &other, size_type pos, size_type count=npos) noexcept
 Substring copy constructor from same capacity string.
 
constexpr BasicStaticString (BasicStaticString &&other, size_type pos, size_type count=npos) noexcept
 Substring move constructor from same capacity string (C++23).
 
template<size_t OtherCapacity>
requires (OtherCapacity < StrCapacity)
constexpr BasicStaticString (const BasicStaticString< OtherCapacity, CharT, Traits > &other, size_type pos, size_type count=npos) noexcept
 Substring copy constructor from smaller capacity string.
 
template<size_t OtherCapacity>
requires (OtherCapacity < StrCapacity)
constexpr BasicStaticString (BasicStaticString< OtherCapacity, CharT, Traits > &&other, size_type pos, size_type count=npos) noexcept
 Substring move constructor from smaller capacity string (C++23).
 
constexpr ~BasicStaticString () noexcept=default
 
constexpr BasicStaticStringoperator= (const BasicStaticString &) noexcept=default
 
constexpr BasicStaticStringoperator= (BasicStaticString &&) noexcept=default
 
template<size_t OtherCapacity>
requires (OtherCapacity < StrCapacity)
constexpr BasicStaticStringoperator= (const BasicStaticString< OtherCapacity, CharT, Traits > &other) noexcept
 Copy assignment from smaller capacity string.
 
template<size_t OtherCapacity>
requires (OtherCapacity < StrCapacity)
constexpr BasicStaticStringoperator= (BasicStaticString< OtherCapacity, CharT, Traits > &&other) noexcept
 Move assignment from smaller capacity string.
 
constexpr BasicStaticStringoperator= (std::basic_string_view< CharT, Traits > sv) noexcept
 Assigns from a string_view.
 
constexpr BasicStaticStringoperator= (const CharT *str) noexcept
 Assigns from a null-terminated C string.
 
constexpr void Clear () noexcept
 Clears the string content.
 
constexpr BasicStaticStringInsert (size_type pos, std::basic_string_view< CharT, Traits > sv) noexcept
 Inserts a string_view at position.
 
constexpr BasicStaticStringInsert (size_type pos, size_type count, CharT ch) noexcept
 Inserts count copies of character at position..
 
template<std::ranges::input_range Range>
requires std::convertible_to<std::ranges::range_value_t<Range>, CharT>
constexpr BasicStaticStringInsertRange (size_type pos, Range &&rg) noexcept
 Inserts characters from a range at position.
 
constexpr BasicStaticStringErase (size_type pos=0, size_type count=npos) noexcept
 Erases characters from pos to pos + count.
 
constexpr void PushBack (CharT ch) noexcept
 Appends a character.
 
constexpr void PopBack () noexcept
 Removes the last character.
 
constexpr BasicStaticStringAppend (std::basic_string_view< CharT, Traits > sv) noexcept
 Appends a string_view.
 
constexpr BasicStaticStringAppend (size_type count, CharT ch) noexcept
 Appends count copies of character ch.
 
constexpr BasicStaticStringAppend (const CharT *str) noexcept
 Appends a null-terminated C string.
 
template<std::ranges::input_range Range>
requires std::convertible_to<std::ranges::range_value_t<Range>, CharT>
constexpr BasicStaticStringAppendRange (Range &&rg) noexcept
 Appends characters from a range.
 
constexpr BasicStaticStringReplace (size_type pos, size_type count, std::basic_string_view< CharT, Traits > sv) noexcept
 Replaces characters in range [pos, pos + count) with string_view.
 
constexpr BasicStaticStringReplace (size_type pos, size_type count, size_type count2, CharT ch) noexcept
 Replaces characters in range [pos, pos + count) with count2 copies of ch.
 
template<std::ranges::input_range Range>
requires std::convertible_to<std::ranges::range_value_t<Range>, CharT>
constexpr BasicStaticStringReplaceWithRange (size_type pos, size_type count, Range &&rg) noexcept
 Replaces characters in range [pos, pos + count) with characters from a range.
 
constexpr size_type Copy (CharT *dest, size_type count, size_type pos=0) const noexcept
 Copies characters to a buffer.
 
constexpr void Resize (size_type count, CharT ch=CharT{}) noexcept
 Resizes the string.
 
constexpr void Swap (BasicStaticString &other) noexcept
 Swaps contents with another BasicStaticString.
 
constexpr BasicStaticStringAssign (std::basic_string_view< CharT, Traits > sv) noexcept
 Assigns a string_view.
 
constexpr BasicStaticStringAssign (const CharT *str) noexcept
 Assigns a null-terminated C string.
 
constexpr BasicStaticStringAssign (size_type count, CharT ch) noexcept
 Assigns count copies of character ch.
 
template<std::ranges::input_range Range>
requires std::convertible_to<std::ranges::range_value_t<Range>, CharT>
constexpr BasicStaticStringAssignRange (Range &&rg) noexcept
 Assigns characters from a range.
 
constexpr BasicStaticString Substr (size_type pos=0, size_type count=npos) const noexcept
 Returns a substring.
 
constexpr int Compare (std::basic_string_view< CharT, Traits > other) const noexcept
 Compares with another string.
 
template<size_t OtherCapacity>
constexpr int Compare (const BasicStaticString< OtherCapacity, CharT, Traits > &other) const noexcept
 Compares with another BasicStaticString.
 
constexpr size_type Find (std::basic_string_view< CharT, Traits > sv, size_type pos=0) const noexcept
 Finds first occurrence of substring.
 
constexpr size_type Find (CharT ch, size_type pos=0) const noexcept
 Finds first occurrence of character.
 
constexpr size_type RFind (std::basic_string_view< CharT, Traits > sv, size_type pos=npos) const noexcept
 Finds last occurrence of substring.
 
constexpr size_type RFind (CharT ch, size_type pos=npos) const noexcept
 Finds last occurrence of character.
 
constexpr size_type FindFirstOf (std::basic_string_view< CharT, Traits > sv, size_type pos=0) const noexcept
 Finds first occurrence of any character in sv.
 
constexpr size_type FindLastOf (std::basic_string_view< CharT, Traits > sv, size_type pos=npos) const noexcept
 Finds last occurrence of any character in sv.
 
constexpr size_type FindFirstNotOf (std::basic_string_view< CharT, Traits > sv, size_type pos=0) const noexcept
 Finds first character not in sv.
 
constexpr size_type FindLastNotOf (std::basic_string_view< CharT, Traits > sv, size_type pos=npos) const noexcept
 Finds last character not in sv.
 
constexpr BasicStaticStringoperator+= (std::basic_string_view< CharT, Traits > sv) noexcept
 Appends a string_view.
 
constexpr BasicStaticStringoperator+= (CharT ch) noexcept
 Appends a character.
 
constexpr BasicStaticStringoperator+= (const CharT *str) noexcept
 Appends a null-terminated C string.
 
constexpr reference operator[] (size_type pos) noexcept
 Accesses character at specified position.
 
constexpr const_reference operator[] (size_type pos) const noexcept
 Accesses character at specified position (const).
 
constexpr operator std::basic_string_view< CharT, Traits > () const noexcept
 Converts to string_view.
 
template<size_t OtherCapacity>
constexpr bool operator== (const BasicStaticString< OtherCapacity, CharT, Traits > &other) const noexcept
 
constexpr bool operator== (std::basic_string_view< CharT, Traits > other) const noexcept
 
constexpr bool operator== (const CharT *other) const noexcept
 
template<size_t OtherCapacity>
requires (StrCapacity > 0)
constexpr auto operator<=> (const BasicStaticString< OtherCapacity, CharT, Traits > &other) const noexcept -> std::strong_ordering
 
constexpr auto operator<=> (std::basic_string_view< CharT, Traits > other) const noexcept -> std::strong_ordering
 
constexpr auto operator<=> (const CharT *other) const noexcept -> std::strong_ordering
 
constexpr bool Empty () const noexcept
 Checks if the string is empty.
 
constexpr bool StartsWith (std::basic_string_view< CharT, Traits > sv) const noexcept
 Checks if string starts with prefix.
 
constexpr bool StartsWith (CharT ch) const noexcept
 Checks if string starts with character.
 
constexpr bool EndsWith (std::basic_string_view< CharT, Traits > sv) const noexcept
 Checks if string ends with suffix.
 
constexpr bool EndsWith (CharT ch) const noexcept
 Checks if string ends with character.
 
constexpr bool Contains (std::basic_string_view< CharT, Traits > sv) const noexcept
 Checks if string contains substring.
 
constexpr bool Contains (CharT ch) const noexcept
 Checks if string contains character.
 
constexpr size_type Size () const noexcept
 Returns the number of characters.
 
constexpr size_type Length () const noexcept
 Returns the number of characters.
 
constexpr size_type RemainingCapacity () const noexcept
 Returns the remaining capacity.
 
constexpr reference At (size_type pos) noexcept
 Accesses character at specified position with bounds checking.
 
constexpr const_reference At (size_type pos) const noexcept
 Accesses character at specified position with bounds checking (const).
 
constexpr reference Front () noexcept
 Accesses the first character.
 
constexpr const_reference Front () const noexcept
 Accesses the first character (const).
 
constexpr reference Back () noexcept
 Accesses the last character.
 
constexpr const_reference Back () const noexcept
 Accesses the last character (const).
 
constexpr pointer Data () noexcept
 Returns pointer to the underlying character array.
 
constexpr const_pointer Data () const noexcept
 Returns pointer to the underlying character array (const).
 
constexpr const_pointer CStr () const noexcept
 Returns null-terminated C string.
 
constexpr std::basic_string_view< CharT, Traits > View () const noexcept
 Returns a string_view of the content.
 
constexpr iterator begin () noexcept
 
constexpr const_iterator begin () const noexcept
 
constexpr const_iterator cbegin () const noexcept
 
constexpr iterator end () noexcept
 
constexpr const_iterator end () const noexcept
 
constexpr const_iterator cend () const noexcept
 
constexpr reverse_iterator rbegin () noexcept
 
constexpr const_reverse_iterator rbegin () const noexcept
 
constexpr const_reverse_iterator crbegin () const noexcept
 
constexpr reverse_iterator rend () noexcept
 
constexpr const_reverse_iterator rend () const noexcept
 
constexpr const_reverse_iterator crend () const noexcept
 
template<size_t N>
requires (N <= StrCapacity + 1)
constexpr BasicStaticString (const CharT(&str)[N]) noexcept
 
template<std::ranges::input_range Range>
requires std::convertible_to<std::ranges::range_value_t<Range>, CharT>
constexpr auto InsertRange (size_type pos, Range &&rg) noexcept -> BasicStaticString &
 
template<std::ranges::input_range Range>
requires std::convertible_to<std::ranges::range_value_t<Range>, CharT>
constexpr auto AppendRange (Range &&rg) noexcept -> BasicStaticString &
 
template<std::ranges::input_range Range>
requires std::convertible_to<std::ranges::range_value_t<Range>, CharT>
constexpr auto ReplaceWithRange (size_type pos, size_type count, Range &&rg) noexcept -> BasicStaticString &
 
template<std::ranges::input_range Range>
requires std::convertible_to<std::ranges::range_value_t<Range>, CharT>
constexpr auto AssignRange (Range &&rg) noexcept -> BasicStaticString &
 
template<size_t OtherCapacity>
requires (OtherCapacity < StrCapacity)
constexpr auto operator= (const BasicStaticString< OtherCapacity, CharT, Traits > &other) noexcept -> BasicStaticString &
 
template<size_t OtherCapacity>
requires (OtherCapacity < StrCapacity)
constexpr auto operator= (BasicStaticString< OtherCapacity, CharT, Traits > &&other) noexcept -> BasicStaticString &
 

Static Public Member Functions

static constexpr size_type MaxSize () noexcept
 Returns the maximum possible number of characters.
 
static constexpr size_type Capacity () noexcept
 Returns the capacity.
 

Static Public Attributes

static constexpr size_type npos = static_cast<size_type>(-1)
 

Detailed Description

template<size_t StrCapacity, typename CharT, typename Traits = std::char_traits<CharT>>
requires (StrCapacity > 0)
class helios::container::BasicStaticString< StrCapacity, CharT, Traits >

A fixed-capacity string class that owns its storage.

Similar to std::string_view but mutable and owning, with a compile-time fixed capacity. Provides all operations of std::string_view plus mutation operations. Does not allocate heap memory.

Template Parameters
StrCapacityMaximum number of characters (excluding null terminator)
CharTCharacter type
TraitsCharacter traits type

Definition at line 34 of file static_string.hpp.

Member Typedef Documentation

◆ const_iterator

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
using helios::container::BasicStaticString< StrCapacity, CharT, Traits >::const_iterator = const CharT*

Definition at line 44 of file static_string.hpp.

◆ const_pointer

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
using helios::container::BasicStaticString< StrCapacity, CharT, Traits >::const_pointer = const CharT*

Definition at line 40 of file static_string.hpp.

◆ const_reference

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
using helios::container::BasicStaticString< StrCapacity, CharT, Traits >::const_reference = const CharT&

Definition at line 42 of file static_string.hpp.

◆ const_reverse_iterator

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
using helios::container::BasicStaticString< StrCapacity, CharT, Traits >::const_reverse_iterator = std::reverse_iterator<const_iterator>

Definition at line 46 of file static_string.hpp.

◆ difference_type

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
using helios::container::BasicStaticString< StrCapacity, CharT, Traits >::difference_type = ptrdiff_t

Definition at line 48 of file static_string.hpp.

◆ iterator

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
using helios::container::BasicStaticString< StrCapacity, CharT, Traits >::iterator = CharT*

Definition at line 43 of file static_string.hpp.

◆ pointer

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
using helios::container::BasicStaticString< StrCapacity, CharT, Traits >::pointer = CharT*

Definition at line 39 of file static_string.hpp.

◆ reference

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
using helios::container::BasicStaticString< StrCapacity, CharT, Traits >::reference = CharT&

Definition at line 41 of file static_string.hpp.

◆ reverse_iterator

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
using helios::container::BasicStaticString< StrCapacity, CharT, Traits >::reverse_iterator = std::reverse_iterator<iterator>

Definition at line 45 of file static_string.hpp.

◆ size_type

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
using helios::container::BasicStaticString< StrCapacity, CharT, Traits >::size_type = size_t

Definition at line 47 of file static_string.hpp.

◆ traits_type

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
using helios::container::BasicStaticString< StrCapacity, CharT, Traits >::traits_type = Traits

Definition at line 37 of file static_string.hpp.

◆ value_type

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
using helios::container::BasicStaticString< StrCapacity, CharT, Traits >::value_type = CharT

Definition at line 38 of file static_string.hpp.

Constructor & Destructor Documentation

◆ BasicStaticString() [1/19]

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
constexpr helios::container::BasicStaticString< StrCapacity, CharT, Traits >::BasicStaticString ( )
inlineconstexprnoexcept

Default constructor. Creates an empty string.

Definition at line 55 of file static_string.hpp.

55{ data_[0] = CharT{}; }

◆ BasicStaticString() [2/19]

template<size_t StrCapacity, typename CharT , typename Traits >
requires (StrCapacity > 0)
constexpr helios::container::BasicStaticString< StrCapacity, CharT, Traits >::BasicStaticString ( std::basic_string_view< CharT, Traits >  sv)
explicitconstexprnoexcept

Constructs from a string_view.

Warning
Triggers assertion if sv.size() > StrCapacity.
Parameters
svSource string view

Definition at line 805 of file static_string.hpp.

806 {
807 HELIOS_ASSERT(sv.size() <= StrCapacity, "String view size exceeds capacity!");
808 const size_type copy_len = std::min(sv.size(), StrCapacity);
809 Traits::copy(data_.data(), sv.data(), copy_len);
810 size_ = copy_len;
811 data_[size_] = CharT{};
812}
#define HELIOS_ASSERT(condition,...)
Assertion macro that aborts execution in debug builds.
Definition assert.hpp:140

◆ BasicStaticString() [3/19]

template<size_t StrCapacity, typename CharT , typename Traits >
requires (StrCapacity > 0)
constexpr helios::container::BasicStaticString< StrCapacity, CharT, Traits >::BasicStaticString ( std::basic_string_view< CharT, Traits >  sv,
size_type  pos,
size_type  count = npos 
)
explicitconstexprnoexcept

Constructs a substring from a string_view with position and count.

Warning
Triggers assertion if (pos + count) > sv.size() or count > StrCapacity.
Parameters
svSource string view
posStarting position in the view
countNumber of characters to copy (default: all remaining)

Definition at line 816 of file static_string.hpp.

817 {
818 HELIOS_ASSERT(pos <= sv.size(), "Position out of range!");
819 const size_type substr_len = std::min(count, sv.size() - pos);
820 HELIOS_ASSERT(substr_len <= StrCapacity, "Substring size exceeds capacity!");
821 Traits::copy(data_.data(), sv.data() + pos, substr_len);
822 size_ = substr_len;
823 data_[size_] = CharT{};
824}

◆ BasicStaticString() [4/19]

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
constexpr helios::container::BasicStaticString< StrCapacity, CharT, Traits >::BasicStaticString ( const CharT *  str)
inlineexplicitconstexprnoexcept

Constructs from a null-terminated C string.

Warning
Triggers assertion if string length > StrCapacity.
Parameters
strSource C string

Definition at line 79 of file static_string.hpp.

80 : BasicStaticString(std::basic_string_view<CharT, Traits>(str)) {}
constexpr BasicStaticString() noexcept
Default constructor. Creates an empty string.

◆ BasicStaticString() [5/19]

template<size_t StrCapacity, typename CharT , typename Traits >
requires (StrCapacity > 0)
constexpr helios::container::BasicStaticString< StrCapacity, CharT, Traits >::BasicStaticString ( size_type  count,
CharT  ch 
)
constexprnoexcept

Constructs from count copies of character ch.

Warning
Triggers assertion if count > StrCapacity.
Parameters
countNumber of characters
chCharacter to repeat

Definition at line 841 of file static_string.hpp.

841 {
842 HELIOS_ASSERT(count <= StrCapacity, "Count exceeds capacity!");
843 std::ranges::fill_n(data_.begin(), count, ch);
844 size_ = count;
845 data_[size_] = CharT{};
846}

◆ BasicStaticString() [6/19]

template<size_t StrCapacity, typename CharT , typename Traits >
requires (StrCapacity > 0)
constexpr helios::container::BasicStaticString< StrCapacity, CharT, Traits >::BasicStaticString ( const CharT *  str,
size_type  len 
)
constexprnoexcept

Constructs from a pointer and length.

Warning
Triggers assertion if len > StrCapacity.
Parameters
strSource string pointer
lenLength of the string

Definition at line 850 of file static_string.hpp.

850 {
851 HELIOS_ASSERT(len <= StrCapacity, "Length exceeds capacity!");
852 Traits::copy(data_.data(), str, len);
853 size_ = len;
854 data_[size_] = CharT{};
855}

◆ BasicStaticString() [7/19]

template<size_t StrCapacity, typename CharT , typename Traits >
requires (StrCapacity > 0)
template<std::input_iterator InputIt>
requires (StrCapacity > 0)
constexpr helios::container::BasicStaticString< StrCapacity, CharT, Traits >::BasicStaticString ( InputIt  first,
InputIt  last 
)
constexprnoexcept

Constructs from an iterator range.

Warning
Triggers assertion if distance(first, last) > StrCapacity.
Template Parameters
InputItInput iterator type
Parameters
firstBeginning of range
lastEnd of range

Definition at line 860 of file static_string.hpp.

860 {
861 size_type count = 0;
862 for (auto it = first; it != last && count < StrCapacity; ++it, ++count) {
863 data_[count] = *it;
864 }
865 size_ = count;
866 data_[size_] = CharT{};
867}

◆ BasicStaticString() [8/19]

template<size_t StrCapacity, typename CharT , typename Traits >
requires std::convertible_to<std::ranges::range_value_t<Range>, CharT>
template<std::ranges::input_range Range>
requires std::convertible_to<std::ranges::range_value_t<Range>, CharT>
constexpr helios::container::BasicStaticString< StrCapacity, CharT, Traits >::BasicStaticString ( std::from_range_t  ,
Range &&  rg 
)
constexprnoexcept

Constructs from a range using std::from_range_t (C++23).

Warning
Triggers assertion if range size > StrCapacity.
Template Parameters
RangeRange type
Parameters
rgRange to construct from

Definition at line 873 of file static_string.hpp.

873 {
874 size_type count = 0;
875 for (auto&& ch : rg) {
876 if (count >= StrCapacity)
877 break;
878 data_[count++] = static_cast<CharT>(ch);
879 }
880 size_ = count;
881 data_[size_] = CharT{};
882}

◆ BasicStaticString() [9/19]

template<size_t StrCapacity, typename CharT , typename Traits >
requires (StrCapacity > 0)
constexpr helios::container::BasicStaticString< StrCapacity, CharT, Traits >::BasicStaticString ( std::initializer_list< CharT >  ilist)
constexprnoexcept

Constructs from an initializer list.

Warning
Triggers assertion if ilist.size() > StrCapacity.
Parameters
ilistInitializer list

Definition at line 886 of file static_string.hpp.

887 {
888 HELIOS_ASSERT(ilist.size() <= StrCapacity, "Initializer list size exceeds capacity!");
889 Traits::copy(data_.data(), ilist.begin(), ilist.size());
890 size_ = ilist.size();
891 data_[size_] = CharT{};
892}

◆ BasicStaticString() [10/19]

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
helios::container::BasicStaticString< StrCapacity, CharT, Traits >::BasicStaticString ( std::nullptr_t  )
delete

Explicitly delete construction from nullptr.

◆ BasicStaticString() [11/19]

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
constexpr helios::container::BasicStaticString< StrCapacity, CharT, Traits >::BasicStaticString ( const BasicStaticString< StrCapacity, CharT, Traits > &  )
constexprdefaultnoexcept

◆ BasicStaticString() [12/19]

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
constexpr helios::container::BasicStaticString< StrCapacity, CharT, Traits >::BasicStaticString ( BasicStaticString< StrCapacity, CharT, Traits > &&  )
constexprdefaultnoexcept

◆ BasicStaticString() [13/19]

template<size_t StrCapacity, typename CharT , typename Traits >
requires (OtherCapacity < StrCapacity)
template<size_t OtherCapacity>
requires (OtherCapacity < StrCapacity)
constexpr helios::container::BasicStaticString< StrCapacity, CharT, Traits >::BasicStaticString ( const BasicStaticString< OtherCapacity, CharT, Traits > &  other)
explicitconstexprnoexcept

Copy constructor from smaller capacity string.

Warning
Triggers assertion if other.Size() > StrCapacity.
Template Parameters
OtherCapacityStrCapacity of source string (must be less than StrCapacity)
Parameters
otherSource string with smaller capacity

Definition at line 1335 of file static_string.hpp.

1336 {
1337 HELIOS_ASSERT(other.Size() <= StrCapacity, "Source string size exceeds capacity!");
1338 Traits::copy(data_.data(), other.Data(), other.Size());
1339 size_ = other.Size();
1340 data_[size_] = CharT{};
1341}

◆ BasicStaticString() [14/19]

template<size_t StrCapacity, typename CharT , typename Traits >
requires (OtherCapacity < StrCapacity)
template<size_t OtherCapacity>
requires (OtherCapacity < StrCapacity)
constexpr helios::container::BasicStaticString< StrCapacity, CharT, Traits >::BasicStaticString ( BasicStaticString< OtherCapacity, CharT, Traits > &&  other)
explicitconstexprnoexcept

Move constructor from smaller capacity string.

Warning
Triggers assertion if other.Size() > StrCapacity.
Template Parameters
OtherCapacityStrCapacity of source string (must be less than StrCapacity)
Parameters
otherSource string with smaller capacity

Definition at line 1347 of file static_string.hpp.

1348 {
1349 HELIOS_ASSERT(other.Size() <= StrCapacity, "Source string size exceeds capacity!");
1350 Traits::copy(data_.data(), other.Data(), other.Size());
1351 size_ = other.Size();
1352 data_[size_] = CharT{};
1353}

◆ BasicStaticString() [15/19]

template<size_t StrCapacity, typename CharT , typename Traits >
requires (StrCapacity > 0)
constexpr helios::container::BasicStaticString< StrCapacity, CharT, Traits >::BasicStaticString ( const BasicStaticString< StrCapacity, CharT, Traits > &  other,
size_type  pos,
size_type  count = npos 
)
constexprnoexcept

Substring copy constructor from same capacity string.

Warning
Triggers assertion if (pos + count) > other.Size() or count > StrCapacity.
Parameters
otherSource string
posStarting position (default: 0)
countNumber of characters to copy (default: all remaining)

Definition at line 1309 of file static_string.hpp.

1310 {
1311 HELIOS_ASSERT(pos <= other.Size(), "Position out of range!");
1312 const size_type substr_len = std::min(count, other.Size() - pos);
1313 HELIOS_ASSERT(substr_len <= StrCapacity, "Substring size exceeds capacity!");
1314 Traits::copy(data_.data(), other.Data() + pos, substr_len);
1315 size_ = substr_len;
1316 data_[size_] = CharT{};
1317}

◆ BasicStaticString() [16/19]

template<size_t StrCapacity, typename CharT , typename Traits >
requires (StrCapacity > 0)
constexpr helios::container::BasicStaticString< StrCapacity, CharT, Traits >::BasicStaticString ( BasicStaticString< StrCapacity, CharT, Traits > &&  other,
size_type  pos,
size_type  count = npos 
)
constexprnoexcept

Substring move constructor from same capacity string (C++23).

Warning
Triggers assertion if (pos + count) > other.Size() or count > StrCapacity.
Parameters
otherSource string
posStarting position (default: 0)
countNumber of characters to copy (default: all remaining)

Definition at line 1321 of file static_string.hpp.

1322 {
1323 HELIOS_ASSERT(pos <= other.Size(), "Position out of range!");
1324 const size_type substr_len = std::min(count, other.Size() - pos);
1325 HELIOS_ASSERT(substr_len <= StrCapacity, "Substring size exceeds capacity!");
1326 Traits::copy(data_.data(), other.Data() + pos, substr_len);
1327 size_ = substr_len;
1328 data_[size_] = CharT{};
1329}

◆ BasicStaticString() [17/19]

template<size_t StrCapacity, typename CharT , typename Traits >
requires (OtherCapacity < StrCapacity)
template<size_t OtherCapacity>
requires (OtherCapacity < StrCapacity)
constexpr helios::container::BasicStaticString< StrCapacity, CharT, Traits >::BasicStaticString ( const BasicStaticString< OtherCapacity, CharT, Traits > &  other,
size_type  pos,
size_type  count = npos 
)
constexprnoexcept

Substring copy constructor from smaller capacity string.

Warning
Triggers assertion if (pos + count) > other.Size() or count > StrCapacity.
Template Parameters
OtherCapacityStrCapacity of source string (must be less than StrCapacity)
Parameters
otherSource string with smaller capacity
posStarting position (default: 0)
countNumber of characters to copy (default: all remaining)

Definition at line 1359 of file static_string.hpp.

1360 {
1361 HELIOS_ASSERT(pos <= other.Size(), "Position out of range!");
1362 const size_type substr_len = std::min(count, other.Size() - pos);
1363 HELIOS_ASSERT(substr_len <= StrCapacity, "Substring size exceeds capacity!");
1364 Traits::copy(data_.data(), other.Data() + pos, substr_len);
1365 size_ = substr_len;
1366 data_[size_] = CharT{};
1367}

◆ BasicStaticString() [18/19]

template<size_t StrCapacity, typename CharT , typename Traits >
requires (OtherCapacity < StrCapacity)
template<size_t OtherCapacity>
requires (OtherCapacity < StrCapacity)
constexpr helios::container::BasicStaticString< StrCapacity, CharT, Traits >::BasicStaticString ( BasicStaticString< OtherCapacity, CharT, Traits > &&  other,
size_type  pos,
size_type  count = npos 
)
constexprnoexcept

Substring move constructor from smaller capacity string (C++23).

Warning
Triggers assertion if (pos + count) > other.Size() or count > StrCapacity.
Template Parameters
OtherCapacityStrCapacity of source string (must be less than StrCapacity)
Parameters
otherSource string with smaller capacity
posStarting position (default: 0)
countNumber of characters to copy (default: all remaining)

Definition at line 1373 of file static_string.hpp.

1374 {
1375 HELIOS_ASSERT(pos <= other.Size(), "Position out of range!");
1376 const size_type substr_len = std::min(count, other.Size() - pos);
1377 HELIOS_ASSERT(substr_len <= StrCapacity, "Substring size exceeds capacity!");
1378 Traits::copy(data_.data(), other.Data() + pos, substr_len);
1379 size_ = substr_len;
1380 data_[size_] = CharT{};
1381}

◆ ~BasicStaticString()

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
constexpr helios::container::BasicStaticString< StrCapacity, CharT, Traits >::~BasicStaticString ( )
constexprdefaultnoexcept

◆ BasicStaticString() [19/19]

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
template<size_t N>
requires (N <= StrCapacity + 1)
constexpr helios::container::BasicStaticString< StrCapacity, CharT, Traits >::BasicStaticString ( const CharT(&)  str[N])
constexprnoexcept

Definition at line 830 of file static_string.hpp.

830 {
831 // N includes null terminator for string literals
832 const size_type copy_len = (N > 0 && str[N - 1] == CharT{}) ? N - 1 : N;
833 HELIOS_ASSERT(copy_len <= StrCapacity, "String literal size exceeds capacity!");
834 Traits::copy(data_.data(), str, copy_len);
835 size_ = copy_len;
836 data_[size_] = CharT{};
837}

Member Function Documentation

◆ Append() [1/3]

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
constexpr BasicStaticString & helios::container::BasicStaticString< StrCapacity, CharT, Traits >::Append ( const CharT *  str)
inlineconstexprnoexcept

Appends a null-terminated C string.

Warning
Triggers assertion if resulting size > capacity().
Parameters
strC string to append
Returns
Reference to this

Definition at line 331 of file static_string.hpp.

331 {
332 return Append(std::basic_string_view<CharT, Traits>(str));
333 }
constexpr BasicStaticString & Append(std::basic_string_view< CharT, Traits > sv) noexcept
Appends a string_view.

◆ Append() [2/3]

template<size_t StrCapacity, typename CharT , typename Traits >
requires (StrCapacity > 0)
constexpr auto helios::container::BasicStaticString< StrCapacity, CharT, Traits >::Append ( size_type  count,
CharT  ch 
)
constexprnoexcept

Appends count copies of character ch.

Warning
Triggers assertion if resulting size > capacity().
Parameters
countNumber of characters
chCharacter to append
Returns
Reference to this

Definition at line 1039 of file static_string.hpp.

1040 {
1041 HELIOS_ASSERT(size_ + count <= StrCapacity, "Append would exceed capacity!");
1042 std::ranges::fill_n(data_.begin() + size_, count, ch);
1043 size_ += count;
1044 data_[size_] = CharT{};
1045 return *this;
1046}

◆ Append() [3/3]

template<size_t StrCapacity, typename CharT , typename Traits >
requires (StrCapacity > 0)
constexpr auto helios::container::BasicStaticString< StrCapacity, CharT, Traits >::Append ( std::basic_string_view< CharT, Traits >  sv)
constexprnoexcept

Appends a string_view.

Warning
Triggers assertion if resulting size > capacity().
Parameters
svString view to append
Returns
Reference to this

Definition at line 1028 of file static_string.hpp.

1029 {
1030 HELIOS_ASSERT(size_ + sv.size() <= StrCapacity, "Append would exceed capacity!");
1031 Traits::copy(data_.data() + size_, sv.data(), sv.size());
1032 size_ += sv.size();
1033 data_[size_] = CharT{};
1034 return *this;
1035}

◆ AppendRange() [1/2]

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
template<std::ranges::input_range Range>
requires std::convertible_to<std::ranges::range_value_t<Range>, CharT>
constexpr BasicStaticString & helios::container::BasicStaticString< StrCapacity, CharT, Traits >::AppendRange ( Range &&  rg)
constexprnoexcept

Appends characters from a range.

Warning
Triggers assertion if resulting size > capacity().
Template Parameters
RangeRange type
Parameters
rgRange to append
Returns
Reference to this

◆ AppendRange() [2/2]

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
template<std::ranges::input_range Range>
requires std::convertible_to<std::ranges::range_value_t<Range>, CharT>
constexpr auto helios::container::BasicStaticString< StrCapacity, CharT, Traits >::AppendRange ( Range &&  rg) -> BasicStaticString&
constexprnoexcept

Definition at line 1052 of file static_string.hpp.

1052 {
1053 for (auto&& ch : rg) {
1054 PushBack(static_cast<CharT>(ch));
1055 }
1056 return *this;
1057}
constexpr void PushBack(CharT ch) noexcept
Appends a character.

◆ Assign() [1/3]

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
constexpr BasicStaticString & helios::container::BasicStaticString< StrCapacity, CharT, Traits >::Assign ( const CharT *  str)
inlineconstexprnoexcept

Assigns a null-terminated C string.

Warning
Triggers assertion if string length > capacity().
Parameters
strC string to assign
Returns
Reference to this

Definition at line 419 of file static_string.hpp.

419 {
420 return Assign(std::basic_string_view<CharT, Traits>(str));
421 }
constexpr BasicStaticString & Assign(std::basic_string_view< CharT, Traits > sv) noexcept
Assigns a string_view.

◆ Assign() [2/3]

template<size_t StrCapacity, typename CharT , typename Traits >
requires (StrCapacity > 0)
constexpr auto helios::container::BasicStaticString< StrCapacity, CharT, Traits >::Assign ( size_type  count,
CharT  ch 
)
constexprnoexcept

Assigns count copies of character ch.

Warning
Triggers assertion if count > capacity().
Parameters
countNumber of characters
chCharacter to assign
Returns
Reference to this

Definition at line 1187 of file static_string.hpp.

1188 {
1189 HELIOS_ASSERT(count <= StrCapacity, "Count exceeds capacity!");
1190 std::ranges::fill_n(data_.begin(), count, ch);
1191 size_ = count;
1192 data_[size_] = CharT{};
1193 return *this;
1194}

◆ Assign() [3/3]

template<size_t StrCapacity, typename CharT , typename Traits >
requires (StrCapacity > 0)
constexpr auto helios::container::BasicStaticString< StrCapacity, CharT, Traits >::Assign ( std::basic_string_view< CharT, Traits >  sv)
constexprnoexcept

Assigns a string_view.

Warning
Triggers assertion if sv.size() > capacity().
Parameters
svString view to assign
Returns
Reference to this

Definition at line 1176 of file static_string.hpp.

1177 {
1178 HELIOS_ASSERT(sv.size() <= StrCapacity, "String view size exceeds capacity!");
1179 Traits::copy(data_.data(), sv.data(), sv.size());
1180 size_ = sv.size();
1181 data_[size_] = CharT{};
1182 return *this;
1183}

◆ AssignRange() [1/2]

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
template<std::ranges::input_range Range>
requires std::convertible_to<std::ranges::range_value_t<Range>, CharT>
constexpr BasicStaticString & helios::container::BasicStaticString< StrCapacity, CharT, Traits >::AssignRange ( Range &&  rg)
constexprnoexcept

Assigns characters from a range.

Warning
Triggers assertion if range size > capacity().
Template Parameters
RangeRange type
Parameters
rgRange to assign from
Returns
Reference to this

◆ AssignRange() [2/2]

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
template<std::ranges::input_range Range>
requires std::convertible_to<std::ranges::range_value_t<Range>, CharT>
constexpr auto helios::container::BasicStaticString< StrCapacity, CharT, Traits >::AssignRange ( Range &&  rg) -> BasicStaticString&
constexprnoexcept

Definition at line 1200 of file static_string.hpp.

1200 {
1201 Clear();
1202 return AppendRange(std::forward<Range>(rg));
1203}
constexpr BasicStaticString & AppendRange(Range &&rg) noexcept
Appends characters from a range.
constexpr void Clear() noexcept
Clears the string content.

◆ At() [1/2]

template<size_t StrCapacity, typename CharT , typename Traits >
requires (StrCapacity > 0)
constexpr auto helios::container::BasicStaticString< StrCapacity, CharT, Traits >::At ( size_type  pos) const
constexprnoexcept

Accesses character at specified position with bounds checking (const).

Warning
Triggers assertion if pos >= size().
Parameters
posPosition of the character
Returns
Const reference to the character

Definition at line 1236 of file static_string.hpp.

1236 {
1237 HELIOS_ASSERT(pos < size_, "Position out of range!");
1238 return data_[pos];
1239}

◆ At() [2/2]

template<size_t StrCapacity, typename CharT , typename Traits >
requires (StrCapacity > 0)
constexpr auto helios::container::BasicStaticString< StrCapacity, CharT, Traits >::At ( size_type  pos)
constexprnoexcept

Accesses character at specified position with bounds checking.

Warning
Triggers assertion if pos >= size().
Parameters
posPosition of the character
Returns
Reference to the character

Definition at line 1229 of file static_string.hpp.

1229 {
1230 HELIOS_ASSERT(pos < size_, "Position out of range!");
1231 return data_[pos];
1232}

◆ Back() [1/2]

template<size_t StrCapacity, typename CharT , typename Traits >
requires (StrCapacity > 0)
constexpr auto helios::container::BasicStaticString< StrCapacity, CharT, Traits >::Back ( ) const
constexprnoexcept

Accesses the last character (const).

Warning
Triggers assertion if string is empty.
Returns
Const reference to the last character

Definition at line 1264 of file static_string.hpp.

1264 {
1265 HELIOS_ASSERT(!Empty(), "String is empty!");
1266 return data_[size_ - 1];
1267}
constexpr bool Empty() const noexcept
Checks if the string is empty.

◆ Back() [2/2]

template<size_t StrCapacity, typename CharT , typename Traits >
requires (StrCapacity > 0)
constexpr auto helios::container::BasicStaticString< StrCapacity, CharT, Traits >::Back ( )
constexprnoexcept

Accesses the last character.

Warning
Triggers assertion if string is empty.
Returns
Reference to the last character

Definition at line 1257 of file static_string.hpp.

1257 {
1258 HELIOS_ASSERT(!Empty(), "String is empty!");
1259 return data_[size_ - 1];
1260}

◆ begin() [1/2]

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
constexpr const_iterator helios::container::BasicStaticString< StrCapacity, CharT, Traits >::begin ( ) const
inlineconstexprnoexcept

Definition at line 783 of file static_string.hpp.

783{ return data_.data(); }

◆ begin() [2/2]

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
constexpr iterator helios::container::BasicStaticString< StrCapacity, CharT, Traits >::begin ( )
inlineconstexprnoexcept

Definition at line 782 of file static_string.hpp.

782{ return data_.data(); }

◆ Capacity()

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
static constexpr size_type helios::container::BasicStaticString< StrCapacity, CharT, Traits >::Capacity ( )
inlinestaticconstexprnoexcept

Returns the capacity.

Returns
StrCapacity

Definition at line 703 of file static_string.hpp.

703{ return StrCapacity; }

◆ cbegin()

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
constexpr const_iterator helios::container::BasicStaticString< StrCapacity, CharT, Traits >::cbegin ( ) const
inlineconstexprnoexcept

Definition at line 784 of file static_string.hpp.

784{ return data_.data(); }

◆ cend()

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
constexpr const_iterator helios::container::BasicStaticString< StrCapacity, CharT, Traits >::cend ( ) const
inlineconstexprnoexcept

Definition at line 788 of file static_string.hpp.

788{ return data_.data() + size_; }

◆ Clear()

template<size_t StrCapacity, typename CharT , typename Traits >
requires (StrCapacity > 0)
constexpr void helios::container::BasicStaticString< StrCapacity, CharT, Traits >::Clear ( )
constexprnoexcept

Clears the string content.

Definition at line 912 of file static_string.hpp.

912 {
913 size_ = 0;
914 data_[0] = CharT{};
915}

◆ Compare() [1/2]

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
template<size_t OtherCapacity>
constexpr int helios::container::BasicStaticString< StrCapacity, CharT, Traits >::Compare ( const BasicStaticString< OtherCapacity, CharT, Traits > &  other) const
inlineconstexprnoexcept

Compares with another BasicStaticString.

Template Parameters
OtherCapacityStrCapacity of the other string
Parameters
otherString to compare with
Returns
Negative if less, zero if equal, positive if greater

Definition at line 468 of file static_string.hpp.

468 {
469 return View().compare(other.View());
470 }
constexpr std::basic_string_view< CharT, Traits > View() const noexcept
Returns a string_view of the content.

◆ Compare() [2/2]

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
constexpr int helios::container::BasicStaticString< StrCapacity, CharT, Traits >::Compare ( std::basic_string_view< CharT, Traits >  other) const
inlineconstexprnoexcept

Compares with another string.

Parameters
otherString to compare with
Returns
Negative if less, zero if equal, positive if greater

Definition at line 457 of file static_string.hpp.

457 {
458 return View().compare(other);
459 }

◆ Contains() [1/2]

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
constexpr bool helios::container::BasicStaticString< StrCapacity, CharT, Traits >::Contains ( CharT  ch) const
inlineconstexprnoexcept

Checks if string contains character.

Parameters
chCharacter to search for
Returns
True if string contains ch

Definition at line 679 of file static_string.hpp.

679{ return View().find(ch) != npos; }
static constexpr size_type npos

◆ Contains() [2/2]

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
constexpr bool helios::container::BasicStaticString< StrCapacity, CharT, Traits >::Contains ( std::basic_string_view< CharT, Traits >  sv) const
inlineconstexprnoexcept

Checks if string contains substring.

Parameters
svSubstring to search for
Returns
True if string contains sv

Definition at line 670 of file static_string.hpp.

670 {
671 return View().find(sv) != npos;
672 }

◆ Copy()

template<size_t StrCapacity, typename CharT , typename Traits >
requires (StrCapacity > 0)
constexpr auto helios::container::BasicStaticString< StrCapacity, CharT, Traits >::Copy ( CharT *  dest,
size_type  count,
size_type  pos = 0 
) const
constexprnoexcept

Copies characters to a buffer.

Warning
Triggers assertion if pos > Size().
Parameters
destDestination buffer
countMaximum number of characters to copy
posStarting position
Returns
Number of characters copied

Definition at line 1148 of file static_string.hpp.

1149 {
1150 HELIOS_ASSERT(pos <= size_, "Position out of range!");
1151 const size_type copy_count = std::min(count, size_ - pos);
1152 Traits::copy(dest, data_.data() + pos, copy_count);
1153 return copy_count;
1154}

◆ crbegin()

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
constexpr const_reverse_iterator helios::container::BasicStaticString< StrCapacity, CharT, Traits >::crbegin ( ) const
inlineconstexprnoexcept

Definition at line 792 of file static_string.hpp.

792{ return const_reverse_iterator(end()); }
constexpr iterator end() noexcept
std::reverse_iterator< const_iterator > const_reverse_iterator

◆ crend()

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
constexpr const_reverse_iterator helios::container::BasicStaticString< StrCapacity, CharT, Traits >::crend ( ) const
inlineconstexprnoexcept

Definition at line 796 of file static_string.hpp.

796{ return const_reverse_iterator(begin()); }
constexpr iterator begin() noexcept

◆ CStr()

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
constexpr const_pointer helios::container::BasicStaticString< StrCapacity, CharT, Traits >::CStr ( ) const
inlineconstexprnoexcept

Returns null-terminated C string.

Returns
Null-terminated character array

Definition at line 772 of file static_string.hpp.

772{ return data_.data(); }

◆ Data() [1/2]

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
constexpr const_pointer helios::container::BasicStaticString< StrCapacity, CharT, Traits >::Data ( ) const
inlineconstexprnoexcept

Returns pointer to the underlying character array (const).

Returns
Const pointer to the character array

Definition at line 766 of file static_string.hpp.

766{ return data_.data(); }

◆ Data() [2/2]

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
constexpr pointer helios::container::BasicStaticString< StrCapacity, CharT, Traits >::Data ( )
inlineconstexprnoexcept

Returns pointer to the underlying character array.

Returns
Pointer to the character array

Definition at line 760 of file static_string.hpp.

760{ return data_.data(); }

◆ Empty()

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
constexpr bool helios::container::BasicStaticString< StrCapacity, CharT, Traits >::Empty ( ) const
inlineconstexprnoexcept

Checks if the string is empty.

Returns
True if Size() == 0

Definition at line 631 of file static_string.hpp.

631{ return size_ == 0; }

◆ end() [1/2]

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
constexpr const_iterator helios::container::BasicStaticString< StrCapacity, CharT, Traits >::end ( ) const
inlineconstexprnoexcept

Definition at line 787 of file static_string.hpp.

787{ return data_.data() + size_; }

◆ end() [2/2]

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
constexpr iterator helios::container::BasicStaticString< StrCapacity, CharT, Traits >::end ( )
inlineconstexprnoexcept

Definition at line 786 of file static_string.hpp.

786{ return data_.data() + size_; }

◆ EndsWith() [1/2]

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
constexpr bool helios::container::BasicStaticString< StrCapacity, CharT, Traits >::EndsWith ( CharT  ch) const
inlineconstexprnoexcept

Checks if string ends with character.

Parameters
chCharacter to check
Returns
True if string ends with ch

Definition at line 663 of file static_string.hpp.

663{ return !Empty() && Back() == ch; }
constexpr reference Back() noexcept
Accesses the last character.

◆ EndsWith() [2/2]

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
constexpr bool helios::container::BasicStaticString< StrCapacity, CharT, Traits >::EndsWith ( std::basic_string_view< CharT, Traits >  sv) const
inlineconstexprnoexcept

Checks if string ends with suffix.

Parameters
svSuffix to check
Returns
True if string ends with sv

Definition at line 654 of file static_string.hpp.

654 {
655 return View().ends_with(sv);
656 }

◆ Erase()

template<size_t StrCapacity, typename CharT , typename Traits >
requires (StrCapacity > 0)
constexpr auto helios::container::BasicStaticString< StrCapacity, CharT, Traits >::Erase ( size_type  pos = 0,
size_type  count = npos 
)
constexprnoexcept

Erases characters from pos to pos + count.

Warning
Triggers assertion if pos > Size().
Parameters
posStarting position
countNumber of characters to erase (default: all remaining)
Returns
Reference to this

Definition at line 998 of file static_string.hpp.

999 {
1000 HELIOS_ASSERT(pos <= size_, "Position out of range!");
1001 const size_type erase_count = std::min(count, size_ - pos);
1002 const size_type remaining = size_ - pos - erase_count;
1003 if (remaining > 0) {
1004 Traits::move(data_.data() + pos, data_.data() + pos + erase_count, remaining);
1005 }
1006 size_ -= erase_count;
1007 data_[size_] = CharT{};
1008 return *this;
1009}

◆ explicit()

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
template<size_t N>
requires (N <= StrCapacity + 1)
constexpr helios::container::BasicStaticString< StrCapacity, CharT, Traits >::explicit ( false  ) )[N] const &
constexprnoexcept

Constructs from a character array of known size.

Warning
Triggers assertion if N-1 > StrCapacity (excluding null terminator).
Template Parameters
NSize of the character array
Parameters
strSource character array

◆ Find() [1/2]

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
constexpr size_type helios::container::BasicStaticString< StrCapacity, CharT, Traits >::Find ( CharT  ch,
size_type  pos = 0 
) const
inlineconstexprnoexcept

Finds first occurrence of character.

Parameters
chCharacter to search for
posStarting position
Returns
Position of first occurrence, or npos if not found

Definition at line 488 of file static_string.hpp.

488{ return View().find(ch, pos); }

◆ Find() [2/2]

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
constexpr size_type helios::container::BasicStaticString< StrCapacity, CharT, Traits >::Find ( std::basic_string_view< CharT, Traits >  sv,
size_type  pos = 0 
) const
inlineconstexprnoexcept

Finds first occurrence of substring.

Parameters
svSubstring to search for
posStarting position
Returns
Position of first occurrence, or npos if not found

Definition at line 478 of file static_string.hpp.

478 {
479 return View().find(sv, pos);
480 }

◆ FindFirstNotOf()

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
constexpr size_type helios::container::BasicStaticString< StrCapacity, CharT, Traits >::FindFirstNotOf ( std::basic_string_view< CharT, Traits >  sv,
size_type  pos = 0 
) const
inlineconstexprnoexcept

Finds first character not in sv.

Parameters
svCharacters to exclude
posStarting position
Returns
Position of first non-matching character, or npos if not found

Definition at line 539 of file static_string.hpp.

540 {
541 return View().find_first_not_of(sv, pos);
542 }

◆ FindFirstOf()

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
constexpr size_type helios::container::BasicStaticString< StrCapacity, CharT, Traits >::FindFirstOf ( std::basic_string_view< CharT, Traits >  sv,
size_type  pos = 0 
) const
inlineconstexprnoexcept

Finds first occurrence of any character in sv.

Parameters
svCharacters to search for
posStarting position
Returns
Position of first occurrence, or npos if not found

Definition at line 517 of file static_string.hpp.

518 {
519 return View().find_first_of(sv, pos);
520 }

◆ FindLastNotOf()

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
constexpr size_type helios::container::BasicStaticString< StrCapacity, CharT, Traits >::FindLastNotOf ( std::basic_string_view< CharT, Traits >  sv,
size_type  pos = npos 
) const
inlineconstexprnoexcept

Finds last character not in sv.

Parameters
svCharacters to exclude
posStarting position (searches backwards from here)
Returns
Position of last non-matching character, or npos if not found

Definition at line 550 of file static_string.hpp.

551 {
552 return View().find_last_not_of(sv, pos);
553 }

◆ FindLastOf()

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
constexpr size_type helios::container::BasicStaticString< StrCapacity, CharT, Traits >::FindLastOf ( std::basic_string_view< CharT, Traits >  sv,
size_type  pos = npos 
) const
inlineconstexprnoexcept

Finds last occurrence of any character in sv.

Parameters
svCharacters to search for
posStarting position (searches backwards from here)
Returns
Position of last occurrence, or npos if not found

Definition at line 528 of file static_string.hpp.

529 {
530 return View().find_last_of(sv, pos);
531 }

◆ Front() [1/2]

template<size_t StrCapacity, typename CharT , typename Traits >
requires (StrCapacity > 0)
constexpr auto helios::container::BasicStaticString< StrCapacity, CharT, Traits >::Front ( ) const
constexprnoexcept

Accesses the first character (const).

Warning
Triggers assertion if string is empty.
Returns
Const reference to the first character

Definition at line 1250 of file static_string.hpp.

1250 {
1251 HELIOS_ASSERT(!Empty(), "String is empty!");
1252 return data_[0];
1253}

◆ Front() [2/2]

template<size_t StrCapacity, typename CharT , typename Traits >
requires (StrCapacity > 0)
constexpr auto helios::container::BasicStaticString< StrCapacity, CharT, Traits >::Front ( )
constexprnoexcept

Accesses the first character.

Warning
Triggers assertion if string is empty.
Returns
Reference to the first character

Definition at line 1243 of file static_string.hpp.

1243 {
1244 HELIOS_ASSERT(!Empty(), "String is empty!");
1245 return data_[0];
1246}

◆ Insert() [1/2]

template<size_t StrCapacity, typename CharT , typename Traits >
requires (StrCapacity > 0)
constexpr auto helios::container::BasicStaticString< StrCapacity, CharT, Traits >::Insert ( size_type  pos,
size_type  count,
CharT  ch 
)
constexprnoexcept

Inserts count copies of character at position..

Warning
Triggers assertion if pos > Size() or resulting size > capacity()
Parameters
posPosition to insert at
countNumber of characters
chCharacter to insert
Returns
Reference to this

Definition at line 939 of file static_string.hpp.

940 {
941 HELIOS_ASSERT(pos <= size_, "Position out of range!");
942 HELIOS_ASSERT(size_ + count <= StrCapacity, "Insert would exceed capacity!");
943
944 if (pos < size_) {
945 Traits::move(data_.data() + pos + count, data_.data() + pos, size_ - pos);
946 }
947
948 std::ranges::fill_n(data_.begin() + pos, count, ch);
949 size_ += count;
950 data_[size_] = CharT{};
951 return *this;
952}

◆ Insert() [2/2]

template<size_t StrCapacity, typename CharT , typename Traits >
requires (StrCapacity > 0)
constexpr auto helios::container::BasicStaticString< StrCapacity, CharT, Traits >::Insert ( size_type  pos,
std::basic_string_view< CharT, Traits >  sv 
)
constexprnoexcept

Inserts a string_view at position.

Warning
Triggers assertion if pos > Size() or resulting size > capacity().
Parameters
posPosition to insert at
svString view to insert
Returns
Reference to this

Definition at line 919 of file static_string.hpp.

921 {
922 HELIOS_ASSERT(pos <= size_, "Position out of range!");
923 HELIOS_ASSERT(size_ + sv.size() <= StrCapacity, "Insert would exceed capacity!");
924
925 // Move existing characters to make room
926 if (pos < size_) {
927 Traits::move(data_.data() + pos + sv.size(), data_.data() + pos, size_ - pos);
928 }
929
930 // Copy new characters
931 Traits::copy(data_.data() + pos, sv.data(), sv.size());
932 size_ += sv.size();
933 data_[size_] = CharT{};
934 return *this;
935}

◆ InsertRange() [1/2]

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
template<std::ranges::input_range Range>
requires std::convertible_to<std::ranges::range_value_t<Range>, CharT>
constexpr BasicStaticString & helios::container::BasicStaticString< StrCapacity, CharT, Traits >::InsertRange ( size_type  pos,
Range &&  rg 
)
constexprnoexcept

Inserts characters from a range at position.

Warning
Triggers assertion if pos > Size() or resulting size > capacity().
Template Parameters
RangeRange type
Parameters
posPosition to insert at
rgRange to insert
Returns
Reference to this

◆ InsertRange() [2/2]

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
template<std::ranges::input_range Range>
requires std::convertible_to<std::ranges::range_value_t<Range>, CharT>
constexpr auto helios::container::BasicStaticString< StrCapacity, CharT, Traits >::InsertRange ( size_type  pos,
Range &&  rg 
) -> BasicStaticString&
constexprnoexcept

Definition at line 958 of file static_string.hpp.

959 {
960 HELIOS_ASSERT(pos <= size_, "Position out of range!");
961
962 // Calculate range size if possible
963 size_type range_size = 0;
964 if constexpr (std::ranges::sized_range<Range>) {
965 range_size = static_cast<size_type>(std::ranges::size(rg));
966 HELIOS_ASSERT(size_ + range_size <= StrCapacity, "Insert would exceed capacity!");
967
968 // Move existing characters
969 if (pos < size_) {
970 Traits::move(data_.data() + pos + range_size, data_.data() + pos, size_ - pos);
971 }
972
973 // Copy from range
974 auto dest = data_.begin() + pos;
975 for (auto&& ch : rg) {
976 *dest++ = static_cast<CharT>(ch);
977 }
978 size_ += range_size;
979 } else {
980 // For non-sized ranges, insert one by one
981 auto insert_pos = pos;
982 for (auto&& ch : rg) {
983 HELIOS_ASSERT(size_ < StrCapacity, "Insert would exceed capacity!");
984 if (insert_pos < size_) {
985 Traits::move(data_.data() + insert_pos + 1, data_.data() + insert_pos, size_ - insert_pos);
986 }
987 data_[insert_pos++] = static_cast<CharT>(ch);
988 ++size_;
989 }
990 }
991
992 data_[size_] = CharT{};
993 return *this;
994}

◆ Length()

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
constexpr size_type helios::container::BasicStaticString< StrCapacity, CharT, Traits >::Length ( ) const
inlineconstexprnoexcept

Returns the number of characters.

Returns
Number of characters (excluding null terminator)

Definition at line 691 of file static_string.hpp.

691{ return size_; }

◆ MaxSize()

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
static constexpr size_type helios::container::BasicStaticString< StrCapacity, CharT, Traits >::MaxSize ( )
inlinestaticconstexprnoexcept

Returns the maximum possible number of characters.

Returns
StrCapacity

Definition at line 697 of file static_string.hpp.

697{ return StrCapacity; }

◆ operator std::basic_string_view< CharT, Traits >()

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
constexpr helios::container::BasicStaticString< StrCapacity, CharT, Traits >::operator std::basic_string_view< CharT, Traits > ( ) const
inlineconstexprnoexcept

Converts to string_view.

Returns
String view of the content

Definition at line 599 of file static_string.hpp.

599 {
600 return std::basic_string_view<CharT, Traits>(data_.data(), size_);
601 }

◆ operator+=() [1/3]

template<size_t StrCapacity, typename CharT , typename Traits >
requires (StrCapacity > 0)
constexpr auto helios::container::BasicStaticString< StrCapacity, CharT, Traits >::operator+= ( CharT  ch)
constexprnoexcept

Appends a character.

Warning
Triggers assertion if resulting size > capacity().
Parameters
chCharacter to append
Returns
Reference to this

Definition at line 1207 of file static_string.hpp.

1207 {
1208 PushBack(ch);
1209 return *this;
1210}

◆ operator+=() [2/3]

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
constexpr BasicStaticString & helios::container::BasicStaticString< StrCapacity, CharT, Traits >::operator+= ( const CharT *  str)
inlineconstexprnoexcept

Appends a null-terminated C string.

Warning
Triggers assertion if resulting size > capacity().
Parameters
strC string to append
Returns
Reference to this

Definition at line 577 of file static_string.hpp.

577{ return Append(str); }

◆ operator+=() [3/3]

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
constexpr BasicStaticString & helios::container::BasicStaticString< StrCapacity, CharT, Traits >::operator+= ( std::basic_string_view< CharT, Traits >  sv)
inlineconstexprnoexcept

Appends a string_view.

Warning
Triggers assertion if resulting size > capacity().
Parameters
svString view to append
Returns
Reference to this

Definition at line 561 of file static_string.hpp.

561{ return Append(sv); }

◆ operator<=>() [1/3]

template<size_t StrCapacity, typename CharT , typename Traits >
requires (StrCapacity > 0)
template<size_t OtherCapacity>
requires (StrCapacity > 0)
constexpr auto helios::container::BasicStaticString< StrCapacity, CharT, Traits >::operator<=> ( const BasicStaticString< OtherCapacity, CharT, Traits > &  other) const -> std::strong_ordering
constexprnoexcept

Definition at line 1281 of file static_string.hpp.

1282 {
1283 const auto result = View().compare(other.View());
1284 if (result < 0) {
1285 return std::strong_ordering::less;
1286 }
1287 if (result > 0) {
1288 return std::strong_ordering::greater;
1289 }
1290 return std::strong_ordering::equal;
1291}

◆ operator<=>() [2/3]

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
constexpr auto helios::container::BasicStaticString< StrCapacity, CharT, Traits >::operator<=> ( const CharT *  other) const -> std::strong_ordering
inlineconstexprnoexcept

Definition at line 623 of file static_string.hpp.

623 {
624 return *this <=> std::basic_string_view<CharT, Traits>(other);
625 }

◆ operator<=>() [3/3]

template<size_t StrCapacity, typename CharT , typename Traits >
requires (StrCapacity > 0)
constexpr auto helios::container::BasicStaticString< StrCapacity, CharT, Traits >::operator<=> ( std::basic_string_view< CharT, Traits >  other) const -> std::strong_ordering
constexprnoexcept

Definition at line 1295 of file static_string.hpp.

1296 {
1297 const auto result = View().compare(other);
1298 if (result < 0) {
1299 return std::strong_ordering::less;
1300 }
1301 if (result > 0) {
1302 return std::strong_ordering::greater;
1303 }
1304 return std::strong_ordering::equal;
1305}

◆ operator=() [1/8]

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
constexpr BasicStaticString & helios::container::BasicStaticString< StrCapacity, CharT, Traits >::operator= ( BasicStaticString< StrCapacity, CharT, Traits > &&  )
constexprdefaultnoexcept

◆ operator=() [2/8]

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
template<size_t OtherCapacity>
requires (OtherCapacity < StrCapacity)
constexpr BasicStaticString & helios::container::BasicStaticString< StrCapacity, CharT, Traits >::operator= ( BasicStaticString< OtherCapacity, CharT, Traits > &&  other)
constexprnoexcept

Move assignment from smaller capacity string.

Warning
Triggers assertion if other.Size() > StrCapacity.
Template Parameters
OtherCapacityStrCapacity of source string (must be less than StrCapacity)
Parameters
otherSource string with smaller capacity
Returns
Reference to this

◆ operator=() [3/8]

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
template<size_t OtherCapacity>
requires (OtherCapacity < StrCapacity)
constexpr auto helios::container::BasicStaticString< StrCapacity, CharT, Traits >::operator= ( BasicStaticString< OtherCapacity, CharT, Traits > &&  other) -> BasicStaticString&
constexprnoexcept

Definition at line 1400 of file static_string.hpp.

1401 {
1402 HELIOS_ASSERT(other.Size() <= StrCapacity, "Source string size exceeds capacity!");
1403 Traits::copy(data_.data(), other.Data(), other.Size());
1404 size_ = other.Size();
1405 data_[size_] = CharT{};
1406 return *this;
1407}

◆ operator=() [4/8]

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
constexpr BasicStaticString & helios::container::BasicStaticString< StrCapacity, CharT, Traits >::operator= ( const BasicStaticString< StrCapacity, CharT, Traits > &  )
constexprdefaultnoexcept

◆ operator=() [5/8]

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
template<size_t OtherCapacity>
requires (OtherCapacity < StrCapacity)
constexpr BasicStaticString & helios::container::BasicStaticString< StrCapacity, CharT, Traits >::operator= ( const BasicStaticString< OtherCapacity, CharT, Traits > &  other)
constexprnoexcept

Copy assignment from smaller capacity string.

Warning
Triggers assertion if other.Size() > StrCapacity.
Template Parameters
OtherCapacityStrCapacity of source string (must be less than StrCapacity)
Parameters
otherSource string with smaller capacity
Returns
Reference to this

◆ operator=() [6/8]

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
template<size_t OtherCapacity>
requires (OtherCapacity < StrCapacity)
constexpr auto helios::container::BasicStaticString< StrCapacity, CharT, Traits >::operator= ( const BasicStaticString< OtherCapacity, CharT, Traits > &  other) -> BasicStaticString&
constexprnoexcept

Definition at line 1387 of file static_string.hpp.

1388 {
1389 HELIOS_ASSERT(other.Size() <= StrCapacity, "Source string size exceeds capacity!");
1390 Traits::copy(data_.data(), other.Data(), other.Size());
1391 size_ = other.Size();
1392 data_[size_] = CharT{};
1393 return *this;
1394}

◆ operator=() [7/8]

template<size_t StrCapacity, typename CharT , typename Traits >
requires (StrCapacity > 0)
constexpr auto helios::container::BasicStaticString< StrCapacity, CharT, Traits >::operator= ( const CharT *  str)
constexprnoexcept

Assigns from a null-terminated C string.

Warning
Triggers assertion if string length > StrCapacity.
Parameters
strSource C string
Returns
Reference to this

Definition at line 904 of file static_string.hpp.

905 {
906 Assign(str);
907 return *this;
908}

◆ operator=() [8/8]

template<size_t StrCapacity, typename CharT , typename Traits >
requires (StrCapacity > 0)
constexpr auto helios::container::BasicStaticString< StrCapacity, CharT, Traits >::operator= ( std::basic_string_view< CharT, Traits >  sv)
constexprnoexcept

Assigns from a string_view.

Warning
Triggers assertion if sv.size() > StrCapacity.
Parameters
svSource string view
Returns
Reference to this

Definition at line 896 of file static_string.hpp.

897 {
898 Assign(sv);
899 return *this;
900}

◆ operator==() [1/3]

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
template<size_t OtherCapacity>
constexpr bool helios::container::BasicStaticString< StrCapacity, CharT, Traits >::operator== ( const BasicStaticString< OtherCapacity, CharT, Traits > &  other) const
inlineconstexprnoexcept

Definition at line 604 of file static_string.hpp.

604 {
605 return View() == other.View();
606 }

◆ operator==() [2/3]

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
constexpr bool helios::container::BasicStaticString< StrCapacity, CharT, Traits >::operator== ( const CharT *  other) const
inlineconstexprnoexcept

Definition at line 612 of file static_string.hpp.

612 {
613 return View() == std::basic_string_view<CharT, Traits>(other);
614 }

◆ operator==() [3/3]

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
constexpr bool helios::container::BasicStaticString< StrCapacity, CharT, Traits >::operator== ( std::basic_string_view< CharT, Traits >  other) const
inlineconstexprnoexcept

Definition at line 608 of file static_string.hpp.

608 {
609 return View() == other;
610 }

◆ operator[]() [1/2]

template<size_t StrCapacity, typename CharT , typename Traits >
requires (StrCapacity > 0)
constexpr auto helios::container::BasicStaticString< StrCapacity, CharT, Traits >::operator[] ( size_type  pos) const
constexprnoexcept

Accesses character at specified position (const).

Warning
Triggers assertion if pos >= size().
Parameters
posPosition of the character
Returns
Const reference to the character

Definition at line 1221 of file static_string.hpp.

1222 {
1223 HELIOS_ASSERT(pos < size_, "Position out of range!");
1224 return data_[pos];
1225}

◆ operator[]() [2/2]

template<size_t StrCapacity, typename CharT , typename Traits >
requires (StrCapacity > 0)
constexpr auto helios::container::BasicStaticString< StrCapacity, CharT, Traits >::operator[] ( size_type  pos)
constexprnoexcept

Accesses character at specified position.

Warning
Triggers assertion if pos >= size().
Parameters
posPosition of the character
Returns
Reference to the character

Definition at line 1214 of file static_string.hpp.

1214 {
1215 HELIOS_ASSERT(pos < size_, "Position out of range!");
1216 return data_[pos];
1217}

◆ PopBack()

template<size_t StrCapacity, typename CharT , typename Traits >
requires (StrCapacity > 0)
constexpr void helios::container::BasicStaticString< StrCapacity, CharT, Traits >::PopBack ( )
constexprnoexcept

Removes the last character.

Warning
Triggers assertion if string is empty.

Definition at line 1021 of file static_string.hpp.

1021 {
1022 HELIOS_ASSERT(!Empty(), "Cannot PopBack: string is empty!");
1023 data_[--size_] = CharT{};
1024}

◆ PushBack()

template<size_t StrCapacity, typename CharT , typename Traits >
requires (StrCapacity > 0)
constexpr void helios::container::BasicStaticString< StrCapacity, CharT, Traits >::PushBack ( CharT  ch)
constexprnoexcept

Appends a character.

Warning
Triggers assertion if Size() >= capacity().
Parameters
chCharacter to append

Definition at line 1013 of file static_string.hpp.

1013 {
1014 HELIOS_ASSERT(size_ < StrCapacity, "Cannot PushBack: string is at capacity!");
1015 data_[size_++] = ch;
1016 data_[size_] = CharT{};
1017}

◆ rbegin() [1/2]

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
constexpr const_reverse_iterator helios::container::BasicStaticString< StrCapacity, CharT, Traits >::rbegin ( ) const
inlineconstexprnoexcept

Definition at line 791 of file static_string.hpp.

791{ return const_reverse_iterator(end()); }

◆ rbegin() [2/2]

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
constexpr reverse_iterator helios::container::BasicStaticString< StrCapacity, CharT, Traits >::rbegin ( )
inlineconstexprnoexcept

Definition at line 790 of file static_string.hpp.

790{ return reverse_iterator(end()); }
std::reverse_iterator< iterator > reverse_iterator

◆ RemainingCapacity()

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
constexpr size_type helios::container::BasicStaticString< StrCapacity, CharT, Traits >::RemainingCapacity ( ) const
inlineconstexprnoexcept

Returns the remaining capacity.

Returns
StrCapacity - Size()

Definition at line 709 of file static_string.hpp.

709{ return StrCapacity - size_; }

◆ rend() [1/2]

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
constexpr const_reverse_iterator helios::container::BasicStaticString< StrCapacity, CharT, Traits >::rend ( ) const
inlineconstexprnoexcept

Definition at line 795 of file static_string.hpp.

795{ return const_reverse_iterator(begin()); }

◆ rend() [2/2]

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
constexpr reverse_iterator helios::container::BasicStaticString< StrCapacity, CharT, Traits >::rend ( )
inlineconstexprnoexcept

Definition at line 794 of file static_string.hpp.

794{ return reverse_iterator(begin()); }

◆ Replace() [1/2]

template<size_t StrCapacity, typename CharT , typename Traits >
requires (StrCapacity > 0)
constexpr auto helios::container::BasicStaticString< StrCapacity, CharT, Traits >::Replace ( size_type  pos,
size_type  count,
size_type  count2,
CharT  ch 
)
constexprnoexcept

Replaces characters in range [pos, pos + count) with count2 copies of ch.

Warning
Triggers assertion if pos > Size() or resulting size > capacity().
Parameters
posStarting position
countNumber of characters to replace
count2Number of replacement characters
chReplacement character
Returns
Reference to this

Definition at line 1085 of file static_string.hpp.

1086 {
1087 HELIOS_ASSERT(pos <= size_, "Position out of range!");
1088 const size_type replace_count = std::min(count, size_ - pos);
1089 const size_type new_size = size_ - replace_count + count2;
1090 HELIOS_ASSERT(new_size <= StrCapacity, "Replace would exceed capacity!");
1091
1092 const size_type tail_pos = pos + replace_count;
1093 const size_type tail_len = size_ - tail_pos;
1094 if (tail_len > 0 && count2 != replace_count) {
1095 Traits::move(data_.data() + pos + count2, data_.data() + tail_pos, tail_len);
1096 }
1097
1098 std::ranges::fill_n(data_.begin() + pos, count2, ch);
1099 size_ = new_size;
1100 data_[size_] = CharT{};
1101 return *this;
1102}

◆ Replace() [2/2]

template<size_t StrCapacity, typename CharT , typename Traits >
requires (StrCapacity > 0)
constexpr auto helios::container::BasicStaticString< StrCapacity, CharT, Traits >::Replace ( size_type  pos,
size_type  count,
std::basic_string_view< CharT, Traits >  sv 
)
constexprnoexcept

Replaces characters in range [pos, pos + count) with string_view.

Warning
Triggers assertion if pos > Size() or resulting size > capacity().
Parameters
posStarting position
countNumber of characters to replace
svReplacement string view
Returns
Reference to this

Definition at line 1061 of file static_string.hpp.

1063 {
1064 HELIOS_ASSERT(pos <= size_, "Position out of range!");
1065 const size_type replace_count = std::min(count, size_ - pos);
1066 const size_type new_size = size_ - replace_count + sv.size();
1067 HELIOS_ASSERT(new_size <= StrCapacity, "Replace would exceed capacity!");
1068
1069 // Move tail
1070 const size_type tail_pos = pos + replace_count;
1071 const size_type tail_len = size_ - tail_pos;
1072 if (tail_len > 0 && sv.size() != replace_count) {
1073 Traits::move(data_.data() + pos + sv.size(), data_.data() + tail_pos, tail_len);
1074 }
1075
1076 // Copy replacement
1077 Traits::copy(data_.data() + pos, sv.data(), sv.size());
1078 size_ = new_size;
1079 data_[size_] = CharT{};
1080 return *this;
1081}

◆ ReplaceWithRange() [1/2]

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
template<std::ranges::input_range Range>
requires std::convertible_to<std::ranges::range_value_t<Range>, CharT>
constexpr BasicStaticString & helios::container::BasicStaticString< StrCapacity, CharT, Traits >::ReplaceWithRange ( size_type  pos,
size_type  count,
Range &&  rg 
)
constexprnoexcept

Replaces characters in range [pos, pos + count) with characters from a range.

Warning
Triggers assertion if pos > Size() or resulting size > capacity().
Template Parameters
RangeRange type
Parameters
posStarting position
countNumber of characters to replace
rgRange of replacement characters
Returns
Reference to this

◆ ReplaceWithRange() [2/2]

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
template<std::ranges::input_range Range>
requires std::convertible_to<std::ranges::range_value_t<Range>, CharT>
constexpr auto helios::container::BasicStaticString< StrCapacity, CharT, Traits >::ReplaceWithRange ( size_type  pos,
size_type  count,
Range &&  rg 
) -> BasicStaticString&
constexprnoexcept

Definition at line 1108 of file static_string.hpp.

1110 {
1111 HELIOS_ASSERT(pos <= size_, "Position out of range!");
1112
1113 const size_type replace_count = std::min(count, size_ - pos);
1114
1115 if constexpr (std::ranges::sized_range<Range>) {
1116 const size_type range_size = static_cast<size_type>(std::ranges::size(rg));
1117 const size_type new_size = size_ - replace_count + range_size;
1118 HELIOS_ASSERT(new_size <= StrCapacity, "Replace would exceed capacity!");
1119
1120 const size_type tail_pos = pos + replace_count;
1121 const size_type tail_len = size_ - tail_pos;
1122 if (tail_len > 0 && range_size != replace_count) {
1123 Traits::move(data_.data() + pos + range_size, data_.data() + tail_pos, tail_len);
1124 }
1125
1126 auto dest = data_.begin() + pos;
1127 for (auto&& ch : rg) {
1128 *dest++ = static_cast<CharT>(ch);
1129 }
1130 size_ = new_size;
1131 } else {
1132 // For non-sized ranges, use temporary storage
1133 BasicStaticString temp;
1134 temp.Assign(View().substr(0, pos));
1135 temp.AppendRange(std::forward<Range>(rg));
1136 if (pos + replace_count < size_) {
1137 temp.Append(View().substr(pos + replace_count));
1138 }
1139 *this = std::move(temp);
1140 }
1141
1142 data_[size_] = CharT{};
1143 return *this;
1144}

◆ Resize()

template<size_t StrCapacity, typename CharT , typename Traits >
requires (StrCapacity > 0)
constexpr void helios::container::BasicStaticString< StrCapacity, CharT, Traits >::Resize ( size_type  count,
CharT  ch = CharT{} 
)
constexprnoexcept

Resizes the string.

Warning
Triggers assertion if count > capacity()
Parameters
countNew size
chCharacter to fill if expanding

Definition at line 1158 of file static_string.hpp.

1158 {
1159 HELIOS_ASSERT(count <= StrCapacity, "Resize count exceeds capacity!");
1160 if (count > size_) {
1161 std::ranges::fill_n(data_.begin() + size_, count - size_, ch);
1162 }
1163 size_ = count;
1164 data_[size_] = CharT{};
1165}

◆ RFind() [1/2]

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
constexpr size_type helios::container::BasicStaticString< StrCapacity, CharT, Traits >::RFind ( CharT  ch,
size_type  pos = npos 
) const
inlineconstexprnoexcept

Finds last occurrence of character.

Parameters
chCharacter to search for
posStarting position (searches backwards from here)
Returns
Position of last occurrence, or npos if not found

Definition at line 507 of file static_string.hpp.

507 {
508 return View().rfind(ch, pos);
509 }

◆ RFind() [2/2]

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
constexpr size_type helios::container::BasicStaticString< StrCapacity, CharT, Traits >::RFind ( std::basic_string_view< CharT, Traits >  sv,
size_type  pos = npos 
) const
inlineconstexprnoexcept

Finds last occurrence of substring.

Parameters
svSubstring to search for
posStarting position (searches backwards from here)
Returns
Position of last occurrence, or npos if not found

Definition at line 496 of file static_string.hpp.

497 {
498 return View().rfind(sv, pos);
499 }

◆ Size()

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
constexpr size_type helios::container::BasicStaticString< StrCapacity, CharT, Traits >::Size ( ) const
inlineconstexprnoexcept

Returns the number of characters.

Returns
Number of characters (excluding null terminator)

Definition at line 685 of file static_string.hpp.

685{ return size_; }

◆ StartsWith() [1/2]

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
constexpr bool helios::container::BasicStaticString< StrCapacity, CharT, Traits >::StartsWith ( CharT  ch) const
inlineconstexprnoexcept

Checks if string starts with character.

Parameters
chCharacter to check
Returns
True if string starts with ch

Definition at line 647 of file static_string.hpp.

647{ return !Empty() && Front() == ch; }
constexpr reference Front() noexcept
Accesses the first character.

◆ StartsWith() [2/2]

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
constexpr bool helios::container::BasicStaticString< StrCapacity, CharT, Traits >::StartsWith ( std::basic_string_view< CharT, Traits >  sv) const
inlineconstexprnoexcept

Checks if string starts with prefix.

Parameters
svPrefix to check
Returns
True if string starts with sv

Definition at line 638 of file static_string.hpp.

638 {
639 return View().starts_with(sv);
640 }

◆ Substr()

template<size_t StrCapacity, typename CharT , typename Traits >
requires (StrCapacity > 0)
constexpr auto helios::container::BasicStaticString< StrCapacity, CharT, Traits >::Substr ( size_type  pos = 0,
size_type  count = npos 
) const
constexprnoexcept

Returns a substring.

Warning
Triggers assertion if pos > Size().
Parameters
posStarting position
countNumber of characters (default: all remaining)
Returns
Substring as StaticString with same capacity

Definition at line 1271 of file static_string.hpp.

1272 {
1273 HELIOS_ASSERT(pos <= size_, "Position out of range!");
1274 const size_type substr_len = std::min(count, size_ - pos);
1275 return BasicStaticString(data_.data() + pos, substr_len);
1276}

◆ Swap()

template<size_t StrCapacity, typename CharT , typename Traits >
requires (StrCapacity > 0)
constexpr void helios::container::BasicStaticString< StrCapacity, CharT, Traits >::Swap ( BasicStaticString< StrCapacity, CharT, Traits > &  other)
constexprnoexcept

Swaps contents with another BasicStaticString.

Parameters
otherString to swap with

Definition at line 1169 of file static_string.hpp.

1169 {
1170 std::swap(data_, other.data_);
1171 std::swap(size_, other.size_);
1172}

◆ View()

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
constexpr std::basic_string_view< CharT, Traits > helios::container::BasicStaticString< StrCapacity, CharT, Traits >::View ( ) const
inlineconstexprnoexcept

Returns a string_view of the content.

Returns
String view of the content

Definition at line 778 of file static_string.hpp.

778 {
779 return std::basic_string_view<CharT, Traits>(data_.data(), size_);
780 }

Member Data Documentation

◆ npos

template<size_t StrCapacity, typename CharT , typename Traits = std::char_traits<CharT>>
constexpr size_type helios::container::BasicStaticString< StrCapacity, CharT, Traits >::npos = static_cast<size_type>(-1)
staticconstexpr

Definition at line 50 of file static_string.hpp.