xentara-utils v2.0.4
The Xentara Utility Library
Loading...
Searching...
No Matches
xentara::utils::string::BasicFixedString< Char, kSize, CharTraits > Class Template Reference

A string with a fixed size. More...

#include <xentara/utils/string/FixedString.hpp>

Public Types

using traits_type = CharTraits
 The character traits.
 
using value_type = Char
 The character type.
 
using size_type = std::size_t
 The type used for sizes.
 
using difference_type = std::ptrdiff_t
 The type used for distances.
 
using reference = value_type &
 A reference to an character.
 
using const_reference = const value_type &
 A const reference to an character.
 
using pointer = value_type *
 A pointer to an character.
 
using const_pointer = const value_type *
 A const pointer to an character.
 
using iterator = core::ContiguousIterator< pointer, BasicFixedString >
 An iterator.
 
using const_iterator = core::ContiguousIterator< const_pointer, BasicFixedString >
 A const iterator.
 
using reverse_iterator = std::reverse_iterator< iterator >
 An iterator for iterating in reverse order.
 
using const_reverse_iterator = std::reverse_iterator< const_iterator >
 A const iterator for iterating in reverse order.
 

Public Member Functions

Constructors
constexpr BasicFixedString () noexcept
 Default constructor.
 
constexpr BasicFixedString (const BasicFixedString &) noexcept=default
 Copy constructor.
 
constexpr BasicFixedString (UninitializedTag tag) noexcept
 Constructor for a string containing uninitialized characters.
 
constexpr BasicFixedString (FillTag tag, Char character) noexcept
 Constructor for a string filled with a specific character.
 
constexpr BasicFixedString (size_type count, Char character)
 Constructor for a string filled with a specific character, checking the size.
 
constexpr BasicFixedString (const Char *string, FillTag tag) noexcept
 Constructor that copies characters from an array.
 
constexpr BasicFixedString (const Char *string, size_type count)
 Constructor that copies characters from an array, checking the size.
 
constexpr BasicFixedString (const Char *string)
 Constructor that copies a null-terminated string.
 
template<std::input_iterator InputIterator>
constexpr BasicFixedString (InputIterator first, InputIterator last)
 Constructor that fills the string from a character sequence.
 
 BasicFixedString (std::initializer_list< Char > characters)
 Constructor that initializes the characters from an initializer list.
 
template<typename String >
requires (std::is_convertible_v<const String &, std::basic_string_view<Char, CharTraits>> && !std::is_convertible_v<const String &, const Char *>)
constexpr BasicFixedString (const String &string)
 Constructor that copies an arbitrary string.
 
template<typename String >
requires (std::is_convertible_v<const String &, std::basic_string_view<Char, CharTraits>> && !std::is_convertible_v<const String &, const Char *>)
constexpr BasicFixedString (const String &string, size_type position, FillTag tag)
 Constructor that copies a sub string of a string, up to a length of kSize characters.
 
template<typename String >
requires (std::is_convertible_v<const String &, std::basic_string_view<Char, CharTraits>> && !std::is_convertible_v<const String &, const Char *>)
constexpr BasicFixedString (const String &string, size_type position, size_type count)
 Constructor that copies a sub string of a string, up to a maximum length.
 
Assigning Values
constexpr auto operator= (const BasicFixedString &) noexcept -> BasicFixedString &=default
 Copy assignment operator.
 
constexpr auto operator= (const Char *string) -> BasicFixedString &
 Assignment operator for a null-terminated string.
 
constexpr auto operator= (std::initializer_list< Char > characters) -> BasicFixedString &
 Assignment operator for an initializer list.
 
template<typename String >
requires (std::is_convertible_v<const String &, std::basic_string_view<Char, CharTraits>> && !std::is_convertible_v<const String &, const Char *>)
constexpr auto operator= (const String &string) -> BasicFixedString &
 Assignment operator for an arbitrary string.
 
constexpr auto assign (FillTag tag, Char character) noexcept -> BasicFixedString &
 Fills the string with a specific character.
 
constexpr auto assign (size_type count, Char character) -> BasicFixedString &
 Fills the string with a specific character, checking the size.
 
constexpr auto assign (const BasicFixedString &string) noexcept -> BasicFixedString &
 Copies another fixed string of the same size.
 
constexpr auto assign (const Char *string, FillTag tag) noexcept -> BasicFixedString &
 Copies characters from an array.
 
constexpr auto assign (const Char *string, size_type count) -> BasicFixedString &
 Copies characters from an array, checking the size.
 
constexpr auto assign (const Char *string) -> BasicFixedString &
 Copies a null-terminated string.
 
template<std::input_iterator InputIterator>
constexpr auto assign (InputIterator first, InputIterator last) -> BasicFixedString &
 Copies a character range.
 
constexpr auto assign (std::initializer_list< Char > characters) -> BasicFixedString &
 Copies the characters from an initializer list.
 
template<typename String >
requires (std::is_convertible_v<const String &, std::basic_string_view<Char, CharTraits>> && !std::is_convertible_v<const String &, const Char *>)
constexpr auto assign (const String &string) -> BasicFixedString &
 Copies an arbitrary string.
 
template<typename String >
requires (std::is_convertible_v<const String &, std::basic_string_view<Char, CharTraits>> && !std::is_convertible_v<const String &, const Char *>)
constexpr auto assign (const String &string, size_type position) -> BasicFixedString &
 Copies a sub string of a string.
 
template<typename String >
requires (std::is_convertible_v<const String &, std::basic_string_view<Char, CharTraits>> && !std::is_convertible_v<const String &, const Char *>)
constexpr auto assign (const String &string, size_type position, FillTag tag) -> BasicFixedString &
 Copies a sub string of a string, up to a length of kSize characters.
 
template<typename String >
requires (std::is_convertible_v<const String &, std::basic_string_view<Char, CharTraits>> && !std::is_convertible_v<const String &, const Char *>)
constexpr auto assign (const String &string, size_type position, size_type count) -> BasicFixedString &
 Copies a sub string of a string, up to a maximum length.
 
Character Access
constexpr operator std::basic_string_view< Char, CharTraits > () const noexcept
 conversion to a string view
 
template<typename Allocator >
constexpr operator std::basic_string< Char, CharTraits, Allocator > () const noexcept
 conversion to an std::string
 
constexpr auto view () const noexcept -> std::basic_string_view< Char, CharTraits >
 Gets the data as a string view.
 
template<typename Allocator = std::allocator<Char>>
constexpr auto str (const Allocator &allocator=Allocator()) const noexcept -> std::basic_string< Char, CharTraits, Allocator >
 Gets the data as an std::string.
 
constexpr auto at (size_type index) const -> const_reference
 Accesses the character at a certain index.
 
constexpr auto at (size_type index) -> reference
 Accesses the character at a certain index.
 
constexpr auto operator[] (size_type index) const noexcept -> const_reference
 Subscript operator.
 
constexpr auto operator[] (size_type index) noexcept -> reference
 Subscript operator.
 
constexpr auto front () const noexcept -> const_reference
 Returns the first character.
 
constexpr auto front () noexcept -> reference
 Returns the first character.
 
constexpr auto back () const noexcept -> const_reference
 Returns the last character.
 
constexpr auto back () noexcept -> reference
 Returns the last character.
 
constexpr auto data () const noexcept -> const Char *
 Gets a pointer to the data.
 
constexpr auto data () noexcept -> Char *
 Gets a pointer to the data.
 
constexpr auto c_str () const noexcept -> const Char *
 Gets the data as a null terminated string.
 
Iterators
constexpr auto begin () noexcept -> iterator
 Creates a begin iterator.
 
constexpr auto begin () const noexcept -> const_iterator
 Creates a begin iterator.
 
constexpr auto cbegin () const noexcept -> const_iterator
 Creates a begin iterator.
 
constexpr auto end () noexcept -> iterator
 Creates an end iterator.
 
constexpr auto end () const noexcept -> const_iterator
 Creates an end iterator.
 
constexpr auto cend () const noexcept -> const_iterator
 Creates an end iterator.
 
constexpr auto rbegin () noexcept -> reverse_iterator
 Creates a reverse begin iterator.
 
constexpr auto rbegin () const noexcept -> const_reverse_iterator
 Creates a reverse begin iterator.
 
constexpr auto crbegin () const noexcept -> const_reverse_iterator
 Creates a reverse begin iterator.
 
constexpr auto rend () noexcept -> reverse_iterator
 Creates a reverse end iterator.
 
constexpr auto rend () const noexcept -> const_reverse_iterator
 Creates a reverse end iterator.
 
constexpr auto crend () const noexcept -> const_reverse_iterator
 Creates a reverse end iterator.
 
Finding Sub Strings
constexpr auto starts_with (std::basic_string_view< Char, CharTraits > string) const noexcept -> bool
 Checks whether the string starts with a certain text.
 
constexpr auto starts_with (Char character) const noexcept -> bool
 Checks whether the string starts with a certain character.
 
constexpr auto starts_with (const Char *string) const -> bool
 Checks whether the string starts with a certain text.
 
constexpr auto ends_with (std::basic_string_view< Char, CharTraits > string) const noexcept -> bool
 Checks whether the string ends with a certain text.
 
constexpr auto ends_with (Char character) const noexcept -> bool
 Checks whether the string ends with a certain character.
 
constexpr auto ends_with (const Char *string) const -> bool
 Checks whether the string ends with a certain text.
 

Static Public Attributes

static constexpr size_type npos
 Special size value used for automatically determined lengths.
 

Size and Capacity

constexpr auto empty () const noexcept -> bool
 Determines whether the string is empty.
 
constexpr auto size () const noexcept -> size_type
 Gets the size.
 
constexpr auto length () const noexcept -> size_type
 Alias for size()
 
constexpr auto capacity () const noexcept -> size_type
 Gets the capacity of the string.
 
static constexpr auto max_size () noexcept -> size_type
 Gets the maximum size.
 

Detailed Description

template<tools::CharType Char, std::size_t kSize, typename CharTraits = std::char_traits<Char>>
class xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >

A string with a fixed size.

Template Parameters
CharThe character type
kSizeThe size of the string
CharTraitsThe char traits used for interacting with the standard C++ library

Member Typedef Documentation

◆ const_iterator

template<tools::CharType Char, std::size_t kSize, typename CharTraits = std::char_traits<Char>>
using xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::const_iterator = core::ContiguousIterator<const_pointer, BasicFixedString>

A const iterator.

◆ const_pointer

template<tools::CharType Char, std::size_t kSize, typename CharTraits = std::char_traits<Char>>
using xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::const_pointer = const value_type *

A const pointer to an character.

◆ const_reference

template<tools::CharType Char, std::size_t kSize, typename CharTraits = std::char_traits<Char>>
using xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::const_reference = const value_type &

A const reference to an character.

◆ const_reverse_iterator

template<tools::CharType Char, std::size_t kSize, typename CharTraits = std::char_traits<Char>>
using xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::const_reverse_iterator = std::reverse_iterator<const_iterator>

A const iterator for iterating in reverse order.

◆ difference_type

template<tools::CharType Char, std::size_t kSize, typename CharTraits = std::char_traits<Char>>
using xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::difference_type = std::ptrdiff_t

The type used for distances.

◆ iterator

template<tools::CharType Char, std::size_t kSize, typename CharTraits = std::char_traits<Char>>
using xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::iterator = core::ContiguousIterator<pointer, BasicFixedString>

An iterator.

◆ pointer

template<tools::CharType Char, std::size_t kSize, typename CharTraits = std::char_traits<Char>>
using xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::pointer = value_type *

A pointer to an character.

◆ reference

template<tools::CharType Char, std::size_t kSize, typename CharTraits = std::char_traits<Char>>
using xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::reference = value_type &

A reference to an character.

◆ reverse_iterator

template<tools::CharType Char, std::size_t kSize, typename CharTraits = std::char_traits<Char>>
using xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::reverse_iterator = std::reverse_iterator<iterator>

An iterator for iterating in reverse order.

◆ size_type

template<tools::CharType Char, std::size_t kSize, typename CharTraits = std::char_traits<Char>>
using xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::size_type = std::size_t

The type used for sizes.

◆ traits_type

template<tools::CharType Char, std::size_t kSize, typename CharTraits = std::char_traits<Char>>
using xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::traits_type = CharTraits

The character traits.

◆ value_type

template<tools::CharType Char, std::size_t kSize, typename CharTraits = std::char_traits<Char>>
using xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::value_type = Char

The character type.

Constructor & Destructor Documentation

◆ BasicFixedString() [1/13]

template<tools::CharType Char, std::size_t kSize, typename CharTraits = std::char_traits<Char>>
constexpr xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::BasicFixedString ( )
constexprnoexcept

Default constructor.

This constructor constructs a string that contains all 0 characters.

◆ BasicFixedString() [2/13]

template<tools::CharType Char, std::size_t kSize, typename CharTraits = std::char_traits<Char>>
constexpr xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::BasicFixedString ( const BasicFixedString< Char, kSize, CharTraits > &  )
constexprdefaultnoexcept

Copy constructor.

◆ BasicFixedString() [3/13]

template<tools::CharType Char, std::size_t kSize, typename CharTraits = std::char_traits<Char>>
constexpr xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::BasicFixedString ( UninitializedTag  tag)
constexprnoexcept

Constructor for a string containing uninitialized characters.

This constructor constructs a string with unitialized string data. You should overwrite the data with valid characters before using the string.

Parameters
tagAlways pass kUninitialized as this parameter

◆ BasicFixedString() [4/13]

template<tools::CharType Char, std::size_t kSize, typename CharTraits = std::char_traits<Char>>
constexpr xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::BasicFixedString ( FillTag  tag,
Char  character 
)
constexprnoexcept

Constructor for a string filled with a specific character.

Parameters
tagAlways pass kFill as this parameter
characterThe character to fill the string with

◆ BasicFixedString() [5/13]

template<tools::CharType Char, std::size_t kSize, typename CharTraits = std::char_traits<Char>>
constexpr xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::BasicFixedString ( size_type  count,
Char  character 
)
constexpr

Constructor for a string filled with a specific character, checking the size.

Parameters
countThe number of repetitions of the character. This must be equal to kSize, or an exception of type std::length_error is thrown.
characterThe character to fill the string with.
Exceptions
std::length_errorcount is not equal to kSize.

◆ BasicFixedString() [6/13]

template<tools::CharType Char, std::size_t kSize, typename CharTraits = std::char_traits<Char>>
constexpr xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::BasicFixedString ( const Char *  string,
FillTag  tag 
)
constexprnoexcept

Constructor that copies characters from an array.

Parameters
stringA pointer to the characters to copy. The pointer must point to a memory region that is at least kSize characters long.
tagAlways pass kFill as this parameter

◆ BasicFixedString() [7/13]

template<tools::CharType Char, std::size_t kSize, typename CharTraits = std::char_traits<Char>>
constexpr xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::BasicFixedString ( const Char *  string,
size_type  count 
)
constexpr

Constructor that copies characters from an array, checking the size.

Parameters
stringA pointer to the characters to copy. The pointer must point to a memory region that is at least count characters long.
countThe number of characters to copy. This must be equal to kSize, or an exception of type std::length_error is thrown.
Exceptions
std::length_errorcount is not equal to kSize.

◆ BasicFixedString() [8/13]

template<tools::CharType Char, std::size_t kSize, typename CharTraits = std::char_traits<Char>>
constexpr xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::BasicFixedString ( const Char *  string)
constexpr

Constructor that copies a null-terminated string.

Parameters
stringThe string to copy. The string must be null-terminated, and must be exactly kSize character long.
Exceptions
std::length_errorThe length of the string is not equal to kSize.

◆ BasicFixedString() [9/13]

template<tools::CharType Char, std::size_t kSize, typename CharTraits = std::char_traits<Char>>
template<std::input_iterator InputIterator>
constexpr xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::BasicFixedString ( InputIterator  first,
InputIterator  last 
)
constexpr

Constructor that fills the string from a character sequence.

Parameters
firstAn iterator pointing to the first character to copy.
lastAn iterator pointing one position past the last character to copy. There must be exactly kSize characters between first and last, or an exception of type std::length_error is thrown.
Exceptions
std::length_errorThe length of the sequence [first, last) is not equal to kSize.

◆ BasicFixedString() [10/13]

template<tools::CharType Char, std::size_t kSize, typename CharTraits = std::char_traits<Char>>
xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::BasicFixedString ( std::initializer_list< Char >  characters)

Constructor that initializes the characters from an initializer list.

Parameters
charactersThe characters to initialize the string with. The size of the initializer list must be equal to kSize, or an exception of type std::length_error is thrown.
Exceptions
std::length_errorThe size of the initializer list is not equal to kSize.

◆ BasicFixedString() [11/13]

template<tools::CharType Char, std::size_t kSize, typename CharTraits = std::char_traits<Char>>
template<typename String >
requires (std::is_convertible_v<const String &, std::basic_string_view<Char, CharTraits>> && !std::is_convertible_v<const String &, const Char *>)
constexpr xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::BasicFixedString ( const String &  string)
explicitconstexpr

Constructor that copies an arbitrary string.

Template Parameters
StringThe string type. Must be a type that is convertible to std::basic_string_view<Char, CharTraits>.
Parameters
stringThe string to copy. The size of the string must be equal to kSize, or an exception of type std::length_error is thrown.
Exceptions
std::length_errorThe size of the string is not equal to kSize.

◆ BasicFixedString() [12/13]

template<tools::CharType Char, std::size_t kSize, typename CharTraits = std::char_traits<Char>>
template<typename String >
requires (std::is_convertible_v<const String &, std::basic_string_view<Char, CharTraits>> && !std::is_convertible_v<const String &, const Char *>)
constexpr xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::BasicFixedString ( const String &  string,
size_type  position,
FillTag  tag 
)
constexpr

Constructor that copies a sub string of a string, up to a length of kSize characters.

Template Parameters
StringThe string type. Must be a type that is convertible to std::basic_string_view<Char, CharTraits>.
Parameters
stringThe string to copy from. The size of the string must be no less than position + kSize, or an exception of type std::length_error is thrown.
positionThe position of the sub string to copy. Must be a valid sub string position within string, meaning it must be between 0 and the size of the string contained in string, inclusively.
tagAlways pass kFill as this parameter
Exceptions
std::out_of_rangeposition is greater than the size of the string contained in string.
std::length_errorThe size of the string is less than position + kSize.

◆ BasicFixedString() [13/13]

template<tools::CharType Char, std::size_t kSize, typename CharTraits = std::char_traits<Char>>
template<typename String >
requires (std::is_convertible_v<const String &, std::basic_string_view<Char, CharTraits>> && !std::is_convertible_v<const String &, const Char *>)
constexpr xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::BasicFixedString ( const String &  string,
size_type  position,
size_type  count 
)
constexpr

Constructor that copies a sub string of a string, up to a maximum length.

Template Parameters
StringThe string type. Must be a type that is convertible to std::basic_string_view<Char, CharTraits>.
Parameters
stringThe string to copy from.
positionThe position of the sub string to copy.
countThe maximum length of the sub string to copy, or npos to always copy the remainder of the string. The length of the sub string is calculated in the same way as std::basic_string_view::substr(). Irrespective of the value of count, the effective length of the sub string must be equal to kSize, or an exception of type std::length_error is thrown.
Exceptions
std::length_errorThe effective length of the sub string is not equal to kSize.

Member Function Documentation

◆ assign() [1/12]

template<tools::CharType Char, std::size_t kSize, typename CharTraits >
constexpr auto xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::assign ( const BasicFixedString< Char, kSize, CharTraits > &  string) -> BasicFixedString &
constexprnoexcept

Copies another fixed string of the same size.

Returns
A Reference to this object

◆ assign() [2/12]

template<tools::CharType Char, std::size_t kSize, typename CharTraits >
constexpr auto xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::assign ( const Char *  string) -> BasicFixedString &
constexpr

Copies a null-terminated string.

Parameters
stringThe string to copy. The string must be null-terminated, and must be exactly kSize character long.
Returns
A Reference to this object
Exceptions
std::length_errorThe length of the string is not equal to kSize.

◆ assign() [3/12]

template<tools::CharType Char, std::size_t kSize, typename CharTraits >
constexpr auto xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::assign ( const Char *  string,
FillTag  tag 
) -> BasicFixedString &
constexprnoexcept

Copies characters from an array.

Parameters
stringA pointer to the characters to copy. The pointer must point to a memory region that is at least kSize characters long.
tagAlways pass kFill as this parameter
Returns
A Reference to this object

◆ assign() [4/12]

template<tools::CharType Char, std::size_t kSize, typename CharTraits >
constexpr auto xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::assign ( const Char *  string,
size_type  count 
) -> BasicFixedString &
constexpr

Copies characters from an array, checking the size.

Parameters
stringA pointer to the characters to copy. The pointer must point to a memory region that is at least count characters long.
countThe number of characters to copy. This must be equal to kSize, or an exception of type std::length_error is thrown.
Returns
A Reference to this object
Exceptions
std::length_errorcount is not equal to kSize.

◆ assign() [5/12]

template<tools::CharType Char, std::size_t kSize, typename CharTraits >
requires (std::is_convertible_v<const String &, std::basic_string_view<Char, CharTraits>> && !std::is_convertible_v<const String &, const Char *>)
template<typename String >
requires (std::is_convertible_v<const String &, std::basic_string_view<Char, CharTraits>> && !std::is_convertible_v<const String &, const Char *>)
constexpr auto xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::assign ( const String &  string) -> BasicFixedString &
constexpr

Copies an arbitrary string.

Template Parameters
StringThe string type. Must be a type that is convertible to std::basic_string_view<Char, CharTraits>.
Parameters
stringThe string to copy. The size of the string must be equal to kSize, or an exception of type std::length_error is thrown.
Returns
A Reference to this object
Exceptions
std::length_errorThe size of the string is not equal to kSize.

◆ assign() [6/12]

template<tools::CharType Char, std::size_t kSize, typename CharTraits >
requires (std::is_convertible_v<const String &, std::basic_string_view<Char, CharTraits>> && !std::is_convertible_v<const String &, const Char *>)
template<typename String >
requires (std::is_convertible_v<const String &, std::basic_string_view<Char, CharTraits>> && !std::is_convertible_v<const String &, const Char *>)
constexpr auto xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::assign ( const String &  string,
size_type  position 
) -> BasicFixedString &
constexpr

Copies a sub string of a string.

Template Parameters
StringThe string type. Must be a type that is convertible to std::basic_string_view<Char, CharTraits>.
Parameters
stringThe string to copy from. The size of the string must be equal to position + kSize, or an exception of type std::length_error is thrown.
positionThe position of the sub string to copy. Must be a valid sub string position within string, meaning it must be between 0 and the size of the string contained in string, inclusively.
Returns
A Reference to this object
Exceptions
std::out_of_rangeposition is greater than the size of the string contained in string.
std::length_errorThe size of the string is not equal to position + kSize.

◆ assign() [7/12]

template<tools::CharType Char, std::size_t kSize, typename CharTraits >
requires (std::is_convertible_v<const String &, std::basic_string_view<Char, CharTraits>> && !std::is_convertible_v<const String &, const Char *>)
template<typename String >
requires (std::is_convertible_v<const String &, std::basic_string_view<Char, CharTraits>> && !std::is_convertible_v<const String &, const Char *>)
constexpr auto xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::assign ( const String &  string,
size_type  position,
FillTag  tag 
) -> BasicFixedString &
constexpr

Copies a sub string of a string, up to a length of kSize characters.

Template Parameters
StringThe string type. Must be a type that is convertible to std::basic_string_view<Char, CharTraits>.
Parameters
stringThe string to copy from. The size of the string must be no less than position + kSize, or an exception of type std::length_error is thrown.
positionThe position of the sub string to copy. Must be a valid sub string position within string, meaning it must be between 0 and the size of the string contained in string, inclusively.
tagAlways pass kFill as this parameter
Returns
A Reference to this object
Exceptions
std::out_of_rangeposition is greater than the size of the string contained in string.
std::length_errorThe size of the string is less than position + kSize.

◆ assign() [8/12]

template<tools::CharType Char, std::size_t kSize, typename CharTraits >
requires (std::is_convertible_v<const String &, std::basic_string_view<Char, CharTraits>> && !std::is_convertible_v<const String &, const Char *>)
template<typename String >
requires (std::is_convertible_v<const String &, std::basic_string_view<Char, CharTraits>> && !std::is_convertible_v<const String &, const Char *>)
constexpr auto xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::assign ( const String &  string,
size_type  position,
size_type  count 
) -> BasicFixedString &
constexpr

Copies a sub string of a string, up to a maximum length.

Template Parameters
StringThe string type. Must be a type that is convertible to std::basic_string_view<Char, CharTraits>.
Parameters
stringThe string to copy from.
positionThe position of the sub string to copy. Must be a valid sub string position within string, meaning it must be between 0 and the size of the string contained in string, inclusively.
countThe maximum length of the sub string to copy, or npos to always copy the remainder of the string. The length of the sub string is calculated in the same way as std::basic_string_view::substr(). Irrespective of the value of count, the effective length of the sub string must be equal to kSize, or an exception of type std::length_error is thrown.
Returns
A Reference to this object
Exceptions
std::out_of_rangeposition is greater than the size of the string contained in string.
std::length_errorThe effective length of the sub string is not equal to kSize.

◆ assign() [9/12]

template<tools::CharType Char, std::size_t kSize, typename CharTraits >
constexpr auto xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::assign ( FillTag  tag,
Char  character 
) -> BasicFixedString &
constexprnoexcept

Fills the string with a specific character.

Parameters
tagAlways pass kFill as this parameter
characterThe character to fill the string with
Returns
A Reference to this object

◆ assign() [10/12]

template<tools::CharType Char, std::size_t kSize, typename CharTraits >
template<std::input_iterator InputIterator>
constexpr auto xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::assign ( InputIterator  first,
InputIterator  last 
) -> BasicFixedString &
constexpr

Copies a character range.

Parameters
firstAn iterator pointing to the first character to copy.
lastAn iterator pointing one position past the last character to copy. There must be exactly kSize characters between first and last, or an exception of type std::length_error is thrown.
Returns
A Reference to this object
Exceptions
std::length_errorThe length of the sequence [first, last) is not equal to kSize.

◆ assign() [11/12]

template<tools::CharType Char, std::size_t kSize, typename CharTraits >
constexpr auto xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::assign ( size_type  count,
Char  character 
) -> BasicFixedString &
constexpr

Fills the string with a specific character, checking the size.

Parameters
countThe number of repetitions of the character. This must be equal to kSize, or an exception of type std::length_error is thrown.
characterThe character to fill the string with.
Returns
A Reference to this object
Exceptions
std::length_errorcount is not equal to kSize.

◆ assign() [12/12]

template<tools::CharType Char, std::size_t kSize, typename CharTraits >
constexpr auto xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::assign ( std::initializer_list< Char >  characters) -> BasicFixedString &
constexpr

Copies the characters from an initializer list.

Parameters
charactersThe characters to initialize the string with. The size of the initializer list must be equal to kSize, or an exception of type std::length_error is thrown.
Returns
A Reference to this object
Exceptions
std::length_errorThe size of the initializer list is not equal to kSize.

◆ at() [1/2]

template<tools::CharType Char, std::size_t kSize, typename CharTraits >
constexpr auto xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::at ( size_type  index) -> reference
constexpr

Accesses the character at a certain index.

Parameters
indexThe index
Returns
A reference to the character at the given index
Exceptions
std::out_of_rangeindex is out of range

◆ at() [2/2]

template<tools::CharType Char, std::size_t kSize, typename CharTraits >
constexpr auto xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::at ( size_type  index) const -> const_reference
constexpr

Accesses the character at a certain index.

Parameters
indexThe index
Returns
A reference to the character at the given index
Exceptions
std::out_of_rangeindex is out of range

◆ back() [1/2]

template<tools::CharType Char, std::size_t kSize, typename CharTraits = std::char_traits<Char>>
constexpr auto xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::back ( ) const -> const_reference
constexprnoexcept

Returns the last character.

Note
Must not be called on an empty string
Returns
A reference to last character

◆ back() [2/2]

template<tools::CharType Char, std::size_t kSize, typename CharTraits = std::char_traits<Char>>
constexpr auto xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::back ( ) -> reference
constexprnoexcept

Returns the last character.

Note
Must not be called on an empty string
Returns
A reference to last character

◆ begin() [1/2]

template<tools::CharType Char, std::size_t kSize, typename CharTraits >
constexpr auto xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::begin ( ) const -> const_iterator
constexprnoexcept

Creates a begin iterator.

Returns
An iterator pointing at the first character, or end(), if the data is empty

◆ begin() [2/2]

template<tools::CharType Char, std::size_t kSize, typename CharTraits >
constexpr auto xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::begin ( ) -> iterator
constexprnoexcept

Creates a begin iterator.

Returns
An iterator pointing at the first character, or end(), if the data is empty

◆ c_str()

template<tools::CharType Char, std::size_t kSize, typename CharTraits = std::char_traits<Char>>
constexpr auto xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::c_str ( ) const -> const Char *
constexprnoexcept

Gets the data as a null terminated string.

Returns
The data as a null terminated string. The returned string will always be null terminated, even if the string data is still uninitialized. The uninitialized data may of course contain additional embedded null characters.

◆ capacity()

template<tools::CharType Char, std::size_t kSize, typename CharTraits = std::char_traits<Char>>
constexpr auto xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::capacity ( ) const -> size_type
constexprnoexcept

Gets the capacity of the string.

Returns
The capacity, as defined by the kSize template parameter.

◆ cbegin()

template<tools::CharType Char, std::size_t kSize, typename CharTraits >
constexpr auto xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::cbegin ( ) const -> const_iterator
constexprnoexcept

Creates a begin iterator.

Returns
An iterator pointing at the first character, or end(), if the data is empty

◆ cend()

template<tools::CharType Char, std::size_t kSize, typename CharTraits >
constexpr auto xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::cend ( ) const -> const_iterator
constexprnoexcept

Creates an end iterator.

Returns
An iterator pointing at the position past the last character

◆ crbegin()

template<tools::CharType Char, std::size_t kSize, typename CharTraits >
constexpr auto xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::crbegin ( ) const -> const_reverse_iterator
constexprnoexcept

Creates a reverse begin iterator.

Returns
A reverse iterator pointing at the last character, or rend(), if the data is empty

◆ crend()

template<tools::CharType Char, std::size_t kSize, typename CharTraits >
constexpr auto xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::crend ( ) const -> const_reverse_iterator
constexprnoexcept

Creates a reverse end iterator.

Returns
A reverse iterator pointing at the position before the first character

◆ data() [1/2]

template<tools::CharType Char, std::size_t kSize, typename CharTraits = std::char_traits<Char>>
constexpr auto xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::data ( ) const -> const Char *
constexprnoexcept

Gets a pointer to the data.

Returns
A pointer to the data.

◆ data() [2/2]

template<tools::CharType Char, std::size_t kSize, typename CharTraits = std::char_traits<Char>>
constexpr auto xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::data ( ) -> Char *
constexprnoexcept

Gets a pointer to the data.

The returned pointer points to a buffer that has enough room for size() characters, plus a terminating null character. It is safe to write to the position after the last character, but only a null character way be written there, or the null termination will be lost.

Returns
A pointer to the data.

◆ empty()

template<tools::CharType Char, std::size_t kSize, typename CharTraits = std::char_traits<Char>>
constexpr auto xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::empty ( ) const -> bool
constexprnoexcept

Determines whether the string is empty.

Since the string has a fixed size, this function will only return true for template instations with a kSize-parameter of 0.

Returns
Whether the string is empty

◆ end() [1/2]

template<tools::CharType Char, std::size_t kSize, typename CharTraits >
constexpr auto xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::end ( ) const -> const_iterator
constexprnoexcept

Creates an end iterator.

Returns
An iterator pointing at the position past the last character

◆ end() [2/2]

template<tools::CharType Char, std::size_t kSize, typename CharTraits >
constexpr auto xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::end ( ) -> iterator
constexprnoexcept

Creates an end iterator.

Returns
An iterator pointing at the position past the last character

◆ ends_with() [1/3]

template<tools::CharType Char, std::size_t kSize, typename CharTraits = std::char_traits<Char>>
constexpr auto xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::ends_with ( Char  character) const -> bool
constexprnoexcept

Checks whether the string ends with a certain character.

◆ ends_with() [2/3]

template<tools::CharType Char, std::size_t kSize, typename CharTraits = std::char_traits<Char>>
constexpr auto xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::ends_with ( const Char *  string) const -> bool
constexpr

Checks whether the string ends with a certain text.

◆ ends_with() [3/3]

template<tools::CharType Char, std::size_t kSize, typename CharTraits = std::char_traits<Char>>
constexpr auto xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::ends_with ( std::basic_string_view< Char, CharTraits >  string) const -> bool
constexprnoexcept

Checks whether the string ends with a certain text.

◆ front() [1/2]

template<tools::CharType Char, std::size_t kSize, typename CharTraits = std::char_traits<Char>>
constexpr auto xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::front ( ) const -> const_reference
constexprnoexcept

Returns the first character.

Note
Must not be called on an empty string
Returns
A reference to first character

◆ front() [2/2]

template<tools::CharType Char, std::size_t kSize, typename CharTraits = std::char_traits<Char>>
constexpr auto xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::front ( ) -> reference
constexprnoexcept

Returns the first character.

Note
Must not be called on an empty string
Returns
A reference to first character

◆ length()

template<tools::CharType Char, std::size_t kSize, typename CharTraits = std::char_traits<Char>>
constexpr auto xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::length ( ) const -> size_type
constexprnoexcept

Alias for size()

Returns
The current size

◆ max_size()

template<tools::CharType Char, std::size_t kSize, typename CharTraits = std::char_traits<Char>>
static constexpr auto xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::max_size ( ) -> size_type
staticconstexprnoexcept

Gets the maximum size.

Returns
The maximum size, as defined by the kSize template parameter.

◆ operator std::basic_string< Char, CharTraits, Allocator >()

template<tools::CharType Char, std::size_t kSize, typename CharTraits = std::char_traits<Char>>
template<typename Allocator >
constexpr xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::operator std::basic_string< Char, CharTraits, Allocator > ( ) const
constexprnoexcept

conversion to an std::string

Returns
A copy to the data

◆ operator std::basic_string_view< Char, CharTraits >()

template<tools::CharType Char, std::size_t kSize, typename CharTraits = std::char_traits<Char>>
constexpr xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::operator std::basic_string_view< Char, CharTraits > ( ) const
constexprnoexcept

conversion to a string view

Returns
A view to the data

◆ operator=() [1/4]

template<tools::CharType Char, std::size_t kSize, typename CharTraits = std::char_traits<Char>>
constexpr auto xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::operator= ( const BasicFixedString< Char, kSize, CharTraits > &  ) -> BasicFixedString &=default
constexprdefaultnoexcept

Copy assignment operator.

◆ operator=() [2/4]

template<tools::CharType Char, std::size_t kSize, typename CharTraits = std::char_traits<Char>>
constexpr auto xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::operator= ( const Char *  string) -> BasicFixedString &
constexpr

Assignment operator for a null-terminated string.

Parameters
stringThe string to copy. The string must be null-terminated, and must be exactly kSize character long.
Returns
A Reference to this object
Exceptions
std::length_errorThe length of the string is not equal to kSize.

◆ operator=() [3/4]

template<tools::CharType Char, std::size_t kSize, typename CharTraits = std::char_traits<Char>>
template<typename String >
requires (std::is_convertible_v<const String &, std::basic_string_view<Char, CharTraits>> && !std::is_convertible_v<const String &, const Char *>)
constexpr auto xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::operator= ( const String &  string) -> BasicFixedString &
constexpr

Assignment operator for an arbitrary string.

Template Parameters
StringThe string type. Must be a type that is convertible to std::basic_string_view<Char, CharTraits>.
Parameters
stringThe string to copy. The size of the string must be equal to kSize, or an exception of type std::length_error is thrown.
Returns
A Reference to this object
Exceptions
std::length_errorThe size of the string is not equal to kSize.

◆ operator=() [4/4]

template<tools::CharType Char, std::size_t kSize, typename CharTraits = std::char_traits<Char>>
constexpr auto xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::operator= ( std::initializer_list< Char >  characters) -> BasicFixedString &
constexpr

Assignment operator for an initializer list.

Parameters
charactersThe characters to initialize the string with. The size of the initializer list must be equal to kSize, or an exception of type std::length_error is thrown.
Returns
A Reference to this object
Exceptions
std::length_errorThe size of the initializer list is not equal to kSize.

◆ operator[]() [1/2]

template<tools::CharType Char, std::size_t kSize, typename CharTraits = std::char_traits<Char>>
constexpr auto xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::operator[] ( size_type  index) const -> const_reference
constexprnoexcept

Subscript operator.

Returns a reference to the character at a certain index

Parameters
indexThe index
Returns
A reference to the value at the given offset

◆ operator[]() [2/2]

template<tools::CharType Char, std::size_t kSize, typename CharTraits = std::char_traits<Char>>
constexpr auto xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::operator[] ( size_type  index) -> reference
constexprnoexcept

Subscript operator.

Returns a reference to the character at a certain index

Parameters
indexThe index
Returns
A reference to the value at the given offset

◆ rbegin() [1/2]

template<tools::CharType Char, std::size_t kSize, typename CharTraits >
constexpr auto xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::rbegin ( ) const -> const_reverse_iterator
constexprnoexcept

Creates a reverse begin iterator.

Returns
A reverse iterator pointing at the last character, or rend(), if the data is empty

◆ rbegin() [2/2]

template<tools::CharType Char, std::size_t kSize, typename CharTraits >
constexpr auto xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::rbegin ( ) -> reverse_iterator
constexprnoexcept

Creates a reverse begin iterator.

Returns
A reverse iterator pointing at the last character, or rend(), if the data is empty

◆ rend() [1/2]

template<tools::CharType Char, std::size_t kSize, typename CharTraits >
constexpr auto xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::rend ( ) const -> const_reverse_iterator
constexprnoexcept

Creates a reverse end iterator.

Returns
A reverse iterator pointing at the position before the first character

◆ rend() [2/2]

template<tools::CharType Char, std::size_t kSize, typename CharTraits >
constexpr auto xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::rend ( ) -> reverse_iterator
constexprnoexcept

Creates a reverse end iterator.

Returns
A reverse iterator pointing at the position before the first character

◆ size()

template<tools::CharType Char, std::size_t kSize, typename CharTraits = std::char_traits<Char>>
constexpr auto xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::size ( ) const -> size_type
constexprnoexcept

Gets the size.

Returns
The current size

◆ starts_with() [1/3]

template<tools::CharType Char, std::size_t kSize, typename CharTraits = std::char_traits<Char>>
constexpr auto xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::starts_with ( Char  character) const -> bool
constexprnoexcept

Checks whether the string starts with a certain character.

◆ starts_with() [2/3]

template<tools::CharType Char, std::size_t kSize, typename CharTraits = std::char_traits<Char>>
constexpr auto xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::starts_with ( const Char *  string) const -> bool
constexpr

Checks whether the string starts with a certain text.

◆ starts_with() [3/3]

template<tools::CharType Char, std::size_t kSize, typename CharTraits = std::char_traits<Char>>
constexpr auto xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::starts_with ( std::basic_string_view< Char, CharTraits >  string) const -> bool
constexprnoexcept

Checks whether the string starts with a certain text.

◆ str()

template<tools::CharType Char, std::size_t kSize, typename CharTraits = std::char_traits<Char>>
template<typename Allocator = std::allocator<Char>>
constexpr auto xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::str ( const Allocator &  allocator = Allocator()) const -> std::basic_string<Char, CharTraits, Allocator>
constexprnoexcept

Gets the data as an std::string.

Returns
The data as a null terminated string.

◆ view()

template<tools::CharType Char, std::size_t kSize, typename CharTraits = std::char_traits<Char>>
constexpr auto xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::view ( ) const -> std::basic_string_view<Char, CharTraits>
constexprnoexcept

Gets the data as a string view.

Returns
The data as a string view.

Member Data Documentation

◆ npos

template<tools::CharType Char, std::size_t kSize, typename CharTraits = std::char_traits<Char>>
constexpr size_type xentara::utils::string::BasicFixedString< Char, kSize, CharTraits >::npos
staticconstexpr

Special size value used for automatically determined lengths.