bn::istring class
#include <bn_string.h>

Base class of bn::string.

Can be used as a reference type for all bn::string containers.

Base classes

class istring_base
Base class of bn::istring.

Derived classes

template<int MaxSize>
class string
std::string like container with a fixed size buffer.

Public types

using reverse_iterator = bn::reverse_iterator<iterator>
Reverse iterator alias.
using const_reverse_iterator = bn::reverse_iterator<const_iterator>
Const reverse iterator alias.

Public static variables

static size_type npos constexpr
Exact meaning depends on context.

Public functions

auto operator=(const istring_base& other) -> istring& constexpr
Copy assignment operator.
auto operator=(const string_view& view) -> istring& constexpr
Copy assignment operator.
auto operator=(const_pointer char_array_ptr) -> istring& constexpr
Copy assignment operator.
auto rbegin() const -> const_reverse_iterator constexpr
Returns a const reverse iterator to the end of the characters data.
auto rbegin() -> reverse_iterator constexpr
Returns a reverse iterator to the end of the characters data.
auto rend() const -> const_reverse_iterator constexpr
Returns a const reverse iterator to the beginning of the characters data.
auto rend() -> reverse_iterator constexpr
Returns a reverse iterator to the beginning of the characters data.
auto crbegin() const -> const_reverse_iterator constexpr
Returns a const reverse iterator to the end of the characters data.
auto crend() const -> const_reverse_iterator constexpr
Returns a const reverse iterator to the beginning of the characters data.
auto operator[](size_type index) const -> const_reference constexpr
Returns a const reference to the character stored at the specified index.
auto operator[](size_type index) -> reference constexpr
Returns a reference to the character stored at the specified index.
auto at(size_type index) const -> const_reference constexpr
Returns a const reference to the character stored at the specified index.
auto at(size_type index) -> reference constexpr
Returns a reference to the character stored at the specified index.
auto front() const -> const_reference constexpr
Returns a const reference to the first character.
auto front() -> reference constexpr
Returns a reference to the first character.
auto back() const -> const_reference constexpr
Returns a const reference to the last character.
auto back() -> reference constexpr
Returns a reference to the last character.
auto starts_with(value_type value) const -> bool constexpr
Checks if the referenced string begins with the given prefix.
auto starts_with(const string_view& view) const -> bool constexpr
Checks if the referenced string begins with the given prefix.
auto starts_with(const_pointer char_array_ptr) const -> bool constexpr
Checks if the referenced string begins with the given prefix.
auto ends_with(value_type value) const -> bool constexpr
Checks if the referenced string ends with the given prefix.
auto ends_with(const string_view& view) const -> bool constexpr
Checks if the referenced string ends with the given prefix.
auto ends_with(const_pointer char_array_ptr) const -> bool constexpr
Checks if the referenced string ends with the given prefix.
auto contains(value_type value) const -> bool constexpr
Checks if the referenced string contains the given character.
auto contains(const string_view& view) const -> bool constexpr
Checks if the referenced string contains the given substring.
auto contains(const_pointer char_array_ptr) const -> bool constexpr
Checks if the referenced string contains the given substring.
auto find(value_type value) const -> size_type constexpr
Finds the first substring equal to the given character.
auto find(const string_view& view) const -> size_type constexpr
Finds the first substring equal to the given character sequence.
auto find(const_pointer char_array_ptr) const -> size_type constexpr
Finds the first substring equal to the given character sequence.
auto assign(const istring_base& other) -> istring& constexpr
Replaces the contents of the istring.
auto assign(const istring_base& other, size_type position) -> istring& constexpr
Replaces the contents of the istring.
auto assign(const istring_base& other, size_type position, size_type count) -> istring& constexpr
Replaces the contents of the istring.
auto assign(value_type value) -> istring& constexpr
Replaces the contents of the istring.
auto assign(const string_view& view) -> istring& constexpr
Replaces the contents of the istring.
auto assign(const string_view& view, size_type position) -> istring& constexpr
Replaces the contents of the istring.
auto assign(const string_view& view, size_type position, size_type count) -> istring& constexpr
Replaces the contents of the istring.
auto assign(const_pointer char_array_ptr) -> istring& constexpr
Replaces the contents of the istring.
auto assign(const_pointer char_array_ptr, size_type char_array_size) -> istring& constexpr
Replaces the contents of the istring.
auto assign(size_type count, value_type value) -> istring& constexpr
Replaces the contents of the istring with count copies of character value.
auto assign(const_iterator first, const_iterator last) -> istring& constexpr
Replaces the contents of the istring with the characters in the range [first, last).
void push_back(value_type value) constexpr
Inserts a character at the end of the istring.
void pop_back() constexpr
Removes the last character of the istring.
auto append(const istring_base& other) -> istring& constexpr
Appends additional characters to the istring.
auto append(const istring_base& other, size_type position) -> istring& constexpr
Appends additional characters to the istring.
auto append(const istring_base& other, size_type position, size_type count) -> istring& constexpr
Appends additional characters to the istring.
auto append(value_type value) -> istring& constexpr
Appends an additional character to the istring.
auto append(const string_view& view) -> istring& constexpr
Appends additional characters to the istring.
auto append(const string_view& view, size_type position) -> istring& constexpr
Appends additional characters to the istring.
auto append(const string_view& view, size_type position, size_type count) -> istring& constexpr
Appends additional characters to the istring.
auto append(const_pointer char_array_ptr) -> istring& constexpr
Appends additional characters to the istring.
auto append(const_pointer char_array_ptr, size_type char_array_size) -> istring& constexpr
Appends additional characters to the istring.
auto append(size_type count, value_type value) -> istring& constexpr
Appends additional characters to the istring.
auto append(const_iterator first, const_iterator last) -> istring& constexpr
Appends additional characters to the istring.
auto erase(const_iterator position) -> iterator constexpr
Erases a character.
auto erase(const_iterator first, const_iterator last) -> iterator constexpr
Erases a range of characters.
void resize(size_type count) constexpr
Resizes the istring.
void resize(size_type count, value_type value) constexpr
Resizes the istring.
void shrink(size_type count) constexpr
Resizes the istring to a size less or equal than the previous one.
void swap(istring& other) constexpr
Exchanges the contents of this istring with those of the other one.
auto operator+=(const istring_base& other) -> istring& constexpr
Appends additional characters to the istring.
auto operator+=(value_type value) -> istring& constexpr
Appends an additional character to the istring.
auto operator+=(const string_view& view) -> istring& constexpr
Appends additional characters to the istring.
auto operator+=(const_pointer char_array_ptr) -> istring& constexpr
Appends additional characters to the istring.

Friends

void swap(istring& a, istring& b) constexpr
Exchanges the contents of a istring with those of another one.

Function documentation

istring& bn::istring::operator=(const istring_base& other) constexpr

Copy assignment operator.

Parameters
other istring_base to copy.
Returns Reference to this.

istring& bn::istring::operator=(const string_view& view) constexpr

Copy assignment operator.

Parameters
view string_view to copy.
Returns Reference to this.

istring& bn::istring::operator=(const_pointer char_array_ptr) constexpr

Copy assignment operator.

Parameters
char_array_ptr Pointer to null-terminated characters array.
Returns Reference to this.

bool bn::istring::starts_with(value_type value) const constexpr

Checks if the referenced string begins with the given prefix.

Parameters
value Single character.
Returns true if the referenced string begins with the given prefix; false otherwise.

bool bn::istring::starts_with(const string_view& view) const constexpr

Checks if the referenced string begins with the given prefix.

Parameters
view string_view to check.
Returns true if the referenced string begins with the given prefix; false otherwise.

bool bn::istring::starts_with(const_pointer char_array_ptr) const constexpr

Checks if the referenced string begins with the given prefix.

Parameters
char_array_ptr Pointer to null-terminated characters array.
Returns true if the referenced string begins with the given prefix; false otherwise.

bool bn::istring::ends_with(value_type value) const constexpr

Checks if the referenced string ends with the given prefix.

Parameters
value Single character.
Returns true if the referenced string ends with the given prefix; false otherwise.

bool bn::istring::ends_with(const string_view& view) const constexpr

Checks if the referenced string ends with the given prefix.

Parameters
view string_view to check.
Returns true if the referenced string ends with the given prefix; false otherwise.

bool bn::istring::ends_with(const_pointer char_array_ptr) const constexpr

Checks if the referenced string ends with the given prefix.

Parameters
char_array_ptr Pointer to null-terminated characters array.
Returns true if the referenced string ends with the given prefix; false otherwise.

bool bn::istring::contains(value_type value) const constexpr

Checks if the referenced string contains the given character.

Parameters
value Single character.
Returns true if the referenced string contains the given character; false otherwise.

bool bn::istring::contains(const string_view& view) const constexpr

Checks if the referenced string contains the given substring.

Parameters
view string_view to check.
Returns true if the referenced string contains the given substring; false otherwise.

bool bn::istring::contains(const_pointer char_array_ptr) const constexpr

Checks if the referenced string contains the given substring.

Parameters
char_array_ptr Pointer to null-terminated characters array.
Returns true if the referenced string contains the given substring; false otherwise.

size_type bn::istring::find(value_type value) const constexpr

Finds the first substring equal to the given character.

Parameters
value Single character.
Returns Position of the first character of the found substring, or npos if no such substring is found.

size_type bn::istring::find(const string_view& view) const constexpr

Finds the first substring equal to the given character sequence.

Parameters
view string_view to search.
Returns Position of the first character of the found substring, or npos if no such substring is found.

size_type bn::istring::find(const_pointer char_array_ptr) const constexpr

Finds the first substring equal to the given character sequence.

Parameters
char_array_ptr Pointer to null-terminated characters array.
Returns Position of the first character of the found substring, or npos if no such substring is found.

istring& bn::istring::assign(const istring_base& other) constexpr

Replaces the contents of the istring.

Parameters
other istring_base replacement.
Returns Reference to this.

istring& bn::istring::assign(const istring_base& other, size_type position) constexpr

Replaces the contents of the istring.

Parameters
other istring_base replacement.
position Starting character index.
Returns Reference to this.

istring& bn::istring::assign(const istring_base& other, size_type position, size_type count) constexpr

Replaces the contents of the istring.

Parameters
other istring_base replacement.
position Starting character index.
count Number of characters to assign.
Returns Reference to this.

istring& bn::istring::assign(value_type value) constexpr

Replaces the contents of the istring.

Parameters
value Character replacement.
Returns Reference to this.

istring& bn::istring::assign(const string_view& view) constexpr

Replaces the contents of the istring.

Parameters
view string_view replacement.
Returns Reference to this.

istring& bn::istring::assign(const string_view& view, size_type position) constexpr

Replaces the contents of the istring.

Parameters
view string_view replacement.
position Starting character index.
Returns Reference to this.

istring& bn::istring::assign(const string_view& view, size_type position, size_type count) constexpr

Replaces the contents of the istring.

Parameters
view string_view replacement.
position Starting character index.
count Number of characters to assign.
Returns Reference to this.

istring& bn::istring::assign(const_pointer char_array_ptr) constexpr

Replaces the contents of the istring.

Parameters
char_array_ptr Pointer to null-terminated characters array replacement.
Returns Reference to this.

istring& bn::istring::assign(const_pointer char_array_ptr, size_type char_array_size) constexpr

Replaces the contents of the istring.

Parameters
char_array_ptr Pointer to null-terminated characters array replacement.
char_array_size Characters count of the characters array.
Returns Reference to this.

istring& bn::istring::assign(size_type count, value_type value) constexpr

Replaces the contents of the istring with count copies of character value.

Parameters
count New size.
value Character replacement.
Returns Reference to this.

istring& bn::istring::assign(const_iterator first, const_iterator last) constexpr

Replaces the contents of the istring with the characters in the range [first, last).

Parameters
first First element of the range.
last Last element of the range.
Returns Reference to this.

void bn::istring::push_back(value_type value) constexpr

Inserts a character at the end of the istring.

Parameters
value Character to insert.

istring& bn::istring::append(const istring_base& other) constexpr

Appends additional characters to the istring.

Parameters
other istring_base to append.
Returns Reference to this.

istring& bn::istring::append(const istring_base& other, size_type position) constexpr

Appends additional characters to the istring.

Parameters
other istring_base to append.
position Starting character index.
Returns Reference to this.

istring& bn::istring::append(const istring_base& other, size_type position, size_type count) constexpr

Appends additional characters to the istring.

Parameters
other istring_base to append.
position Starting character index.
count Number of characters to append.
Returns Reference to this.

istring& bn::istring::append(value_type value) constexpr

Appends an additional character to the istring.

Parameters
value Character to append.
Returns Reference to this.

istring& bn::istring::append(const string_view& view) constexpr

Appends additional characters to the istring.

Parameters
view string_view to append.
Returns Reference to this.

istring& bn::istring::append(const string_view& view, size_type position) constexpr

Appends additional characters to the istring.

Parameters
view string_view to append.
position Starting character index.
Returns Reference to this.

istring& bn::istring::append(const string_view& view, size_type position, size_type count) constexpr

Appends additional characters to the istring.

Parameters
view string_view to append.
position Starting character index.
count Number of characters to append.
Returns Reference to this.

istring& bn::istring::append(const_pointer char_array_ptr) constexpr

Appends additional characters to the istring.

Parameters
char_array_ptr Pointer to null-terminated characters array.
Returns Reference to this.

istring& bn::istring::append(const_pointer char_array_ptr, size_type char_array_size) constexpr

Appends additional characters to the istring.

Parameters
char_array_ptr Pointer to characters array.
char_array_size Characters count of the characters array.
Returns Reference to this.

istring& bn::istring::append(size_type count, value_type value) constexpr

Appends additional characters to the istring.

Parameters
count Number of characters to append.
value Character to append.
Returns Reference to this.

istring& bn::istring::append(const_iterator first, const_iterator last) constexpr

Appends additional characters to the istring.

Parameters
first First element of the range to append.
last Last element of the range to append.
Returns Reference to this.

iterator bn::istring::erase(const_iterator position) constexpr

Erases a character.

Parameters
position Iterator to the character to erase.
Returns Iterator following the erased character.

iterator bn::istring::erase(const_iterator first, const_iterator last) constexpr

Erases a range of characters.

Parameters
first Iterator to the first character to erase.
last Iterator to the last character to erase.
Returns Iterator following the last erased character.

The range includes all the characters between first and last, including the character pointed by first, but not the one pointed by last.

void bn::istring::resize(size_type count) constexpr

Resizes the istring.

Parameters
count New size.

void bn::istring::resize(size_type count, value_type value) constexpr

Resizes the istring.

Parameters
count New size.
value Character to fill new elements with.

void bn::istring::shrink(size_type count) constexpr

Resizes the istring to a size less or equal than the previous one.

Parameters
count New size.

void bn::istring::swap(istring& other) constexpr

Exchanges the contents of this istring with those of the other one.

Parameters
other istring to exchange the contents with.

istring& bn::istring::operator+=(const istring_base& other) constexpr

Appends additional characters to the istring.

Parameters
other istring_base to append.
Returns Reference to this.

istring& bn::istring::operator+=(value_type value) constexpr

Appends an additional character to the istring.

Parameters
value Character to append.
Returns Reference to this.

istring& bn::istring::operator+=(const string_view& view) constexpr

Appends additional characters to the istring.

Parameters
view string_view to append.
Returns Reference to this.

istring& bn::istring::operator+=(const_pointer char_array_ptr) constexpr

Appends additional characters to the istring.

Parameters
char_array_ptr Pointer to null-terminated characters array.
Returns Reference to this.

void swap(istring& a, istring& b) constexpr

Exchanges the contents of a istring with those of another one.

Parameters
a First istring to exchange the contents with.
b Second istring to exchange the contents with.