ToyGine2 26.2.0
Game Engine for retro consoles
Loading...
Searching...
No Matches
toy::FixedString< allocatedSize > Class Template Reference

Template string class with fixed-size character buffer. More...

Public Types

using value_type = char
 Type of characters stored in the string.
using size_type = size_t
 Type used for string size and capacity.
using difference_type = std::ptrdiff_t
 Type used for pointer differences.
using reference = value_type &
 Reference to string character.
using const_reference = const value_type &
 Const reference to string character.
using pointer = value_type *
 Pointer to string character.
using const_pointer = const value_type *
 Const pointer to string character.
using iterator = value_type *
 Iterator type for string characters.
using const_iterator = const value_type *
 Const iterator type for string characters.
using reverse_iterator = std::reverse_iterator<iterator>
 Reverse iterator type for string characters.
using const_reverse_iterator = std::reverse_iterator<const_iterator>
 Const reverse iterator type for string characters.

Public Member Functions

constexpr FixedString () noexcept=default
 Default constructor.
constexpr FixedString (size_type count, char character) noexcept
 Constructs a string of the given count of character.
template<StringLike stringType>
constexpr FixedString (const stringType &string) noexcept
 Constructs a string initialized with a toy::StringLike object.
template<StringLike stringType>
constexpr FixedString (stringType &&string) noexcept
constexpr FixedString (const char *string) noexcept
 Constructs a string initialized with the C string.
template<StringLike stringType>
constexpr FixedString< allocatedSize > & operator= (const stringType &string) noexcept
 Copy assigns a toy::StringLike object to this string.
constexpr FixedString< allocatedSize > & operator= (const char *string) noexcept
 Copy assigns the C string to this string.
constexpr FixedString< allocatedSize > & operator= (char character) noexcept
 Character assignment to this string.
constexpr FixedString< allocatedSize > & assign (const FixedString< allocatedSize > &string) noexcept
 Copy assigns other string to this string.
template<StringLike stringType>
constexpr FixedString< allocatedSize > & assign (const stringType &string) noexcept
 Copy assigns a toy::StringLike object to this string.
constexpr FixedString< allocatedSize > & assign (const char *string) noexcept
 Copy assigns the C string to this string.
constexpr FixedString< allocatedSize > & assign (char character, size_t count=1) noexcept
 Character fill assign method for the string.
constexpr char & at (size_t offset) noexcept
 Access a character in the string at a given offset.
constexpr const char & at (size_t offset) const noexcept
 Access a character in the string at a given offset.
constexpr char & operator[] (size_t offset) noexcept
 Access a character in the string at a given offset.
constexpr const char & operator[] (size_t offset) const noexcept
 Access a character in the string at a given offset.
constexpr char & front () noexcept
 Returns a reference to the first character of the string.
constexpr const char & front () const noexcept
 Returns a const reference to the first character of the string.
constexpr char & back () noexcept
 Returns a reference to the last character of the string.
constexpr const char & back () const noexcept
 Returns a const reference to the last character of the string.
constexpr char * data () noexcept
 Returns a pointer to the data of the string.
constexpr const char * data () const noexcept
 Returns a constant pointer to the data of the string.
constexpr const char * c_str () const noexcept
 Returns a constant pointer to the C string representation of this string.
constexpr bool empty () const noexcept
 Checks if the string is empty.
constexpr size_t size () const noexcept
 Returns the size of the string.
size_t utf8_size () const noexcept
 Returns the size of the Unicode string in UTF-8 encoding.
constexpr size_t length () const noexcept
 Returns the size of the string.
constexpr size_t max_size () const noexcept
 Returns the maximum size of the string.
constexpr size_t capacity () const noexcept
 Returns the capacity of the string.
constexpr void clear () noexcept
 Clears the contents of the string.
constexpr FixedString< allocatedSize > & insert (size_t index, const FixedString< allocatedSize > &string) noexcept
 Inserts other string at the specified index.
template<StringLike stringType>
constexpr FixedString< allocatedSize > & insert (size_t index, const stringType &string) noexcept
 Inserts a toy::StringLike object at the specified index.
constexpr FixedString< allocatedSize > & insert (size_t index, const char *string) noexcept
 Inserts the C string at the specified index.
constexpr FixedString< allocatedSize > & insert (size_t index, char character, size_t count=1) noexcept
 Inserts a character repeated the given count times at the specified index.
constexpr FixedString< allocatedSize > & erase (size_t offset, size_t count=npos) noexcept
 Erases characters from the string starting at the specified offset.
constexpr void push_back (char character) noexcept
 Appends a single character to the end of the string.
constexpr void pop_back () noexcept
 Removes the last character from the string.
constexpr void utf8_pop_back () noexcept
 Removes the last UTF-8 encoded character from the string.
constexpr FixedString< allocatedSize > & append (size_type count, char character) noexcept
 Appends a character repeated the given count times to the end of this string.
constexpr FixedString< allocatedSize > & append (const char *string, size_type count) noexcept
 Appends the first count characters from the C string to the end of this string.
constexpr FixedString< allocatedSize > & append (const char *string) noexcept
 Appends the C string to the end of this string.
constexpr FixedString< allocatedSize > & append (const FixedString< allocatedSize > &string) noexcept
 Appends other string to the end of this string.
template<StringLike stringType>
constexpr FixedString< allocatedSize > & append (const stringType &string) noexcept
 Appends a toy::StringLike object to the end of this string.
constexpr FixedString< allocatedSize > & operator+= (const FixedString< allocatedSize > &string) noexcept
 Appends other string to the end of this string.
template<StringLike stringType>
constexpr FixedString< allocatedSize > & operator+= (const stringType &string) noexcept
 Appends a toy::StringLike object to the end of this string.
constexpr FixedString< allocatedSize > & operator+= (const char *string) noexcept
 Appends the C string to the end of this string.
constexpr FixedString< allocatedSize > & operator+= (char character) noexcept
 Appends a character to the end of this string.
constexpr FixedString< allocatedSize > & replace (size_t pos, size_t count, const FixedString< allocatedSize > &string) noexcept
 Replaces a portion of the string with another string.
template<StringLike stringType>
constexpr FixedString< allocatedSize > & replace (size_t pos, size_t count, const stringType &string) noexcept
 Replaces a portion of the string with a toy::StringLike object.
constexpr FixedString< allocatedSize > & replace (size_t pos, size_t count, const char *string) noexcept
 Replaces a portion of the string with the C string.
constexpr FixedString< allocatedSize > & replace (size_t pos, size_t count, char character, size_t charactersCount=1) noexcept
 Replaces a portion of the string with a character repeated the given count of times.
constexpr size_t copy (char *dest, size_t count, size_t pos=0) const noexcept
 Copies characters from the string to a destination buffer.
constexpr void swap (FixedString< allocatedSize > &string) noexcept
 Swaps the contents of this string with another string.
constexpr size_t find (const FixedString< allocatedSize > &string, size_t position=0) const noexcept
 Finds the first occurrence of other string in the string.
template<StringLike stringType>
constexpr size_t find (const stringType &string, size_t position=0) const noexcept
 Finds the first occurrence of a toy::StringLike object in the string.
constexpr size_t find (const char *string, size_t position=0) const noexcept
 Finds the first occurrence of the C string in the string.
constexpr size_t find (char character, size_t position=0) const noexcept
 Finds the first occurrence of a character in the string.
constexpr size_t rfind (const FixedString< allocatedSize > &string, size_t position=npos) const noexcept
 Finds the last occurrence of other string in the string.
template<StringLike stringType>
constexpr size_t rfind (const stringType &string, size_t position=npos) const noexcept
 Finds the last occurrence of a toy::StringLike object in the string.
constexpr size_t rfind (const char *string, size_t position=npos) const noexcept
 Finds the last occurrence of the C string in the string.
constexpr size_t rfind (char character, size_t position=npos) const noexcept
 Finds the last occurrence of a character in the string.
constexpr size_t find_first_of (const FixedString< allocatedSize > &string, size_t position=0) const noexcept
 Finds the first occurrence of any character from the specified string.
template<StringLike stringType>
constexpr size_t find_first_of (const stringType &string, size_t position=0) const noexcept
 Finds the first occurrence of any character from a toy::StringLike object.
constexpr size_t find_first_of (const char *string, size_t position=0) const noexcept
 Finds the first occurrence of any character from the C string.
constexpr size_t find_first_of (char character, size_t position=0) const noexcept
 Finds the first occurrence of the specified character.
constexpr size_t find_first_not_of (const FixedString< allocatedSize > &string, size_t position=0) const noexcept
 Finds the first occurrence of any character not from the specified string.
template<StringLike stringType>
constexpr size_t find_first_not_of (const stringType &string, size_t position=0) const noexcept
 Finds the first occurrence of any character not from a toy::StringLike object.
constexpr size_t find_first_not_of (const char *string, size_t position=0) const noexcept
 Finds the first occurrence of any character not from the C string.
constexpr size_t find_first_not_of (char character, size_t position=0) const noexcept
 Finds the first occurrence of any character not equal to the specified character.
constexpr size_t find_last_of (const FixedString< allocatedSize > &string, size_t position=npos) const noexcept
 Finds the last occurrence of any character from the specified string.
template<StringLike stringType>
constexpr size_t find_last_of (const stringType &string, size_t position=npos) const noexcept
 Finds the last occurrence of any character from a toy::StringLike object.
constexpr size_t find_last_of (const char *string, size_t position=npos) const noexcept
 Finds the last occurrence of any character from the C string.
constexpr size_t find_last_of (char character, size_t position=npos) const noexcept
 Finds the last occurrence of the specified character.
constexpr size_t find_last_not_of (const FixedString< allocatedSize > &string, size_t position=npos) const noexcept
 Finds the last occurrence of any character not from the specified string.
template<StringLike stringType>
constexpr size_t find_last_not_of (const stringType &string, size_t position=npos) const noexcept
 Finds the last occurrence of any character not from a toy::StringLike object.
constexpr size_t find_last_not_of (const char *string, size_t position=npos) const noexcept
 Finds the last occurrence of any character not from the C string.
constexpr size_t find_last_not_of (char character, size_t position=npos) const noexcept
 Finds the last occurrence of any character not equal to the specified character.
constexpr int compare (const FixedString< allocatedSize > &string) const noexcept
 Compares this string with another string lexicographically.
template<StringLike stringType>
constexpr int compare (const stringType &string) const noexcept
 Compares this string with a toy::StringLike object lexicographically.
constexpr int compare (const char *string) const noexcept
 Compares this string with the C string lexicographically.
constexpr bool starts_with (const FixedString< allocatedSize > &string) const noexcept
 Checks if the string starts with the specified string.
template<StringLike stringType>
constexpr bool starts_with (const stringType &string) const noexcept
 Checks if the string starts with a toy::StringLike object.
constexpr bool starts_with (const char *string) const noexcept
 Checks if the string starts with the specified C string.
constexpr bool starts_with (char character) const noexcept
 Checks if the string starts with the specified character.
constexpr bool ends_with (const FixedString< allocatedSize > &string) const noexcept
 Checks if the string ends with the specified string.
template<StringLike stringType>
constexpr bool ends_with (const stringType &string) const noexcept
 Checks if the string ends with a toy::StringLike object.
constexpr bool ends_with (const char *string) const noexcept
 Checks if the string ends with the C string.
constexpr bool ends_with (char character) const noexcept
 Checks if the string ends with the specified character.
constexpr bool contains (const FixedString< allocatedSize > &string) const noexcept
 Checks if the string contains the specified string.
template<StringLike stringType>
constexpr bool contains (const stringType &string) const noexcept
 Checks if the string contains a toy::StringLike object.
constexpr bool contains (const char *string) const noexcept
 Checks if the string contains the C string.
constexpr bool contains (char character) const noexcept
 Checks if the string contains the specified character.
constexpr FixedString< allocatedSize > substr (size_t position=0, size_t count=npos) const noexcept
 Returns a substring of this string.

Static Public Attributes

static constexpr size_t npos = size_t(-1)
 The special value, its exact meaning depends on the context.

Private Member Functions

constexpr void _insert_raw (size_t position, const char *data, size_t dataSize) noexcept
 Helper method for inserting data at a specific position.
constexpr void _append_raw (const char *data, size_t dataSize) noexcept
 Helper method for appending data to the end of the string.
constexpr void _replace_raw (size_t position, size_t oldCount, const char *data, size_t dataSize) noexcept
 Helper method for replacing data at a specific position.
constexpr size_t _find_raw (size_t position, const char *data, size_t dataSize) const noexcept
 Helper method for finding data in the string.
constexpr size_t _rfind_raw (size_t position, const char *data, size_t dataSize) const noexcept
 Helper method for finding data in the string backwards.
constexpr size_t _find_first_of_raw (size_t position, const char *data, size_t dataSize) const noexcept
 Helper method for finding the first occurrence of any character from data.
constexpr size_t _find_first_not_of_raw (size_t position, const char *data, size_t dataSize) const noexcept
 Helper method for finding the first occurrence of any character not from data.
constexpr size_t _find_last_of_raw (size_t position, const char *data, size_t dataSize) const noexcept
 Helper method for finding the last occurrence of any character from data.
constexpr size_t _find_last_not_of_raw (size_t position, const char *data, size_t dataSize) const noexcept
 Helper method for finding the last occurrence of any character not from data.

Private Attributes

FixedStringStorage< allocatedSize > _storage
 Internal character buffer storing the string data.

Detailed Description

template<size_t allocatedSize>
class toy::FixedString< allocatedSize >

Template string class with fixed-size character buffer.

FixedString is a lightweight, high-performance string class that uses a fixed-size character buffer allocated on the stack. It provides a std::string-like interface while avoiding dynamic memory allocation, making it suitable for embedded systems, real-time applications, and performance-critical code where memory allocation overhead must be minimized.

Template Parameters
allocatedSizeThe size of the internal character buffer, including space for the null terminator. Must be greater than zero.

Key Features

  • ⚙️ Zero Dynamic Allocation: All memory is allocated on the stack at compile time
  • 🔧 ConstExpr Support: Most operations can be evaluated at compile time
  • 🛡️ Exception Safety: All operations are noexcept
  • 🔗 STL Compatibility: Provides std::string-like interface
  • 🌍 UTF-8 Support: Built-in UTF-8 character counting and manipulation
  • 🧬 Type Safety: Uses C++20 concepts for type safety

Usage Example

#include "fixed_string.hpp"
// Create a string with 32-character capacity
toy::FixedString<32> str("Hello, World!");
// Append more content
str += " This is a test.";
// Use in constexpr context
constexpr auto greeting = toy::FixedString<16>("Hello");
constexpr auto world = toy::FixedString<16>("World");
constexpr auto combined = greeting + " " + world;
Template string class with fixed-size character buffer.
Definition fixed_string.hpp:117
Fixed-capacity string with stack storage.

Performance Characteristics

  • ⚙️ Construction: O(n) where n is the length of the source string
  • 📝 Assignment: O(n) where n is the length of the source string
  • 🔗 Concatenation: O(n) where n is the length of the appended string
  • 🔍 Search Operations: O(n*m) where n is the string length and m is the pattern length
  • ⚖️ Comparison Operations: O(n) where n is the string length
  • 💾 Memory Usage: Fixed at compile time, no heap allocation
  • Cache Performance: Excellent due to stack allocation and contiguous memory layout
  • 📋 Copy Performance: Fast due to memcpy/memmove optimizations
  • 🎯 String Operations: Optimized for common cases

Safety Guarantees

  • 🛡️ Contracts & Debug Checks: Bounds/capacity are asserted in debug; in production, violating preconditions is UB
  • 🔒 Null Pointer Safety: All C-string operations validate pointers via assertions in debug
  • 📐 Type Safety: Template parameters and concepts prevent invalid usage
  • ⚠️ Exception Safety: All operations are noexcept, no exceptions thrown

Compatibility

  • 🆕 C++23: Requires C++23 or later for full functionality
  • 🔗 STL Integration: Compatible with STL algorithms and containers
  • 🌐 Cross-Platform: Works on all platforms supported by the compiler
  • 🔧 Embedded Systems: Suitable for resource-constrained environments
Note
The internal buffer size is allocatedSize, but the maximum string length is allocatedSize - 1 (null terminator).
See also
std::string, toy::StringLike, toy::CStringView

Member Typedef Documentation

◆ const_iterator

template<size_t allocatedSize>
using toy::FixedString< allocatedSize >::const_iterator = const value_type *

Const iterator type for string characters.

◆ const_pointer

template<size_t allocatedSize>
using toy::FixedString< allocatedSize >::const_pointer = const value_type *

Const pointer to string character.

◆ const_reference

template<size_t allocatedSize>
using toy::FixedString< allocatedSize >::const_reference = const value_type &

Const reference to string character.

◆ const_reverse_iterator

template<size_t allocatedSize>
using toy::FixedString< allocatedSize >::const_reverse_iterator = std::reverse_iterator<const_iterator>

Const reverse iterator type for string characters.

◆ difference_type

template<size_t allocatedSize>
using toy::FixedString< allocatedSize >::difference_type = std::ptrdiff_t

Type used for pointer differences.

◆ iterator

template<size_t allocatedSize>
using toy::FixedString< allocatedSize >::iterator = value_type *

Iterator type for string characters.

◆ pointer

template<size_t allocatedSize>
using toy::FixedString< allocatedSize >::pointer = value_type *

Pointer to string character.

◆ reference

template<size_t allocatedSize>
using toy::FixedString< allocatedSize >::reference = value_type &

Reference to string character.

◆ reverse_iterator

template<size_t allocatedSize>
using toy::FixedString< allocatedSize >::reverse_iterator = std::reverse_iterator<iterator>

Reverse iterator type for string characters.

◆ size_type

template<size_t allocatedSize>
using toy::FixedString< allocatedSize >::size_type = size_t

Type used for string size and capacity.

◆ value_type

template<size_t allocatedSize>
using toy::FixedString< allocatedSize >::value_type = char

Type of characters stored in the string.

Constructor & Destructor Documentation

◆ FixedString() [1/5]

template<size_t allocatedSize>
toy::FixedString< allocatedSize >::FixedString ( )
constexprdefaultnoexcept

Default constructor.

◆ FixedString() [2/5]

template<size_t allocatedSize>
toy::FixedString< allocatedSize >::FixedString ( size_type count,
char character )
constexprnoexcept

Constructs a string of the given count of character.

This constructor initializes a string with a character repeated the given count of times.

Parameters
countThe number of times to repeat the character.
characterThe character to repeat.
Precondition
The count must not exceed the allocated size.
Postcondition
The new string is created with the contents of the character repeated the given count of times.
The string size equals the count.
Note
This is useful for creating strings with repeated patterns or filling with specific characters.

◆ FixedString() [3/5]

template<size_t allocatedSize>
template<StringLike stringType>
toy::FixedString< allocatedSize >::FixedString ( const stringType & string)
explicitconstexprnoexcept

Constructs a string initialized with a toy::StringLike object.

This constructor initializes a string by copying the content from a toy::StringLike object.

Template Parameters
stringTypeThe type of the source string. Must satisfy the toy::StringLike concept.
Parameters
stringThe source toy::StringLike object to copy content from.
Precondition
The source toy::StringLike object must be valid and properly initialized.
The source toy::StringLike object size must not exceed the allocated capacity.
Postcondition
The new string is created with the contents of the source toy::StringLike object.

◆ FixedString() [4/5]

template<size_t allocatedSize>
template<StringLike stringType>
toy::FixedString< allocatedSize >::FixedString ( stringType && string)
explicitconstexprnoexcept

◆ FixedString() [5/5]

template<size_t allocatedSize>
toy::FixedString< allocatedSize >::FixedString ( const char * string)
explicitconstexprnoexcept

Constructs a string initialized with the C string.

This constructor initializes a string by copying the content from the C string. The constructor automatically determines the length of the source string and copies the content up to the allocated capacity.

Parameters
stringThe source C string to copy content from.
Precondition
The source string must not be null.
Postcondition
The new string is created with the contents of the source C string.

Member Function Documentation

◆ _append_raw()

template<size_t allocatedSize>
void toy::FixedString< allocatedSize >::_append_raw ( const char * data,
size_t dataSize )
constexprprivatenoexcept

Helper method for appending data to the end of the string.

This private method performs the common append logic used by all append methods. It copies new data to the end of the string and updates the size accordingly.

Parameters
dataThe data to append.
dataSizeThe size of the data to append.
Precondition
The data must not be null.
The combined length after appending must not exceed the allocated capacity.

◆ _find_first_not_of_raw()

template<size_t allocatedSize>
size_t toy::FixedString< allocatedSize >::_find_first_not_of_raw ( size_t position,
const char * data,
size_t dataSize ) const
constexprprivatenoexcept

Helper method for finding the first occurrence of any character not from data.

This private method performs the common search logic used by all find_first_not_of methods. It searches for the first occurrence of any character that is not present in the specified data starting from the given position.

Parameters
positionThe position to start searching from.
dataThe data containing characters to exclude from search.
dataSizeThe size of the data containing characters to exclude from search.
Returns
The position of the first occurrence of any character not from data, or npos if not found.
Precondition
The position must be less than the string size.
The data must not be null.

◆ _find_first_of_raw()

template<size_t allocatedSize>
size_t toy::FixedString< allocatedSize >::_find_first_of_raw ( size_t position,
const char * data,
size_t dataSize ) const
constexprprivatenoexcept

Helper method for finding the first occurrence of any character from data.

This private method performs the common search logic used by all find_first_of methods. It searches for the first occurrence of any character from the specified data starting from the given position.

Parameters
positionThe position to start searching from.
dataThe data containing characters to search for.
dataSizeThe size of the data containing characters to search for.
Returns
The position of the first occurrence of any character from data, or npos if not found.
Precondition
The position must be less than the string size.
The data must not be null.

◆ _find_last_not_of_raw()

template<size_t allocatedSize>
size_t toy::FixedString< allocatedSize >::_find_last_not_of_raw ( size_t position,
const char * data,
size_t dataSize ) const
constexprprivatenoexcept

Helper method for finding the last occurrence of any character not from data.

This private method performs the common reverse search logic used by all find_last_not_of methods. It searches for the last occurrence of any character that is not present in the specified data starting from the given position and searching backwards.

Parameters
positionThe position to start searching from. If npos, searches from the end.
dataThe data containing characters to exclude from search.
dataSizeThe size of the data containing characters to exclude from search.
Returns
The position of the last occurrence of any character not from data, or npos if not found.
Precondition
If position is not npos, it must be less than the string size.
The data must not be null.

◆ _find_last_of_raw()

template<size_t allocatedSize>
size_t toy::FixedString< allocatedSize >::_find_last_of_raw ( size_t position,
const char * data,
size_t dataSize ) const
constexprprivatenoexcept

Helper method for finding the last occurrence of any character from data.

This private method performs the common reverse search logic used by all find_last_of methods. It searches for the last occurrence of any character from the specified data starting from the given position and searching backwards.

Parameters
positionThe position to start searching from. If npos, searches from the end.
dataThe data containing characters to search for.
dataSizeThe size of the data containing characters to search for.
Returns
The position of the last occurrence of any character from data, or npos if not found.
Precondition
If position is not npos, it must be less than the string size.
The data must not be null.

◆ _find_raw()

template<size_t allocatedSize>
size_t toy::FixedString< allocatedSize >::_find_raw ( size_t position,
const char * data,
size_t dataSize ) const
constexprprivatenoexcept

Helper method for finding data in the string.

This private method performs the common search logic used by all find methods. It searches for the specified data starting from the given position.

Parameters
positionThe position to start searching from.
dataThe data to search for.
dataSizeThe size of the data to search for.
Returns
The position of the first occurrence of data, or npos if not found.
Precondition
The position must be less than the string size.
The data must not be null.

◆ _insert_raw()

template<size_t allocatedSize>
void toy::FixedString< allocatedSize >::_insert_raw ( size_t position,
const char * data,
size_t dataSize )
constexprprivatenoexcept

Helper method for inserting data at a specific position.

This private method performs the common insertion logic used by all insert methods. It shifts existing data to the right and inserts new data at the specified position.

Parameters
positionThe position where to insert the data.
dataThe data to insert.
dataSizeThe size of the data to insert.
Precondition
The position must be within the bounds of the current string.
The data must not be null.
The combined length after insertion must not exceed the allocated capacity.

◆ _replace_raw()

template<size_t allocatedSize>
void toy::FixedString< allocatedSize >::_replace_raw ( size_t position,
size_t oldCount,
const char * data,
size_t dataSize )
constexprprivatenoexcept

Helper method for replacing data at a specific position.

This private method performs the common replacement logic used by all replace methods. It handles the shifting of existing data and insertion of new data at the specified position.

Parameters
positionThe position where to replace the data.
oldCountThe number of characters to replace.
dataThe new data to insert.
dataSizeThe size of the new data.
Precondition
The position must be within the bounds of the current string.
The data must not be null.
The replacement range must be within string bounds.
The resulting string size must not exceed the allocated capacity.

◆ _rfind_raw()

template<size_t allocatedSize>
size_t toy::FixedString< allocatedSize >::_rfind_raw ( size_t position,
const char * data,
size_t dataSize ) const
constexprprivatenoexcept

Helper method for finding data in the string backwards.

This private method performs the common reverse search logic used by all rfind methods. It searches for the specified data starting from the given position and searching backwards.

Parameters
positionThe position to start searching from.
dataThe data to search for.
dataSizeThe size of the data to search for.
Returns
The position of the last occurrence of data, or npos if not found.
Precondition
If position is not npos, it must be less than or equal to the string size.
The data must not be null.

◆ append() [1/5]

template<size_t allocatedSize>
FixedString< allocatedSize > & toy::FixedString< allocatedSize >::append ( const char * string)
constexprnoexcept

Appends the C string to the end of this string.

This method appends the contents of the C string to the end of this string.

Parameters
stringThe source C string to append content from.
Returns
A reference to this string after appending.
Precondition
The combined length after appending must not exceed the allocated size.
The source C string must not be null.
Postcondition
The string is extended with the appended content.
Note
This method is equivalent to the addition assignment operator.
See also
operator+=(const char *)

◆ append() [2/5]

template<size_t allocatedSize>
FixedString< allocatedSize > & toy::FixedString< allocatedSize >::append ( const char * string,
size_type count )
constexprnoexcept

Appends the first count characters from the C string to the end of this string.

This method appends the first count characters from the C string to the end of this string.

Parameters
stringThe source C string to append content from.
countThe number of characters to append from the C string.
Returns
A reference to this string after appending.
Precondition
The combined length after appending must not exceed the allocated size.
The source C string must not be null.
The C string must be at least count characters long.
Postcondition
The string size is increased by count.

◆ append() [3/5]

template<size_t allocatedSize>
FixedString< allocatedSize > & toy::FixedString< allocatedSize >::append ( const FixedString< allocatedSize > & string)
constexprnoexcept

Appends other string to the end of this string.

This method appends the contents of another string to the end of this string.

Parameters
stringThe source string to append content from.
Returns
A reference to this string after appending.
Precondition
The combined length after appending must not exceed the allocated size.
Postcondition
The string is extended with the appended content.
Note
This method is equivalent to the addition assignment operator.
See also
operator+=(const FixedString<allocatedSize> &)

◆ append() [4/5]

template<size_t allocatedSize>
template<StringLike stringType>
FixedString< allocatedSize > & toy::FixedString< allocatedSize >::append ( const stringType & string)
constexprnoexcept

Appends a toy::StringLike object to the end of this string.

This method appends the contents of a toy::StringLike object to the end of this string.

Template Parameters
stringTypeThe type of the source string. Must satisfy the toy::StringLike concept.
Parameters
stringThe source toy::StringLike object to append content from.
Returns
A reference to this string after appending.
Precondition
The combined length after appending must not exceed the allocated size.
Postcondition
The toy::StringLike object is appended to the end of this string.
The string size is increased by the size of the appended toy::StringLike object.
Note
This method is equivalent to the addition assignment operator.
See also
operator+=(const stringType &)
toy::StringLike

◆ append() [5/5]

template<size_t allocatedSize>
FixedString< allocatedSize > & toy::FixedString< allocatedSize >::append ( size_type count,
char character )
constexprnoexcept

Appends a character repeated the given count times to the end of this string.

This method appends a character repeated the given count of times to the end of this string.

Parameters
countThe number of times to repeat the character.
characterThe character to append.
Returns
A reference to this string after appending.
Precondition
The combined length after appending must not exceed the allocated size.
Postcondition
The character is appended count times to the end of the string.
The string size is increased by count.

◆ assign() [1/4]

template<size_t allocatedSize>
FixedString< allocatedSize > & toy::FixedString< allocatedSize >::assign ( char character,
size_t count = 1 )
constexprnoexcept

Character fill assign method for the string.

This method assigns a character repeated the given count of times to this string.

Parameters
characterThe character to repeat.
countThe number of times to repeat the character (default: 1).
Returns
A reference to this string after assignment.
Precondition
The count must not exceed this object's allocated size.
Postcondition
This string object contains the specified character repeated count of times.
The string size equals the count parameter.
Note
This is useful for creating strings with repeated patterns or filling with specific characters.

◆ assign() [2/4]

template<size_t allocatedSize>
FixedString< allocatedSize > & toy::FixedString< allocatedSize >::assign ( const char * string)
constexprnoexcept

Copy assigns the C string to this string.

This method assigns the content from the C string to this string. The assignment operation automatically determines the length of the source content and performs a deep copy of the string data and updates the size accordingly.

Parameters
stringThe source C string to copy content from.
Returns
A reference to this string after assignment.
Precondition
The source C string must not be null.
The source C string size must not exceed the allocated capacity.
Postcondition
This string contains the same content as the source C string.
The size of this string equals the size of the source C string.
Note
Self-assignment is handled correctly and safely.
This method is equivalent to the copy assignment operator.
See also
operator=(const char * string)

◆ assign() [3/4]

template<size_t allocatedSize>
FixedString< allocatedSize > & toy::FixedString< allocatedSize >::assign ( const FixedString< allocatedSize > & string)
constexprnoexcept

Copy assigns other string to this string.

This method assigns the contents of another string to this string. The assignment operation performs a deep copy of the string data and updates the size accordingly.

Parameters
stringThe source string to copy content from.
Returns
A reference to this string after assignment.
Precondition
The source string must be valid and properly initialized.
Postcondition
This string contains the same content as the source string.
The size of this string equals the size of the source string.
Note
Self-assignment is handled correctly and safely.
This method is equivalent to the copy assignment operator.
See also
operator=(const FixedString<allocatedSize> & string)

◆ assign() [4/4]

template<size_t allocatedSize>
template<StringLike stringType>
FixedString< allocatedSize > & toy::FixedString< allocatedSize >::assign ( const stringType & string)
constexprnoexcept

Copy assigns a toy::StringLike object to this string.

This method assigns the content from a toy::StringLike object to this string. The assignment operation performs a deep copy of the string data and updates the size accordingly.

Template Parameters
stringTypeThe type of the source string. Must satisfy the toy::StringLike concept.
Parameters
stringThe source toy::StringLike object to copy content from.
Returns
A reference to this string after assignment.
Precondition
The source toy::StringLike object must be valid and properly initialized.
The source toy::StringLike object size must not exceed the allocated capacity.
Postcondition
This string contains the same content as the source toy::StringLike object.
The size of this string equals the size of the source toy::StringLike object.
Note
Self-assignment is handled correctly and safely.
This method is equivalent to the copy assignment operator.
See also
operator=(const stringType & string)

◆ at() [1/2]

template<size_t allocatedSize>
const char & toy::FixedString< allocatedSize >::at ( size_t offset) const
nodiscardconstexprnoexcept

Access a character in the string at a given offset.

This method provides read-only access to a character at the specified offset within the string.

Parameters
offsetThe offset of the character to access in the string.
Returns
A const reference to the character at the specified offset.
Precondition
The offset must be less than the current string size.
Note
The returned reference is read-only and cannot modify the character.
Use the non-const overload to allow modification.
This method is equivalent to the subscript operator.
See also
operator[](size_t offset) const

◆ at() [2/2]

template<size_t allocatedSize>
char & toy::FixedString< allocatedSize >::at ( size_t offset)
nodiscardconstexprnoexcept

Access a character in the string at a given offset.

This method provides direct access to a character at the specified offset within the string.

Parameters
offsetThe offset of the character to access in the string.
Returns
A reference to the character at the specified offset.
Precondition
The offset must be less than the current string size.
Note
The returned reference allows modification of the character.
Use const version for read-only access.
This method is equivalent to the subscript operator.
See also
operator[](size_t offset)

◆ back() [1/2]

template<size_t allocatedSize>
const char & toy::FixedString< allocatedSize >::back ( ) const
nodiscardconstexprnoexcept

Returns a const reference to the last character of the string.

This method provides read-only access to the last character of the string.

Returns
A const reference to the last character of the string.
Precondition
The string must not be empty.
Note
The returned reference is read-only and cannot modify the character.
Use the non-const overload to allow modification.
See also
back() noexcept

◆ back() [2/2]

template<size_t allocatedSize>
char & toy::FixedString< allocatedSize >::back ( )
nodiscardconstexprnoexcept

Returns a reference to the last character of the string.

This method provides direct access to the last character of the string.

Returns
A reference to the last character of the string.
Precondition
The string must not be empty.
Note
The returned reference allows modification of the character.
Use const version for read-only access.
See also
back() const

◆ c_str()

template<size_t allocatedSize>
const char * toy::FixedString< allocatedSize >::c_str ( ) const
nodiscardconstexprnoexcept

Returns a constant pointer to the C string representation of this string.

This method returns a constant pointer to the C string representation of this string. The returned pointer provides read-only access to the string contents and can be used with C functions that require a char pointer.

Returns
A constant pointer to the C string representation of this string.
Note
The returned pointer is read-only and cannot modify the string contents.
This method is equivalent to data() const.
See also
data() const

◆ capacity()

template<size_t allocatedSize>
size_t toy::FixedString< allocatedSize >::capacity ( ) const
nodiscardconstexprnoexcept

Returns the capacity of the string.

This method returns the capacity of the allocated buffer for the string, which is determined by the template parameter allocatedSize.

Returns
The capacity of the string in characters, excluding the terminating null character.
Note
The capacity is determined at compile time.
This method is equivalent to max_size() method.
See also
max_size()

◆ clear()

template<size_t allocatedSize>
void toy::FixedString< allocatedSize >::clear ( )
constexprnoexcept

Clears the contents of the string.

This method resets the size of the string to zero and effectively clears the string.

Postcondition
The string is empty (size is 0).
All characters are cleared, but the buffer remains allocated.
Note
The string object is cleared, and its size is set to zero.

◆ compare() [1/3]

template<size_t allocatedSize>
int toy::FixedString< allocatedSize >::compare ( const char * string) const
nodiscardconstexprnoexcept

Compares this string with the C string lexicographically.

This method performs a lexicographic comparison between this string and the C string. The comparison is performed character by character using the character's numeric value.

Parameters
stringThe C string to compare with this string.
Returns
A negative value if this string is lexicographically less than C string, zero if they are equal, or a positive value if this string is lexicographically greater than C string.
Precondition
The C string must not be null.
Note
The comparison is case-sensitive.
The comparison stops at the first character that differs between the strings.
If one string is a prefix of another, the shorter is considered lexicographically smaller.

◆ compare() [2/3]

template<size_t allocatedSize>
int toy::FixedString< allocatedSize >::compare ( const FixedString< allocatedSize > & string) const
nodiscardconstexprnoexcept

Compares this string with another string lexicographically.

This method performs a lexicographic comparison between this string and another string. The comparison is performed character by character using the character's numeric value.

Parameters
stringThe string to compare with this string.
Returns
A negative value if this string is lexicographically less than string, zero if they are equal, or a positive value if this string is lexicographically greater than string.
Note
The comparison is case-sensitive.
The comparison stops at the first character that differs between the strings.
If one string is a prefix of another, the shorter is considered lexicographically smaller.

◆ compare() [3/3]

template<size_t allocatedSize>
template<StringLike stringType>
int toy::FixedString< allocatedSize >::compare ( const stringType & string) const
nodiscardconstexprnoexcept

Compares this string with a toy::StringLike object lexicographically.

This method performs a lexicographic comparison between this string and a toy::StringLike object. The comparison is performed character by character using the character's numeric value.

Template Parameters
stringTypeThe type of the source string. Must satisfy the toy::StringLike concept.
Parameters
stringThe toy::StringLike object to compare with this string.
Returns
A negative value if this string is lexicographically less than a toy::StringLike object, zero if they are equal, or a positive value if this string is lexicographically greater than a toy::StringLike object.
Note
The comparison is case-sensitive.
The comparison stops at the first character that differs between the strings.
If one string is a prefix of another, the shorter is considered lexicographically smaller.

◆ contains() [1/4]

template<size_t allocatedSize>
bool toy::FixedString< allocatedSize >::contains ( char character) const
nodiscardconstexprnoexcept

Checks if the string contains the specified character.

This method checks if the current string contains the specified character anywhere within it.

Parameters
characterThe character to search for within this string.
Returns
true if this string contains the specified character, false otherwise.
Note
The search is case-sensitive.
If the string is empty, this method returns false.

◆ contains() [2/4]

template<size_t allocatedSize>
bool toy::FixedString< allocatedSize >::contains ( const char * string) const
nodiscardconstexprnoexcept

Checks if the string contains the C string.

This method checks if the current string contains the C string anywhere within it.

Parameters
stringThe C string to search for within this string.
Returns
true if this string contains the C string, false otherwise.
Precondition
The C string must not be null.
Note
The search is case-sensitive.
If the C string is empty, this method returns true.
If the C string is longer than this string, this method returns false.

◆ contains() [3/4]

template<size_t allocatedSize>
bool toy::FixedString< allocatedSize >::contains ( const FixedString< allocatedSize > & string) const
nodiscardconstexprnoexcept

Checks if the string contains the specified string.

This method checks if the current string contains the specified string anywhere within it.

Parameters
stringThe string to search for within this string.
Returns
true if this string contains the specified string, false otherwise.
Note
The search is case-sensitive.
If the specified string is empty, this method returns true.
If the specified string is longer than this string, returns false.

◆ contains() [4/4]

template<size_t allocatedSize>
template<StringLike stringType>
bool toy::FixedString< allocatedSize >::contains ( const stringType & string) const
nodiscardconstexprnoexcept

Checks if the string contains a toy::StringLike object.

This method checks if the current string contains a toy::StringLike object anywhere within it.

Template Parameters
stringTypeThe type of the source string. Must satisfy the toy::StringLike concept.
Parameters
stringThe toy::StringLike object to search for within this string.
Returns
true if this string contains a toy::StringLike object, false otherwise.
Note
The search is case-sensitive.
If a toy::StringLike object is empty, this method returns true.
If a toy::StringLike object is longer than this string, returns false.

◆ copy()

template<size_t allocatedSize>
size_t toy::FixedString< allocatedSize >::copy ( char * dest,
size_t count,
size_t pos = 0 ) const
constexprnoexcept

Copies characters from the string to a destination buffer.

This method copies up to count characters from the string starting at position pos to the destination buffer. The method returns the actual number of characters copied, which may be less than count if the end of the string is reached.

Parameters
destThe destination buffer to copy characters to.
countThe maximum number of characters to copy.
posThe starting position in the string to copy from (default: 0).
Returns
The actual number of characters copied.
Precondition
The pos must be within the bounds of the current string.
The dest pointer must not be null.
The dest buffer must not overlap this string's internal storage.
The dest buffer must have sufficient space for the copied characters.
Note
If count is npos or exceeds remaining characters from pos, all remaining characters are copied.
The destination buffer is not null-terminated by this method.

◆ data() [1/2]

template<size_t allocatedSize>
const char * toy::FixedString< allocatedSize >::data ( ) const
nodiscardconstexprnoexcept

Returns a constant pointer to the data of the string.

This method returns a constant pointer to the internal character array that stores the string data. The returned pointer provides read-only access to the string contents and can be used for low-level operations.

Returns
A constant pointer to the internal character array.
Note
The returned pointer points to a null-terminated character array.
The returned pointer is read-only and cannot modify the string contents.
Use the non-const overload to allow modification.
See also
data()
c_str()

◆ data() [2/2]

template<size_t allocatedSize>
char * toy::FixedString< allocatedSize >::data ( )
nodiscardconstexprnoexcept

Returns a pointer to the data of the string.

This method returns a pointer to the internal character array that stores the string data. The returned pointer provides direct access to the string contents and can be used for low-level operations.

Returns
A pointer to the internal character array.
Note
The returned pointer points to a null-terminated character array.
The returned pointer allows modification of the string contents.
Use const version for read-only access.
See also
data() const, c_str()

◆ empty()

template<size_t allocatedSize>
bool toy::FixedString< allocatedSize >::empty ( ) const
nodiscardconstexprnoexcept

Checks if the string is empty.

This method checks if the string is empty, i.e. its size is zero. An empty string contains no characters and has a length of zero.

Returns
true if the string is empty (size is 0), false otherwise.
Note
An empty string has size zero.
An empty string still contains a null terminator.
This method is equivalent to the expression: size() == 0.
See also
size()

◆ ends_with() [1/4]

template<size_t allocatedSize>
bool toy::FixedString< allocatedSize >::ends_with ( char character) const
nodiscardconstexprnoexcept

Checks if the string ends with the specified character.

This method checks if the current string ends with the specified character. The comparison is performed on the last character of the string.

Parameters
characterThe character to check if this string ends with.
Returns
true if this string ends with the specified character, false otherwise.
Note
The comparison is case-sensitive.
If the string is empty, this method returns false.

◆ ends_with() [2/4]

template<size_t allocatedSize>
bool toy::FixedString< allocatedSize >::ends_with ( const char * string) const
nodiscardconstexprnoexcept

Checks if the string ends with the C string.

This method checks if the current string ends with the C string. The comparison is performed character by character from the end of the string.

Parameters
stringThe C string to check if this string ends with.
Returns
true if this string ends with the C string, false otherwise.
Precondition
The C string must not be null.
Note
The comparison is case-sensitive.
If the C string is empty, this method returns true.
If the C string is longer than this string, this method returns false.

◆ ends_with() [3/4]

template<size_t allocatedSize>
bool toy::FixedString< allocatedSize >::ends_with ( const FixedString< allocatedSize > & string) const
nodiscardconstexprnoexcept

Checks if the string ends with the specified string.

This method checks if the current string ends with the specified string. The comparison is performed character by character from the end of the string.

Parameters
stringThe string to check if this string ends with.
Returns
true if this string ends with the specified string, false otherwise.
Note
The comparison is case-sensitive.
If the specified string is empty, this method returns true.
If the specified string is longer than this string, returns false.

◆ ends_with() [4/4]

template<size_t allocatedSize>
template<StringLike stringType>
bool toy::FixedString< allocatedSize >::ends_with ( const stringType & string) const
nodiscardconstexprnoexcept

Checks if the string ends with a toy::StringLike object.

This method checks if the current string ends with a toy::StringLike object. The comparison is performed character by character from the end of the string.

Template Parameters
stringTypeThe type of the source string. Must satisfy the toy::StringLike concept.
Parameters
stringThe toy::StringLike object to check if this string ends with.
Returns
true if this string ends with a toy::StringLike object, false otherwise.
Note
The comparison is case-sensitive.
If a toy::StringLike object is empty, this method returns true.
If a toy::StringLike object is longer than this string, returns false.

◆ erase()

template<size_t allocatedSize>
FixedString< allocatedSize > & toy::FixedString< allocatedSize >::erase ( size_t offset,
size_t count = npos )
constexprnoexcept

Erases characters from the string starting at the specified offset.

This method removes characters from the string starting at the specified offset. The method can remove a specific number of characters or all characters from the offset to the end of the string. The remaining characters are shifted left to fill the gap, and the string size is updated accordingly.

Parameters
offsetThe starting position for erasing characters.
countThe number of characters to erase (default: npos). If count is npos or equal to the remaining length, then all characters from offset to the end are removed.
Returns
A reference to this string after erasing.
Precondition
The offset must be within the bounds of the current string.
The sum of offset and count must be less than or equal to the current string size.
Postcondition
The specified range of characters is removed from the string.
The string size is decreased by the number of erased characters.
All characters after the erased range are shifted left.
Note
If count is npos, all characters from offset to the end are removed.
If count is 0, the operation is a no-op.
Erasing from an empty string has no effect.

◆ find() [1/4]

template<size_t allocatedSize>
size_t toy::FixedString< allocatedSize >::find ( char character,
size_t position = 0 ) const
nodiscardconstexprnoexcept

Finds the first occurrence of a character in the string.

This method searches for the first occurrence of the specified character within this string, starting from the given position.

Parameters
characterThe character to search for.
positionThe position to start searching from (default: 0).
Returns
The position of the first occurrence of the character, or npos if not found.
Precondition
The position must be less than the string size.
Note
The search is case-sensitive.

◆ find() [2/4]

template<size_t allocatedSize>
size_t toy::FixedString< allocatedSize >::find ( const char * string,
size_t position = 0 ) const
nodiscardconstexprnoexcept

Finds the first occurrence of the C string in the string.

This method searches for the first occurrence of the C string within this string, starting from the given position.

Parameters
stringThe source C string to search for.
positionThe position to start searching from (default: 0).
Returns
The position of the first occurrence of the C string, or npos if not found.
Precondition
The position must be less than the string size.
The string must not be null.
Note
The search is case-sensitive.

◆ find() [3/4]

template<size_t allocatedSize>
size_t toy::FixedString< allocatedSize >::find ( const FixedString< allocatedSize > & string,
size_t position = 0 ) const
nodiscardconstexprnoexcept

Finds the first occurrence of other string in the string.

This method searches for the first occurrence of the specified string within this string, starting from the given position.

Parameters
stringThe source string to search for.
positionThe position to start searching from (default: 0).
Returns
The position of the first occurrence of other string, or npos if not found.
Precondition
The position must be less than the string size.
Note
The search is case-sensitive.

◆ find() [4/4]

template<size_t allocatedSize>
template<StringLike stringType>
size_t toy::FixedString< allocatedSize >::find ( const stringType & string,
size_t position = 0 ) const
nodiscardconstexprnoexcept

Finds the first occurrence of a toy::StringLike object in the string.

This method searches for the first occurrence of a toy::StringLike object within this string, starting from the given position.

Template Parameters
stringTypeThe type of the source string. Must satisfy the toy::StringLike concept.
Parameters
stringThe source toy::StringLike object to search for.
positionThe position to start searching from (default: 0).
Returns
The position of the first occurrence of a toy::StringLike object, or npos if not found.
Precondition
The position must be less than the string size.
Note
The search is case-sensitive.

◆ find_first_not_of() [1/4]

template<size_t allocatedSize>
size_t toy::FixedString< allocatedSize >::find_first_not_of ( char character,
size_t position = 0 ) const
nodiscardconstexprnoexcept

Finds the first occurrence of any character not equal to the specified character.

This method searches for the first occurrence of any character that is not equal to the specified character within this string, starting from the given position.

Parameters
characterThe character to exclude from search.
positionThe position to start searching from (default: 0).
Returns
The position of the first occurrence of any character not equal to character, or npos if not found.
Precondition
The position must be less than the string size.
Note
The search is case-sensitive.

◆ find_first_not_of() [2/4]

template<size_t allocatedSize>
size_t toy::FixedString< allocatedSize >::find_first_not_of ( const char * string,
size_t position = 0 ) const
nodiscardconstexprnoexcept

Finds the first occurrence of any character not from the C string.

This method searches for the first occurrence of any character that is not present in the C string within this string, starting from the given position.

Parameters
stringThe C string containing characters to exclude from search.
positionThe position to start searching from (default: 0).
Returns
The position of the first occurrence of any character not from the C string, or npos if not found.
Precondition
The position must be less than the string size.
The string must not be null.
Note
The search is case-sensitive.
If the C string is empty, returns position if within bounds, otherwise returns npos.

◆ find_first_not_of() [3/4]

template<size_t allocatedSize>
size_t toy::FixedString< allocatedSize >::find_first_not_of ( const FixedString< allocatedSize > & string,
size_t position = 0 ) const
nodiscardconstexprnoexcept

Finds the first occurrence of any character not from the specified string.

This method searches for the first occurrence of any character that is not present in the specified string within this string, starting from the given position.

Parameters
stringThe string containing characters to exclude from search.
positionThe position to start searching from (default: 0).
Returns
The position of the first occurrence of any character not from string, or npos if not found.
Precondition
The position must be less than the string size.
Note
The search is case-sensitive.
If string is empty, returns position if within bounds, otherwise returns npos.

◆ find_first_not_of() [4/4]

template<size_t allocatedSize>
template<StringLike stringType>
size_t toy::FixedString< allocatedSize >::find_first_not_of ( const stringType & string,
size_t position = 0 ) const
nodiscardconstexprnoexcept

Finds the first occurrence of any character not from a toy::StringLike object.

This method searches for the first occurrence of any character that is not present in a toy::StringLike object within this string, starting from the given position.

Template Parameters
stringTypeThe type of the source string. Must satisfy the toy::StringLike concept.
Parameters
stringThe toy::StringLike object containing characters to exclude from search.
positionThe position to start searching from (default: 0).
Returns
The position of the first occurrence of any character not from a toy::StringLike object, or npos if not found.
Precondition
The position must be less than the string size.
Note
The search is case-sensitive.
If a toy::StringLike object is empty, returns position if within bounds, otherwise returns npos.

◆ find_first_of() [1/4]

template<size_t allocatedSize>
size_t toy::FixedString< allocatedSize >::find_first_of ( char character,
size_t position = 0 ) const
nodiscardconstexprnoexcept

Finds the first occurrence of the specified character.

This method searches for the first occurrence of the specified character within this string, starting from the given position.

Parameters
characterThe character to search for.
positionThe position to start searching from (default: 0).
Returns
The position of the first occurrence of the character, or npos if not found.
Precondition
The position must be less than the string size.
Note
The search is case-sensitive.
This method is equivalent to find(character, position).

◆ find_first_of() [2/4]

template<size_t allocatedSize>
size_t toy::FixedString< allocatedSize >::find_first_of ( const char * string,
size_t position = 0 ) const
nodiscardconstexprnoexcept

Finds the first occurrence of any character from the C string.

This method searches for the first occurrence of any character from the C string within this string, starting from the given position.

Parameters
stringThe C string containing characters to search for.
positionThe position to start searching from (default: 0).
Returns
The position of the first occurrence of any character from the C string, or npos if not found.
Precondition
The position must be less than the string size.
The string must not be null.
Note
The search is case-sensitive.
If the C string is empty, this method returns npos.

◆ find_first_of() [3/4]

template<size_t allocatedSize>
size_t toy::FixedString< allocatedSize >::find_first_of ( const FixedString< allocatedSize > & string,
size_t position = 0 ) const
nodiscardconstexprnoexcept

Finds the first occurrence of any character from the specified string.

This method searches for the first occurrence of any character from the specified string within this string, starting from the given position.

Parameters
stringThe string containing characters to search for.
positionThe position to start searching from (default: 0).
Returns
The position of the first occurrence of any character from string, or npos if not found.
Precondition
The position must be less than the string size.
Note
The search is case-sensitive.
If string is empty, this method returns npos.

◆ find_first_of() [4/4]

template<size_t allocatedSize>
template<StringLike stringType>
size_t toy::FixedString< allocatedSize >::find_first_of ( const stringType & string,
size_t position = 0 ) const
nodiscardconstexprnoexcept

Finds the first occurrence of any character from a toy::StringLike object.

This method searches for the first occurrence of any character from a toy::StringLike object within this string, starting from the given position.

Template Parameters
stringTypeThe type of the source string. Must satisfy the toy::StringLike concept.
Parameters
stringThe toy::StringLike object containing characters to search for.
positionThe position to start searching from (default: 0).
Returns
The position of the first occurrence of any character from a toy::StringLike object, or npos if not found.
Precondition
The position must be less than the string size.
Note
The search is case-sensitive.
If a toy::StringLike object is empty, this method returns npos.

◆ find_last_not_of() [1/4]

template<size_t allocatedSize>
size_t toy::FixedString< allocatedSize >::find_last_not_of ( char character,
size_t position = npos ) const
nodiscardconstexprnoexcept

Finds the last occurrence of any character not equal to the specified character.

This method searches for the last occurrence of any character that is not equal to the specified character within this string, starting from the given position and searching backwards.

Parameters
characterThe character to exclude from search.
positionThe position to start searching from (default: npos). If npos, searches from the end.
Returns
The position of the last occurrence of any character not equal to character, or npos if not found.
Precondition
If position is not npos, it must be less than the string size.
Note
The search is case-sensitive.

◆ find_last_not_of() [2/4]

template<size_t allocatedSize>
size_t toy::FixedString< allocatedSize >::find_last_not_of ( const char * string,
size_t position = npos ) const
nodiscardconstexprnoexcept

Finds the last occurrence of any character not from the C string.

This method searches for the last occurrence of any character that is not present in the C string within this string, starting from the given position and searching backwards.

Parameters
stringThe C string containing characters to exclude from search.
positionThe position to start searching from (default: npos). If npos, searches from the end.
Returns
The position of the last occurrence of any character not from the C string, or npos if not found.
Precondition
If position is not npos, it must be less than the string size.
The string must not be null.
Note
The search is case-sensitive.
If the C string is empty, returns position if within bounds, otherwise returns npos.

◆ find_last_not_of() [3/4]

template<size_t allocatedSize>
size_t toy::FixedString< allocatedSize >::find_last_not_of ( const FixedString< allocatedSize > & string,
size_t position = npos ) const
nodiscardconstexprnoexcept

Finds the last occurrence of any character not from the specified string.

This method searches for the last occurrence of any character that is not present in the specified string within this string, starting from the given position and searching backwards.

Parameters
stringThe string containing characters to exclude from search.
positionThe position to start searching from (default: npos). If npos, searches from the end.
Returns
The position of the last occurrence of any character not from string, or npos if not found.
Precondition
If position is not npos, it must be less than the string size.
Note
The search is case-sensitive.
If string is empty, returns position if within bounds, otherwise returns npos.

◆ find_last_not_of() [4/4]

template<size_t allocatedSize>
template<StringLike stringType>
size_t toy::FixedString< allocatedSize >::find_last_not_of ( const stringType & string,
size_t position = npos ) const
nodiscardconstexprnoexcept

Finds the last occurrence of any character not from a toy::StringLike object.

This method searches for the last occurrence of any character that is not present in a toy::StringLike object within this string, starting from the given position and searching backwards.

Template Parameters
stringTypeThe type of the source string. Must satisfy the toy::StringLike concept.
Parameters
stringThe toy::StringLike object containing characters to exclude from search.
positionThe position to start searching from (default: npos). If npos, searches from the end.
Returns
The position of the last occurrence of any character not from a toy::StringLike object, or npos if not found.
Precondition
If position is not npos, it must be less than the string size.
Note
The search is case-sensitive.
If a toy::StringLike object is empty, returns position if within bounds, otherwise returns npos.

◆ find_last_of() [1/4]

template<size_t allocatedSize>
size_t toy::FixedString< allocatedSize >::find_last_of ( char character,
size_t position = npos ) const
nodiscardconstexprnoexcept

Finds the last occurrence of the specified character.

This method searches for the last occurrence of the specified character within this string, starting from the given position and searching backwards.

Parameters
characterThe character to search for.
positionThe position to start searching from (default: npos). If npos, searches from the end.
Returns
The position of the last occurrence of the character, or npos if not found.
Precondition
If position is not npos, it must be less than the string size.
Note
The search is case-sensitive.
This method is equivalent to rfind(char, size_t) const.
See also
rfind(char, size_t) const

◆ find_last_of() [2/4]

template<size_t allocatedSize>
size_t toy::FixedString< allocatedSize >::find_last_of ( const char * string,
size_t position = npos ) const
nodiscardconstexprnoexcept

Finds the last occurrence of any character from the C string.

This method searches for the last occurrence of any character from the C string within this string, starting from the given position and searching backwards.

Parameters
stringThe C string containing characters to search for.
positionThe position to start searching from (default: npos). If npos, searches from the end.
Returns
The position of the last occurrence of any character from the C string, or npos if not found.
Precondition
If position is not npos, it must be less than the string size.
The string must not be null.
Note
The search is case-sensitive.
If the C string is empty, this method returns npos.

◆ find_last_of() [3/4]

template<size_t allocatedSize>
size_t toy::FixedString< allocatedSize >::find_last_of ( const FixedString< allocatedSize > & string,
size_t position = npos ) const
nodiscardconstexprnoexcept

Finds the last occurrence of any character from the specified string.

This method searches for the last occurrence of any character from the specified string within this string, starting from the given position and searching backwards.

Parameters
stringThe string containing characters to search for.
positionThe position to start searching from (default: npos). If npos, searches from the end.
Returns
The position of the last occurrence of any character from string, or npos if not found.
Precondition
If position is not npos, it must be less than the string size.
Note
The search is case-sensitive.
If string is empty, this method returns npos.

◆ find_last_of() [4/4]

template<size_t allocatedSize>
template<StringLike stringType>
size_t toy::FixedString< allocatedSize >::find_last_of ( const stringType & string,
size_t position = npos ) const
nodiscardconstexprnoexcept

Finds the last occurrence of any character from a toy::StringLike object.

This method searches for the last occurrence of any character from a toy::StringLike object within this string, starting from the given position and searching backwards.

Template Parameters
stringTypeThe type of the source string. Must satisfy the toy::StringLike concept.
Parameters
stringThe toy::StringLike object containing characters to search for.
positionThe position to start searching from (default: npos). If npos, searches from the end.
Returns
The position of the last occurrence of any character from a toy::StringLike object, or npos if not found.
Precondition
If position is not npos, it must be less than the string size.
Note
The search is case-sensitive.
If a toy::StringLike object is empty, this method returns npos.

◆ front() [1/2]

template<size_t allocatedSize>
const char & toy::FixedString< allocatedSize >::front ( ) const
nodiscardconstexprnoexcept

Returns a const reference to the first character of the string.

This method provides read-only access to the first character of the string.

Returns
A const reference to the first character of the string.
Precondition
The string must not be empty.
Note
The returned reference is read-only and cannot modify the character.
Use the non-const overload to allow modification.
See also
front() noexcept

◆ front() [2/2]

template<size_t allocatedSize>
char & toy::FixedString< allocatedSize >::front ( )
nodiscardconstexprnoexcept

Returns a reference to the first character of the string.

This method provides direct access to the first character of the string.

Returns
A reference to the first character of the string.
Precondition
The string must not be empty.
Note
The returned reference allows modification of the character.
Use const version for read-only access.
See also
front() const

◆ insert() [1/4]

template<size_t allocatedSize>
FixedString< allocatedSize > & toy::FixedString< allocatedSize >::insert ( size_t index,
char character,
size_t count = 1 )
constexprnoexcept

Inserts a character repeated the given count times at the specified index.

This method inserts a character repeated the given count of times at the specified position. The insertion shifts existing characters to the right to make room for the new content.

Parameters
indexThe position where the characters should be inserted.
characterThe character to insert.
countThe number of times to repeat the character (default: 1).
Returns
A reference to this string after insertion.
Precondition
The index must be within the bounds of the current string.
The combined length after insertion must not exceed the allocated size.

◆ insert() [2/4]

template<size_t allocatedSize>
FixedString< allocatedSize > & toy::FixedString< allocatedSize >::insert ( size_t index,
const char * string )
constexprnoexcept

Inserts the C string at the specified index.

This method inserts the contents of the C string at the specified position. The insertion shifts existing characters to the right to make room for the new content.

Parameters
indexThe position where the C string should be inserted.
stringThe source C string to insert content from.
Returns
A reference to this string after insertion.
Precondition
The index must be within the bounds of the current string.
The combined length after insertion must not exceed the allocated size.
The source C string must not be null.
Postcondition
The C string is inserted at position index.
The string size is increased by the size of the inserted C string.
All characters after index are shifted right.

◆ insert() [3/4]

template<size_t allocatedSize>
FixedString< allocatedSize > & toy::FixedString< allocatedSize >::insert ( size_t index,
const FixedString< allocatedSize > & string )
constexprnoexcept

Inserts other string at the specified index.

This method inserts the contents from another string at the specified position. The insertion shifts existing characters to the right to make room for the new content.

Parameters
indexThe position where the string should be inserted.
stringThe source string to insert content from.
Returns
A reference to this string after insertion.
Precondition
The index must be within the bounds of the current string.
The combined length after insertion must not exceed the allocated size.
Postcondition
The string is inserted at position index.
The string size is increased by the size of the inserted string.
All characters after index are shifted right.

◆ insert() [4/4]

template<size_t allocatedSize>
template<StringLike stringType>
FixedString< allocatedSize > & toy::FixedString< allocatedSize >::insert ( size_t index,
const stringType & string )
constexprnoexcept

Inserts a toy::StringLike object at the specified index.

This method inserts the contents from a toy::StringLike object at the specified position. The insertion shifts existing characters to the right to make room for the new content.

Template Parameters
stringTypeThe type of the source string. Must satisfy the toy::StringLike concept.
Parameters
indexThe position where the toy::StringLike object should be inserted.
stringThe source toy::StringLike object to insert content from.
Returns
A reference to this string after insertion.
Precondition
The index must be within the bounds of the current string.
The combined length after insertion must not exceed the allocated size.
Postcondition
The toy::StringLike object is inserted at position index.
The string size is increased by the size of the inserted toy::StringLike object.
All characters after index are shifted right.

◆ length()

template<size_t allocatedSize>
size_t toy::FixedString< allocatedSize >::length ( ) const
nodiscardconstexprnoexcept

Returns the size of the string.

This method returns the current number of characters in the string, excluding the terminating null character. The length represents the actual length of the string content.

Returns
The number of characters in the string, excluding the terminating null character.
Note
This method is equivalent to size().
See also
size()

◆ max_size()

template<size_t allocatedSize>
size_t toy::FixedString< allocatedSize >::max_size ( ) const
nodiscardconstexprnoexcept

Returns the maximum size of the string.

This method returns the maximum possible size for the string, which is determined by the template parameter allocatedSize. The maximum size represents the size of the allocated buffer.

Returns
The maximum number of characters in the string, excluding the terminating null character.
Note
The maximum size is determined at compile time.
This method is equivalent to capacity() method.
See also
capacity()

◆ operator+=() [1/4]

template<size_t allocatedSize>
FixedString< allocatedSize > & toy::FixedString< allocatedSize >::operator+= ( char character)
constexprnoexcept

Appends a character to the end of this string.

This operator appends a character to the end of this string.

Parameters
characterThe character to append.
Returns
A reference to this string after appending.
Precondition
The current string size must be less than the allocated capacity.
Postcondition
The character is appended to the end of this string.
The string size is increased by 1.
See also
append(size_type, char)
push_back(char)

◆ operator+=() [2/4]

template<size_t allocatedSize>
FixedString< allocatedSize > & toy::FixedString< allocatedSize >::operator+= ( const char * string)
constexprnoexcept

Appends the C string to the end of this string.

This operator appends the contents of the C string to the end of this string.

Parameters
stringThe source C string to append content from.
Returns
A reference to this string after appending.
Precondition
The combined length after appending must not exceed the allocated size.
The source C string must not be null.
Postcondition
The string is extended with the appended content.

◆ operator+=() [3/4]

template<size_t allocatedSize>
FixedString< allocatedSize > & toy::FixedString< allocatedSize >::operator+= ( const FixedString< allocatedSize > & string)
constexprnoexcept

Appends other string to the end of this string.

This operator appends the contents of another string to the end of this string.

Parameters
stringThe source string to append content from.
Returns
A reference to this string after appending.
Precondition
The combined length after appending must not exceed the allocated size.
Postcondition
The string is appended to the end of this string.
The string size is increased by the size of the appended string.

◆ operator+=() [4/4]

template<size_t allocatedSize>
template<StringLike stringType>
FixedString< allocatedSize > & toy::FixedString< allocatedSize >::operator+= ( const stringType & string)
constexprnoexcept

Appends a toy::StringLike object to the end of this string.

This operator appends the contents of a toy::StringLike object to the end of this string.

Template Parameters
stringTypeThe type of the source string. Must satisfy the toy::StringLike concept.
Parameters
stringThe source toy::StringLike object to append content from.
Returns
A reference to this string after appending.
Precondition
The combined length after appending must not exceed the allocated size.
Postcondition
The string is extended with the appended content.

◆ operator=() [1/3]

template<size_t allocatedSize>
FixedString< allocatedSize > & toy::FixedString< allocatedSize >::operator= ( char character)
constexprnoexcept

Character assignment to this string.

This operator assigns a single character to this string, creating a string of length 1.

Parameters
characterThe character to assign.
Returns
A reference to this string after assignment.
Postcondition
This string contains only one specified character.
The string size equals 1.
Note
This is useful for resetting a string to contain only a single character.

◆ operator=() [2/3]

template<size_t allocatedSize>
FixedString< allocatedSize > & toy::FixedString< allocatedSize >::operator= ( const char * string)
constexprnoexcept

Copy assigns the C string to this string.

This operator assigns the content from the C string to this string. The assignment operation automatically determines the length of the source content and performs a deep copy of the string data and updates the size accordingly.

Parameters
stringThe source C string to copy content from.
Returns
A reference to this string after assignment.
Precondition
The source C string must not be null.
The source C string size must not exceed the allocated capacity.
Postcondition
This string contains the same content as the source C string.
The size of this string equals the size of the source C string.
Note
Self-assignment is handled correctly and safely.
See also
assign(const char *)

◆ operator=() [3/3]

template<size_t allocatedSize>
template<StringLike stringType>
FixedString< allocatedSize > & toy::FixedString< allocatedSize >::operator= ( const stringType & string)
constexprnoexcept

Copy assigns a toy::StringLike object to this string.

This operator assigns the content from a toy::StringLike object to this string. The assignment operation performs a deep copy of the string data and updates the size accordingly.

Template Parameters
stringTypeThe type of the source string. Must satisfy the toy::StringLike concept.
Parameters
stringThe source toy::StringLike object to copy content from.
Returns
A reference to this string after assignment.
Precondition
The source toy::StringLike object must be valid and properly initialized.
The source toy::StringLike object size must not exceed the allocated capacity.
Postcondition
This string contains the same content as the source toy::StringLike object.
The size of this string equals the size of the source toy::StringLike object.
Note
Self-assignment is handled correctly and safely.
See also
assign(const stringType &)

◆ operator[]() [1/2]

template<size_t allocatedSize>
const char & toy::FixedString< allocatedSize >::operator[] ( size_t offset) const
nodiscardconstexprnoexcept

Access a character in the string at a given offset.

This operator provides read-only access to a character at the specified offset within the string.

Parameters
offsetThe offset of the character to access in the string.
Returns
A const reference to the character at the specified offset.
Precondition
The offset must be less than the current string size.
Note
The returned reference is read-only and cannot modify the character.
Use the non-const overload to allow modification.

◆ operator[]() [2/2]

template<size_t allocatedSize>
char & toy::FixedString< allocatedSize >::operator[] ( size_t offset)
nodiscardconstexprnoexcept

Access a character in the string at a given offset.

This operator provides direct access to a character at the specified offset within the string.

Parameters
offsetThe offset of the character to access in the string.
Returns
A reference to the character at the specified offset.
Precondition
The offset must be less than the current string size.
Note
The returned reference allows modification of the character.
Use const version for read-only access.
See also
operator[](size_t offset) const, at()

◆ pop_back()

template<size_t allocatedSize>
void toy::FixedString< allocatedSize >::pop_back ( )
constexprnoexcept

Removes the last character from the string.

This method removes the last character from the current string, decreasing its size by one.

Precondition
The string must not be empty.
Postcondition
The string size is decreased by one.
Note
If the string is empty, the behavior is undefined.

◆ push_back()

template<size_t allocatedSize>
void toy::FixedString< allocatedSize >::push_back ( char character)
constexprnoexcept

Appends a single character to the end of the string.

This method appends a single character to the end of the current string, increasing its size by one.

Parameters
characterThe character to append.
Precondition
The combined length after append must not exceed the allocated size.
Note
This method is equivalent to operator+= but more explicit in intent.
See also
operator+=(char)

◆ replace() [1/4]

template<size_t allocatedSize>
FixedString< allocatedSize > & toy::FixedString< allocatedSize >::replace ( size_t pos,
size_t count,
char character,
size_t charactersCount = 1 )
constexprnoexcept

Replaces a portion of the string with a character repeated the given count of times.

This method replaces a specified range of characters in the current string with a character repeated the given count of times. The replacement operation shifts existing characters as needed to accommodate the new content.

Parameters
posThe starting position for the replacement.
countThe number of characters to replace.
characterThe character to replace with.
charactersCountThe number of times to repeat the character (default: 1).
Returns
A reference to this string after replacement.
Precondition
The pos must be within the bounds of the current string.
The replacement range ( pos + count ) must be within the string bounds.
The resulting string size must not exceed the allocated capacity.
Postcondition
The specified range is replaced with the character repeated charactersCount times.

◆ replace() [2/4]

template<size_t allocatedSize>
FixedString< allocatedSize > & toy::FixedString< allocatedSize >::replace ( size_t pos,
size_t count,
const char * string )
constexprnoexcept

Replaces a portion of the string with the C string.

This method replaces a specified range of characters in the current string with the contents of the C string. The replacement operation shifts existing characters as needed to accommodate the new content.

Parameters
posThe starting position for the replacement.
countThe number of characters to replace.
stringThe source C string to replace content from.
Returns
A reference to this string after replacement.
Precondition
The pos must be within the bounds of the current string.
The replacement range ( pos + count ) must be within the string bounds.
The source C string must not be null.
The resulting string size must not exceed the allocated capacity.
Postcondition
The specified range is replaced with the C string.

◆ replace() [3/4]

template<size_t allocatedSize>
FixedString< allocatedSize > & toy::FixedString< allocatedSize >::replace ( size_t pos,
size_t count,
const FixedString< allocatedSize > & string )
constexprnoexcept

Replaces a portion of the string with another string.

This method replaces a specified range of characters in the current string with the contents of another string. The replacement operation shifts existing characters as needed to accommodate the new content.

Parameters
posThe starting position for the replacement.
countThe number of characters to replace.
stringThe source string to replace content from.
Returns
A reference to this string after replacement.
Precondition
The pos must be within the bounds of the current string.
The replacement range ( pos + count ) must be within the string bounds.
The resulting string size must not exceed the allocated capacity.
Postcondition
The specified range is replaced with the string.

◆ replace() [4/4]

template<size_t allocatedSize>
template<StringLike stringType>
FixedString< allocatedSize > & toy::FixedString< allocatedSize >::replace ( size_t pos,
size_t count,
const stringType & string )
constexprnoexcept

Replaces a portion of the string with a toy::StringLike object.

This method replaces a specified range of characters in the current string with the contents of a toy::StringLike object. The replacement operation shifts existing characters as needed to accommodate the new content.

Template Parameters
stringTypeThe type of the source string. Must satisfy the toy::StringLike concept.
Parameters
posThe starting position for the replacement.
countThe number of characters to replace.
stringThe source toy::StringLike object to replace content from.
Returns
A reference to this string after replacement.
Precondition
The pos must be within the bounds of the current string.
The replacement range ( pos + count ) must be within the string bounds.
The resulting string size must not exceed the allocated capacity.
Postcondition
The specified range is replaced with the toy::StringLike object.

◆ rfind() [1/4]

template<size_t allocatedSize>
size_t toy::FixedString< allocatedSize >::rfind ( char character,
size_t position = npos ) const
nodiscardconstexprnoexcept

Finds the last occurrence of a character in the string.

This method searches for the last occurrence of the specified character within this string, starting from the given position and searching backwards.

Parameters
characterThe character to search for.
positionThe position to start searching from (default: npos). If npos, searches from the end.
Returns
The position of the last occurrence of the character, or npos if not found.
Precondition
The position must be less than the string size.
Note
The search is case-sensitive.

◆ rfind() [2/4]

template<size_t allocatedSize>
size_t toy::FixedString< allocatedSize >::rfind ( const char * string,
size_t position = npos ) const
nodiscardconstexprnoexcept

Finds the last occurrence of the C string in the string.

This method searches for the last occurrence of the C string within this string, starting from the given position and searching backwards.

Parameters
stringThe source C string to search for.
positionThe position to start searching from (default: npos). If npos, searches from the end.
Returns
The position of the last occurrence of the C string, or npos if not found.
Precondition
If position is not npos, it must be less than or equal to the maximum valid start index: the string size minus the size of the C string.
The string must not be null.
Note
The search is case-sensitive.
If the C string is empty, returns position if within bounds, otherwise returns the string size.

◆ rfind() [3/4]

template<size_t allocatedSize>
size_t toy::FixedString< allocatedSize >::rfind ( const FixedString< allocatedSize > & string,
size_t position = npos ) const
nodiscardconstexprnoexcept

Finds the last occurrence of other string in the string.

This method searches for the last occurrence of the specified string within this string, starting from the given position and searching backwards.

Parameters
stringThe source string to search for.
positionThe position to start searching from (default: npos). If npos, searches from the end.
Returns
The position of the last occurrence of other string, or npos if not found.
Precondition
If position is not npos, it must be less than or equal to the maximum valid start index: the string size minus the size of string.
Note
The search is case-sensitive.
If string is empty, returns position if within bounds, otherwise returns the string size.

◆ rfind() [4/4]

template<size_t allocatedSize>
template<StringLike stringType>
size_t toy::FixedString< allocatedSize >::rfind ( const stringType & string,
size_t position = npos ) const
nodiscardconstexprnoexcept

Finds the last occurrence of a toy::StringLike object in the string.

This method searches for the last occurrence of a toy::StringLike object within this string, starting from the given position and searching backwards.

Template Parameters
stringTypeThe type of the source string. Must satisfy the toy::StringLike concept.
Parameters
stringThe source toy::StringLike object to search for.
positionThe position to start searching from (default: npos). If npos, searches from the end.
Returns
The position of the last occurrence of a toy::StringLike object, or npos if not found.
Precondition
If position is not npos, it must be less than or equal to the maximum valid start index: the string size minus the size of a toy::StringLike object.
Note
The search is case-sensitive.
If a toy::StringLike object is empty, returns position if within bounds, otherwise returns the string size.

◆ size()

template<size_t allocatedSize>
size_t toy::FixedString< allocatedSize >::size ( ) const
nodiscardconstexprnoexcept

Returns the size of the string.

This method returns the current number of characters in the string, excluding the terminating null character. The size represents the actual length of the string content.

Returns
The number of characters in the string, excluding the terminating null character.
Note
This method is equivalent to length().
See also
length()

◆ starts_with() [1/4]

template<size_t allocatedSize>
bool toy::FixedString< allocatedSize >::starts_with ( char character) const
nodiscardconstexprnoexcept

Checks if the string starts with the specified character.

This method checks if the current string starts with the specified character. The comparison is performed on the first character of the string.

Parameters
characterThe character to check if this string starts with.
Returns
true if this string starts with the specified character, false otherwise.
Note
The comparison is case-sensitive.
If the string is empty, this method returns false.

◆ starts_with() [2/4]

template<size_t allocatedSize>
bool toy::FixedString< allocatedSize >::starts_with ( const char * string) const
nodiscardconstexprnoexcept

Checks if the string starts with the specified C string.

This method checks if the current string starts with the C string. The comparison is performed character by character from the beginning of the string.

Parameters
stringThe C string to check if this string starts with.
Returns
true if this string starts with the C string, false otherwise.
Precondition
The C string must not be null.
Note
The comparison is case-sensitive.
If the C string is empty, this method returns true.
If the C string is longer than this string, this method returns false.

◆ starts_with() [3/4]

template<size_t allocatedSize>
bool toy::FixedString< allocatedSize >::starts_with ( const FixedString< allocatedSize > & string) const
nodiscardconstexprnoexcept

Checks if the string starts with the specified string.

This method checks if the current string starts with the specified string. The comparison is performed character by character from the beginning of the string.

Parameters
stringThe string to check if this string starts with.
Returns
true if this string starts with the specified string, false otherwise.
Note
The comparison is case-sensitive.
If the specified string is empty, this method returns true.
If the specified string is longer than this string, returns false.

◆ starts_with() [4/4]

template<size_t allocatedSize>
template<StringLike stringType>
bool toy::FixedString< allocatedSize >::starts_with ( const stringType & string) const
nodiscardconstexprnoexcept

Checks if the string starts with a toy::StringLike object.

This method checks if the current string starts with a toy::StringLike object. The comparison is performed character by character from the beginning of the string.

Template Parameters
stringTypeThe type of the source string. Must satisfy the toy::StringLike concept.
Parameters
stringThe toy::StringLike object to check if this string starts with.
Returns
true if this string starts with a toy::StringLike object, false otherwise.
Note
The comparison is case-sensitive.
If a toy::StringLike object is empty, this method returns true.
If a toy::StringLike object is longer than this string, returns false.

◆ substr()

template<size_t allocatedSize>
FixedString< allocatedSize > toy::FixedString< allocatedSize >::substr ( size_t position = 0,
size_t count = npos ) const
nodiscardconstexprnoexcept

Returns a substring of this string.

This method creates and returns a new FixedString object containing a substring of this string, starting at the specified position and containing up to count characters.

Parameters
positionThe starting position of the substring (default: 0).
countThe maximum number of characters to include in the substring (default: npos). If npos or exceeds the remaining characters, all characters from position to the end are included.
Returns
A new FixedString object containing the specified substring.
Precondition
The position must be less than or equal to the string size.
Note
If position is equal to the string size, an empty string is returned.
If count is npos or exceeds remaining characters from position, all remaining characters are included.

◆ swap()

template<size_t allocatedSize>
void toy::FixedString< allocatedSize >::swap ( FixedString< allocatedSize > & string)
constexprnoexcept

Swaps the contents of this string with another string.

This method exchanges the contents of this string with another string of the same type. Both strings must have the same allocated size. The operation is performed efficiently by swapping the internal data and size information.

Parameters
stringThe string to swap contents with.
Postcondition
This string contains the contents that were in other string.
The other string contains the contents that were in this string.
The sizes of both strings are exchanged.
Note
Self-swap is handled correctly and safely (no-op).

◆ utf8_pop_back()

template<size_t allocatedSize>
void toy::FixedString< allocatedSize >::utf8_pop_back ( )
constexprnoexcept

Removes the last UTF-8 encoded character from the string.

This method removes the last UTF-8 encoded character from the current string. Unlike pop_back() which removes a single character, this method removes the complete UTF-8 encoded character, which may consist of multiple bytes.

Precondition
The string must not be empty.
The string must contain valid UTF-8 encoded text.
Postcondition
The string size is decreased by the number of bytes that constituted the last UTF-8 encoded character.
Note
If the string is empty, the behavior is undefined.
For ASCII strings, this method behaves identically to pop_back().
This method is useful for internationalized text with non-ASCII characters.

◆ utf8_size()

template<size_t allocatedSize>
size_t toy::FixedString< allocatedSize >::utf8_size ( ) const
inlinenodiscardnoexcept

Returns the size of the Unicode string in UTF-8 encoding.

This method returns the number of Unicode characters in the UTF-8 encoded string, excluding the terminating null character. For ASCII strings, this value equals the size() method. For UTF-8 encoded strings, this method counts the number of Unicode characters rather than bytes. The method validates UTF-8 encoding and counts only complete, well-formed Unicode characters.

Returns
The number of Unicode characters in the string, excluding the terminating null character.
Note
For ASCII strings, utf8_size() equals size().
For UTF-8 strings, utf8_size() may be less than size().
Invalid UTF-8 sequences are handled gracefully and may affect the count.
This method is useful for internationalization and text processing.

Member Data Documentation

◆ _storage

template<size_t allocatedSize>
FixedStringStorage<allocatedSize> toy::FixedString< allocatedSize >::_storage
private

Internal character buffer storing the string data.

◆ npos

template<size_t allocatedSize>
size_t toy::FixedString< allocatedSize >::npos = size_t(-1)
staticconstexpr

The special value, its exact meaning depends on the context.


The documentation for this class was generated from the following files: