xentara-utils v2.0.4
The Xentara Utility Library
Loading...
Searching...
No Matches
xentara::utils::tparam::BasicString< Char, kSize > Struct Template Reference

A string literal that can be used as a template parameter. More...

#include <xentara/utils/tparam/String.hpp>

Public Types

using traits_type = std::char_traits< Char >
 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, BasicString >
 An iterator.
 
using const_iterator = core::ContiguousIterator< const_pointer, BasicString >
 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 BasicString (const Char(&string)[kSize+1]) noexcept
 Constructor that sets the string.
 
Character Access
constexpr operator std::basic_string_view< Char, traits_type > () const noexcept
 conversion to a string view
 
template<typename Allocator >
constexpr operator std::basic_string< Char, traits_type, Allocator > () const noexcept
 conversion to an std::string
 
constexpr auto view () const noexcept -> std::basic_string_view< Char, traits_type >
 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, traits_type, 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.
 
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 size.
 
constexpr auto length () const noexcept -> std::size_t
 Alias for size()
 
Finding Sub Strings
constexpr auto starts_with (std::basic_string_view< Char > string) const noexcept -> bool
 Checks whether the string starts with a certain text.
 
constexpr auto starts_with (Char character) const noexcept -> bool
 Checks whether the string starts with a certain character.
 
constexpr auto starts_with (const Char *string) const -> bool
 Checks whether the string starts with a certain text.
 
constexpr auto ends_with (std::basic_string_view< Char > string) const noexcept -> bool
 Checks whether the string ends with a certain text.
 
constexpr auto ends_with (Char character) const noexcept -> bool
 Checks whether the string ends with a certain character.
 
constexpr auto ends_with (const Char *string) const -> bool
 Checks whether the string ends with a certain text.
 

Detailed Description

template<tools::CharType Char, std::size_t kSize>
struct xentara::utils::tparam::BasicString< Char, kSize >

A string literal that can be used as a template parameter.

This class behaves just like std::string, but can be used as a template parameter.

Template Parameters
CharThe character type
kSizeThe size of the string

Member Typedef Documentation

◆ const_iterator

template<tools::CharType Char, std::size_t kSize>
using xentara::utils::tparam::BasicString< Char, kSize >::const_iterator = core::ContiguousIterator<const_pointer, BasicString>

A const iterator.

◆ const_pointer

template<tools::CharType Char, std::size_t kSize>
using xentara::utils::tparam::BasicString< Char, kSize >::const_pointer = const value_type *

A const pointer to an character.

◆ const_reference

template<tools::CharType Char, std::size_t kSize>
using xentara::utils::tparam::BasicString< Char, kSize >::const_reference = const value_type &

A const reference to an character.

◆ const_reverse_iterator

template<tools::CharType Char, std::size_t kSize>
using xentara::utils::tparam::BasicString< Char, kSize >::const_reverse_iterator = std::reverse_iterator<const_iterator>

A const iterator for iterating in reverse order.

◆ difference_type

template<tools::CharType Char, std::size_t kSize>
using xentara::utils::tparam::BasicString< Char, kSize >::difference_type = std::ptrdiff_t

The type used for distances.

◆ iterator

template<tools::CharType Char, std::size_t kSize>
using xentara::utils::tparam::BasicString< Char, kSize >::iterator = core::ContiguousIterator<pointer, BasicString>

An iterator.

◆ pointer

template<tools::CharType Char, std::size_t kSize>
using xentara::utils::tparam::BasicString< Char, kSize >::pointer = value_type *

A pointer to an character.

◆ reference

template<tools::CharType Char, std::size_t kSize>
using xentara::utils::tparam::BasicString< Char, kSize >::reference = value_type &

A reference to an character.

◆ reverse_iterator

template<tools::CharType Char, std::size_t kSize>
using xentara::utils::tparam::BasicString< Char, kSize >::reverse_iterator = std::reverse_iterator<iterator>

An iterator for iterating in reverse order.

◆ size_type

template<tools::CharType Char, std::size_t kSize>
using xentara::utils::tparam::BasicString< Char, kSize >::size_type = std::size_t

The type used for sizes.

◆ traits_type

template<tools::CharType Char, std::size_t kSize>
using xentara::utils::tparam::BasicString< Char, kSize >::traits_type = std::char_traits<Char>

The character traits.

◆ value_type

template<tools::CharType Char, std::size_t kSize>
using xentara::utils::tparam::BasicString< Char, kSize >::value_type = Char

The character type.

Constructor & Destructor Documentation

◆ BasicString()

template<tools::CharType Char, std::size_t kSize>
constexpr xentara::utils::tparam::BasicString< Char, kSize >::BasicString ( const Char(&)  string[kSize+1])
constexprnoexcept

Constructor that sets the string.

Member Function Documentation

◆ at() [1/2]

template<tools::CharType Char, std::size_t kSize>
constexpr auto xentara::utils::tparam::BasicString< Char, kSize >::at ( size_type  index) -> reference
constexpr

Accesses the character at a certain index.

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

◆ at() [2/2]

template<tools::CharType Char, std::size_t kSize>
constexpr auto xentara::utils::tparam::BasicString< Char, kSize >::at ( size_type  index) const -> const_reference
constexpr

Accesses the character at a certain index.

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

◆ back() [1/2]

template<tools::CharType Char, std::size_t kSize>
constexpr auto xentara::utils::tparam::BasicString< Char, kSize >::back ( ) const -> const_reference
constexprnoexcept

Returns the last character.

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

◆ back() [2/2]

template<tools::CharType Char, std::size_t kSize>
constexpr auto xentara::utils::tparam::BasicString< Char, kSize >::back ( ) -> reference
constexprnoexcept

Returns the last character.

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

◆ begin() [1/2]

template<tools::CharType Char, std::size_t kSize>
constexpr auto xentara::utils::tparam::BasicString< Char, kSize >::begin ( ) const -> const_iterator
constexprnoexcept

Creates a begin iterator.

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

◆ begin() [2/2]

template<tools::CharType Char, std::size_t kSize>
constexpr auto xentara::utils::tparam::BasicString< Char, kSize >::begin ( ) -> iterator
constexprnoexcept

Creates a begin iterator.

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

◆ c_str()

template<tools::CharType Char, std::size_t kSize>
constexpr auto xentara::utils::tparam::BasicString< Char, kSize >::c_str ( ) const -> const Char *
constexprnoexcept

Gets the data as a null terminated string.

Returns
The data as a null terminated string.

◆ cbegin()

template<tools::CharType Char, std::size_t kSize>
constexpr auto xentara::utils::tparam::BasicString< Char, kSize >::cbegin ( ) const -> const_iterator
constexprnoexcept

Creates a begin iterator.

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

◆ cend()

template<tools::CharType Char, std::size_t kSize>
constexpr auto xentara::utils::tparam::BasicString< Char, kSize >::cend ( ) const -> const_iterator
constexprnoexcept

Creates an end iterator.

Returns
An iterator pointing at the position past the last character

◆ crbegin()

template<tools::CharType Char, std::size_t kSize>
constexpr auto xentara::utils::tparam::BasicString< Char, kSize >::crbegin ( ) const -> const_reverse_iterator
constexprnoexcept

Creates a reverse begin iterator.

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

◆ crend()

template<tools::CharType Char, std::size_t kSize>
constexpr auto xentara::utils::tparam::BasicString< Char, kSize >::crend ( ) const -> const_reverse_iterator
constexprnoexcept

Creates a reverse end iterator.

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

◆ data() [1/2]

template<tools::CharType Char, std::size_t kSize>
constexpr auto xentara::utils::tparam::BasicString< Char, kSize >::data ( ) const -> const Char *
constexprnoexcept

Gets a pointer to the data.

Returns
A pointer to the data.

◆ data() [2/2]

template<tools::CharType Char, std::size_t kSize>
constexpr auto xentara::utils::tparam::BasicString< Char, kSize >::data ( ) -> Char *
constexprnoexcept

Gets a pointer to the data.

Returns
A pointer to the data.

◆ empty()

template<tools::CharType Char, std::size_t kSize>
constexpr auto xentara::utils::tparam::BasicString< Char, kSize >::empty ( ) const -> bool
constexprnoexcept

Determines whether the string is empty.

Returns
Whether the string is empty

◆ end() [1/2]

template<tools::CharType Char, std::size_t kSize>
constexpr auto xentara::utils::tparam::BasicString< Char, kSize >::end ( ) const -> const_iterator
constexprnoexcept

Creates an end iterator.

Returns
An iterator pointing at the position past the last character

◆ end() [2/2]

template<tools::CharType Char, std::size_t kSize>
constexpr auto xentara::utils::tparam::BasicString< Char, kSize >::end ( ) -> iterator
constexprnoexcept

Creates an end iterator.

Returns
An iterator pointing at the position past the last character

◆ ends_with() [1/3]

template<tools::CharType Char, std::size_t kSize>
constexpr auto xentara::utils::tparam::BasicString< Char, kSize >::ends_with ( Char  character) const -> bool
constexprnoexcept

Checks whether the string ends with a certain character.

◆ ends_with() [2/3]

template<tools::CharType Char, std::size_t kSize>
constexpr auto xentara::utils::tparam::BasicString< Char, kSize >::ends_with ( const Char *  string) const -> bool
constexpr

Checks whether the string ends with a certain text.

◆ ends_with() [3/3]

template<tools::CharType Char, std::size_t kSize>
constexpr auto xentara::utils::tparam::BasicString< Char, kSize >::ends_with ( std::basic_string_view< Char >  string) const -> bool
constexprnoexcept

Checks whether the string ends with a certain text.

◆ front() [1/2]

template<tools::CharType Char, std::size_t kSize>
constexpr auto xentara::utils::tparam::BasicString< Char, kSize >::front ( ) const -> const_reference
constexprnoexcept

Returns the first character.

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

◆ front() [2/2]

template<tools::CharType Char, std::size_t kSize>
constexpr auto xentara::utils::tparam::BasicString< Char, kSize >::front ( ) -> reference
constexprnoexcept

Returns the first character.

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

◆ length()

template<tools::CharType Char, std::size_t kSize>
constexpr auto xentara::utils::tparam::BasicString< Char, kSize >::length ( ) const -> std::size_t
constexprnoexcept

Alias for size()

Returns
The size

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

template<tools::CharType Char, std::size_t kSize>
template<typename Allocator >
constexpr xentara::utils::tparam::BasicString< Char, kSize >::operator std::basic_string< Char, traits_type, Allocator > ( ) const
constexprnoexcept

conversion to an std::string

Returns
A copy to the data

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

template<tools::CharType Char, std::size_t kSize>
constexpr xentara::utils::tparam::BasicString< Char, kSize >::operator std::basic_string_view< Char, traits_type > ( ) const
constexprnoexcept

conversion to a string view

Returns
A view to the data

◆ operator[]() [1/2]

template<tools::CharType Char, std::size_t kSize>
constexpr auto xentara::utils::tparam::BasicString< Char, kSize >::operator[] ( size_type  index) const -> const_reference
constexprnoexcept

Subscript operator.

Returns a reference to the character at a certain index

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

◆ operator[]() [2/2]

template<tools::CharType Char, std::size_t kSize>
constexpr auto xentara::utils::tparam::BasicString< Char, kSize >::operator[] ( size_type  index) -> reference
constexprnoexcept

Subscript operator.

Returns a reference to the character at a certain index

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

◆ rbegin() [1/2]

template<tools::CharType Char, std::size_t kSize>
constexpr auto xentara::utils::tparam::BasicString< Char, kSize >::rbegin ( ) const -> const_reverse_iterator
constexprnoexcept

Creates a reverse begin iterator.

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

◆ rbegin() [2/2]

template<tools::CharType Char, std::size_t kSize>
constexpr auto xentara::utils::tparam::BasicString< Char, kSize >::rbegin ( ) -> reverse_iterator
constexprnoexcept

Creates a reverse begin iterator.

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

◆ rend() [1/2]

template<tools::CharType Char, std::size_t kSize>
constexpr auto xentara::utils::tparam::BasicString< Char, kSize >::rend ( ) const -> const_reverse_iterator
constexprnoexcept

Creates a reverse end iterator.

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

◆ rend() [2/2]

template<tools::CharType Char, std::size_t kSize>
constexpr auto xentara::utils::tparam::BasicString< Char, kSize >::rend ( ) -> reverse_iterator
constexprnoexcept

Creates a reverse end iterator.

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

◆ size()

template<tools::CharType Char, std::size_t kSize>
constexpr auto xentara::utils::tparam::BasicString< Char, kSize >::size ( ) const -> std::size_t
constexprnoexcept

Gets the size.

Returns
The size

◆ starts_with() [1/3]

template<tools::CharType Char, std::size_t kSize>
constexpr auto xentara::utils::tparam::BasicString< Char, kSize >::starts_with ( Char  character) const -> bool
constexprnoexcept

Checks whether the string starts with a certain character.

◆ starts_with() [2/3]

template<tools::CharType Char, std::size_t kSize>
constexpr auto xentara::utils::tparam::BasicString< Char, kSize >::starts_with ( const Char *  string) const -> bool
constexpr

Checks whether the string starts with a certain text.

◆ starts_with() [3/3]

template<tools::CharType Char, std::size_t kSize>
constexpr auto xentara::utils::tparam::BasicString< Char, kSize >::starts_with ( std::basic_string_view< Char >  string) const -> bool
constexprnoexcept

Checks whether the string starts with a certain text.

◆ str()

template<tools::CharType Char, std::size_t kSize>
template<typename Allocator = std::allocator<Char>>
constexpr auto xentara::utils::tparam::BasicString< Char, kSize >::str ( const Allocator &  allocator = Allocator()) const -> std::basic_string<Char, traits_type, Allocator>
constexprnoexcept

Gets the data as an std::string.

Returns
The data as a null terminated string.

◆ view()

template<tools::CharType Char, std::size_t kSize>
constexpr auto xentara::utils::tparam::BasicString< Char, kSize >::view ( ) const -> std::basic_string_view<Char, traits_type>
constexprnoexcept

Gets the data as a string view.

Returns
The data as a string view.