xentara-utils v1.2
Xentara utilities library
|
A string that uses a statically allocated buffer for the data. More...
#include <string/StaticString.hpp>
Public Types | |
using | traits_type = CharTraits |
The character traits. | |
using | value_type = Char |
The character type. | |
using | size_type = std::size_t |
The type used for sizes. | |
using | difference_type = std::ptrdiff_t |
The type used for distances. | |
using | reference = value_type & |
A reference to an character. | |
using | const_reference = const value_type & |
A const reference to an character. | |
using | pointer = value_type * |
A pointer to an character. | |
using | const_pointer = const value_type * |
A const pointer to an character. | |
using | iterator = core::ContiguousIterator< pointer, BasicStaticString > |
An iterator. | |
using | const_iterator = core::ContiguousIterator< const_pointer, BasicStaticString > |
A const iterator. | |
using | reverse_iterator = std::reverse_iterator< iterator > |
An iterator for iterating in reverse order. | |
using | const_reverse_iterator = std::reverse_iterator< const_iterator > |
A const iterator for iterating in reverse order. | |
Public Member Functions | |
constexpr | BasicStaticString () noexcept |
Constructor for an empty string. | |
Character Access | |
constexpr | operator std::basic_string_view< Char, CharTraits > () const noexcept |
conversion to a string view | |
template<typename Allocator > | |
constexpr | operator std::basic_string< Char, CharTraits, Allocator > () const noexcept |
conversion to an std::string | |
constexpr auto | view () const noexcept -> std::basic_string_view< Char, CharTraits > |
Gets the data as a string view. | |
template<typename Allocator = std::allocator<Char>> | |
constexpr auto | str (const Allocator &allocator=Allocator()) const noexcept -> std::basic_string< Char, CharTraits, Allocator > |
Gets the data as an std::string. | |
constexpr auto | at (size_type index) const -> const_reference |
Accesses the character at a certain index. | |
constexpr auto | at (size_type index) -> reference |
Accesses the character at a certain index. | |
constexpr auto | operator[] (size_type index) const noexcept -> const_reference |
Subscript operator. | |
constexpr auto | operator[] (size_type index) noexcept -> reference |
Subscript operator. | |
constexpr auto | front () const noexcept -> const_reference |
Returns the first character. | |
constexpr auto | front () noexcept -> reference |
Returns the first character. | |
constexpr auto | back () const noexcept -> const_reference |
Returns the last character. | |
constexpr auto | back () noexcept -> reference |
Returns the last character. | |
constexpr auto | data () const noexcept -> const Char * |
Gets a pointer to the data. | |
constexpr auto | data () noexcept -> Char * |
Gets a pointer to the data. | |
constexpr auto | c_str () const noexcept -> const Char * |
Gets the data as a null terminated string. | |
Iterators | |
constexpr auto | begin () noexcept -> iterator |
Creates a begin iterator. | |
constexpr auto | begin () const noexcept -> const_iterator |
Creates a begin iterator. | |
constexpr auto | cbegin () const noexcept -> const_iterator |
Creates a begin iterator. | |
constexpr auto | end () noexcept -> iterator |
Creates an end iterator. | |
constexpr auto | end () const noexcept -> const_iterator |
Creates an end iterator. | |
constexpr auto | cend () const noexcept -> const_iterator |
Creates an end iterator. | |
constexpr auto | rbegin () noexcept -> reverse_iterator |
Creates a reverse begin iterator. | |
constexpr auto | rbegin () const noexcept -> const_reverse_iterator |
Creates a reverse begin iterator. | |
constexpr auto | crbegin () const noexcept -> const_reverse_iterator |
Creates a reverse begin iterator. | |
constexpr auto | rend () noexcept -> reverse_iterator |
Creates a reverse end iterator. | |
constexpr auto | rend () const noexcept -> const_reverse_iterator |
Creates a reverse end iterator. | |
constexpr auto | crend () const noexcept -> const_reverse_iterator |
Creates a reverse end iterator. | |
Buffer Access | |
constexpr auto | buffer () noexcept -> std::span< Char > |
Returns the internal buffer. | |
constexpr auto | bufferEnd () noexcept -> iterator |
Creates an end iterator for the entire buffer. | |
constexpr auto | bufferEnd () const noexcept -> const_iterator |
Creates an end iterator for the entire buffer. | |
constexpr auto | cBufferEnd () const noexcept -> const_iterator |
Creates an end iterator for the entire buffer. | |
constexpr auto | rBufferBegin () noexcept -> reverse_iterator |
Creates a reverse begin iterator for the entire buffer. | |
constexpr auto | rBufferBegin () const noexcept -> const_reverse_iterator |
Creates a reverse begin iterator for the entire buffer. | |
constexpr auto | crBufferBegin () const noexcept -> const_reverse_iterator |
Creates a reverse begin iterator for the entire buffer. | |
Modifiers | |
constexpr auto | resize (std::size_t size) noexcept -> void |
Resizes the string. | |
constexpr auto | clear () noexcept -> void |
Clears the string. | |
Size and Capacity | |
constexpr auto | empty () const noexcept -> bool |
Determines whether the string is empty. | |
constexpr auto | size () const noexcept -> std::size_t |
Gets the current size. | |
constexpr auto | capacity () const noexcept -> std::size_t |
Gets the capacity of the string. | |
static constexpr auto | max_size () noexcept -> std::size_t |
Gets the maximum size. | |
A string that uses a statically allocated buffer for the data.
This class behaves just like std::string, but doesn't require any heap allocation. Instead, the string data is allocated in a static buffer of a fixed size.
Char | The character type |
kCapacity | The capacity of the string |
CharTraits | The char traits used for interacting with the standard C++ library |
using xentara::utils::string::BasicStaticString< Char, kCapacity, CharTraits >::const_iterator = core::ContiguousIterator<const_pointer, BasicStaticString> |
A const iterator.
using xentara::utils::string::BasicStaticString< Char, kCapacity, CharTraits >::const_pointer = const value_type * |
A const pointer to an character.
using xentara::utils::string::BasicStaticString< Char, kCapacity, CharTraits >::const_reference = const value_type & |
A const reference to an character.
using xentara::utils::string::BasicStaticString< Char, kCapacity, CharTraits >::const_reverse_iterator = std::reverse_iterator<const_iterator> |
A const iterator for iterating in reverse order.
using xentara::utils::string::BasicStaticString< Char, kCapacity, CharTraits >::difference_type = std::ptrdiff_t |
The type used for distances.
using xentara::utils::string::BasicStaticString< Char, kCapacity, CharTraits >::iterator = core::ContiguousIterator<pointer, BasicStaticString> |
An iterator.
using xentara::utils::string::BasicStaticString< Char, kCapacity, CharTraits >::pointer = value_type * |
A pointer to an character.
using xentara::utils::string::BasicStaticString< Char, kCapacity, CharTraits >::reference = value_type & |
A reference to an character.
using xentara::utils::string::BasicStaticString< Char, kCapacity, CharTraits >::reverse_iterator = std::reverse_iterator<iterator> |
An iterator for iterating in reverse order.
using xentara::utils::string::BasicStaticString< Char, kCapacity, CharTraits >::size_type = std::size_t |
The type used for sizes.
using xentara::utils::string::BasicStaticString< Char, kCapacity, CharTraits >::traits_type = CharTraits |
The character traits.
using xentara::utils::string::BasicStaticString< Char, kCapacity, CharTraits >::value_type = Char |
The character type.
|
constexprnoexcept |
Constructor for an empty string.
|
constexpr |
Accesses the character at a certain index.
index | The index |
std::out_of_range | index is out of range |
|
constexpr |
Accesses the character at a certain index.
index | The index |
std::out_of_range | index is out of range |
|
constexprnoexcept |
Returns the last character.
|
constexprnoexcept |
Returns the last character.
|
constexprnoexcept |
Creates a begin iterator.
|
constexprnoexcept |
Creates a begin iterator.
|
constexprnoexcept |
Returns the internal buffer.
The returned buffer has enough room for capacity() characters. There is also room one character past the end of the buffer for a terminating null character.
It is safe to write past size(), but not past capacity() + 1. If you write data past size(), you must subsequently resize the string using resize(), or the terminating null character will be lost.
|
constexprnoexcept |
Creates an end iterator for the entire buffer.
|
constexprnoexcept |
Creates an end iterator for the entire buffer.
|
constexprnoexcept |
Gets the data as a null terminated string.
|
constexprnoexcept |
Gets the capacity of the string.
|
constexprnoexcept |
Creates a begin iterator.
|
constexprnoexcept |
Creates an end iterator for the entire buffer.
|
constexprnoexcept |
Creates an end iterator.
|
constexprnoexcept |
Clears the string.
|
constexprnoexcept |
Creates a reverse begin iterator.
|
constexprnoexcept |
Creates a reverse begin iterator for the entire buffer.
|
constexprnoexcept |
Creates a reverse end iterator.
|
constexprnoexcept |
Gets a pointer to the data.
|
constexprnoexcept |
Gets a pointer to the data.
The returned pointer points to a buffer that has enough room for capacity() characters, plus a terminating null character. It is safe to write past size(), but not past capacity() + 1. If you write data past size(), you must subsequently resize the string using resize(), or the terminating null character will be lost.
|
constexprnoexcept |
Determines whether the string is empty.
|
constexprnoexcept |
Creates an end iterator.
|
constexprnoexcept |
Creates an end iterator.
|
constexprnoexcept |
Returns the first character.
|
constexprnoexcept |
Returns the first character.
|
staticconstexprnoexcept |
Gets the maximum size.
|
constexprnoexcept |
conversion to an std::string
|
constexprnoexcept |
conversion to a string view
|
constexprnoexcept |
Subscript operator.
Returns a reference to the character at a certain index
index | The index |
|
constexprnoexcept |
Subscript operator.
Returns a reference to the character at a certain index
index | The index |
|
constexprnoexcept |
Creates a reverse begin iterator.
|
constexprnoexcept |
Creates a reverse begin iterator.
|
constexprnoexcept |
Creates a reverse begin iterator for the entire buffer.
|
constexprnoexcept |
Creates a reverse begin iterator for the entire buffer.
|
constexprnoexcept |
Creates a reverse end iterator.
|
constexprnoexcept |
Creates a reverse end iterator.
|
constexprnoexcept |
|
constexprnoexcept |
Gets the current size.
|
constexprnoexcept |
Gets the data as an std::string.
|
constexprnoexcept |
Gets the data as a string view.