class
#include <bn_string_view.h>
string_view Refers to a constant contiguous sequence of char values.
It doesn't store the char data like a string does.
Public types
- using value_type = char
- Value type alias.
- using size_type = int
- Size type alias.
- using difference_type = int
- Difference type alias.
- using reference = char&
- Reference alias.
- using const_reference = const char&
- Const reference alias.
- using pointer = char*
- Pointer alias.
- using const_pointer = const char*
- Const pointer alias.
- using iterator = char*
- Iterator alias.
- using const_iterator = const char*
- Const iterator alias.
- 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
Constructors, destructors, conversion operators
- string_view() defaulted constexpr
- Default constructor.
-
string_view(const istring_
base& string) constexpr - Constructor.
-
string_view(const_
pointer char_array_ptr) constexpr - Constructor.
-
string_view(const_
pointer char_array_ptr, size_ type char_array_size) constexpr - Constructor.
Public functions
-
auto front() const -> const_
reference constexpr - Returns a const reference to the first character.
-
auto back() const -> const_
reference constexpr - Returns a const reference to the last character.
-
auto data() const -> const_
pointer constexpr - Returns a const pointer to the first character of the internal storage.
-
auto begin() const -> const_
iterator constexpr - Returns a const iterator to the beginning of the string_
view. -
auto cbegin() const -> const_
iterator constexpr - Returns a const iterator to the beginning of the string_
view. -
auto end() const -> const_
iterator constexpr - Returns a const iterator to the end of the string_
view. -
auto cend() const -> const_
iterator constexpr - Returns a const iterator to the end of the string_
view. -
auto rbegin() const -> const_
reverse_ iterator constexpr - Returns a const reverse iterator to the end of the string_
view. -
auto crbegin() const -> const_
reverse_ iterator constexpr - Returns a const reverse iterator to the end of the string_
view. -
auto rend() const -> const_
reverse_ iterator constexpr - Returns a const reverse iterator to the beginning of the string_
view. -
auto crend() const -> const_
reverse_ iterator constexpr - Returns a const reverse iterator to the beginning of the string_
view. - auto empty() const -> bool constexpr
- Indicates if it doesn't contain any character.
-
auto size() const -> size_
type constexpr - Returns the number of characters in the string_
view. -
auto length() const -> size_
type constexpr - Returns the number of characters in the string_
view. -
auto operator[](size_
type position) const -> const_ reference constexpr - Returns a const reference to the character at the specified location.
-
auto at(size_
type position) const -> const_ reference constexpr - Returns a const reference to the character at the specified location.
-
auto substr() const -> string_
view constexpr - Returns a copy of this.
-
auto substr(size_
type position) const -> string_ view constexpr - Returns a string_
view of the substring [position, size() - position). -
auto substr(size_
type position, size_ type count) const -> string_ view constexpr - Returns a string_
view of the substring [position, position + count). -
void remove_prefix(size_
type count) constexpr - Shrinks the string_
view by moving its start forward by count characters. -
void remove_suffix(size_
type count) constexpr - Shrinks the string_
view by moving its end backward by count characters. -
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& other) 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& other) 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& other) 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& other) 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.
-
void swap(string_
view& other) constexpr - Exchanges the contents of this string_
view with those of the other one.
Friends
-
void swap(string_
view& a, string_ view& b) constexpr - Exchanges the contents of a string_
view with those of another one. -
auto operator==(const string_
view& a, const string_ view& b) -> bool constexpr - Equal operator.
-
auto operator<(const string_
view& a, const string_ view& b) -> bool constexpr - Less than operator.
-
auto operator>(const string_
view& a, const string_ view& b) -> bool constexpr - Greater than operator.
-
auto operator<=(const string_
view& a, const string_ view& b) -> bool constexpr - Less than or equal operator.
-
auto operator>=(const string_
view& a, const string_ view& b) -> bool constexpr - Greater than or equal operator.
Function documentation
bn:: string_view:: string_view(const istring_ base& string) constexpr
Constructor.
Parameters | |
---|---|
string | Base string to reference. |
bn:: string_view:: string_view(const_ pointer char_array_ptr) constexpr
Constructor.
Parameters | |
---|---|
char_array_ptr | Pointer to null-terminated characters array. |
bn:: string_view:: string_view(const_ pointer char_array_ptr,
size_ type char_array_size) constexpr
Constructor.
Parameters | |
---|---|
char_array_ptr | Pointer to characters array. |
char_array_size | Characters count of the characters array. |
const_ reference bn:: string_view:: operator[](size_ type position) const constexpr
Returns a const reference to the character at the specified location.
Parameters | |
---|---|
position | Character's position index. |
Returns | Const reference to the character at the specified location. |
const_ reference bn:: string_view:: at(size_ type position) const constexpr
Returns a const reference to the character at the specified location.
Parameters | |
---|---|
position | Character's position index. |
Returns | Const reference to the character at the specified location. |
bool bn:: string_view:: 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:: string_view:: starts_with(const string_ view& other) const constexpr
Checks if the referenced string begins with the given prefix.
Parameters | |
---|---|
other | Another string_ |
Returns | true if the referenced string begins with the given prefix; false otherwise. |
bool bn:: string_view:: 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:: string_view:: 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:: string_view:: ends_with(const string_ view& other) const constexpr
Checks if the referenced string ends with the given prefix.
Parameters | |
---|---|
other | Another string_ |
Returns | true if the referenced string ends with the given prefix; false otherwise. |
bool bn:: string_view:: 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:: string_view:: 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:: string_view:: contains(const string_ view& other) const constexpr
Checks if the referenced string contains the given substring.
Parameters | |
---|---|
other | Another string_ |
Returns | true if the referenced string contains the given substring; false otherwise. |
bool bn:: string_view:: 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:: string_view:: 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:: string_view:: find(const string_ view& other) const constexpr
Finds the first substring equal to the given character sequence.
Parameters | |
---|---|
other | Another string_ |
Returns | Position of the first character of the found substring, or npos if no such substring is found. |
size_ type bn:: string_view:: 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. |
void bn:: string_view:: swap(string_ view& other) constexpr
Exchanges the contents of this string_
Parameters | |
---|---|
other | string_ |
void swap(string_ view& a,
string_ view& b) constexpr
Exchanges the contents of a string_
Parameters | |
---|---|
a | First string_ |
b | Second string_ |
bool operator==(const string_ view& a,
const string_ view& b) constexpr
Equal operator.
Parameters | |
---|---|
a | First string_ |
b | Second string_ |
Returns | true if the first string_false . |
bool operator<(const string_ view& a,
const string_ view& b) constexpr
Less than operator.
Parameters | |
---|---|
a | First string_ |
b | Second string_ |
Returns | true if the first string_false . |
bool operator>(const string_ view& a,
const string_ view& b) constexpr
Greater than operator.
Parameters | |
---|---|
a | First string_ |
b | Second string_ |
Returns | true if the first string_false . |
bool operator<=(const string_ view& a,
const string_ view& b) constexpr
Less than or equal operator.
Parameters | |
---|---|
a | First string_ |
b | Second string_ |
Returns | true if the first string_false . |
bool operator>=(const string_ view& a,
const string_ view& b) constexpr
Greater than or equal operator.
Parameters | |
---|---|
a | First string_ |
b | Second string_ |
Returns | true if the first string_false . |