#include <bn_string.h>
template<int MaxSize>
string class
std::string
like container with a fixed size buffer.
Template parameters | |
---|---|
MaxSize | Maximum number of characters that can be stored. |
It doesn't throw exceptions. Instead, asserts are used to ensure valid usage.
Base classes
- class istring
- Base class of bn::
string.
Constructors, destructors, conversion operators
- string()
- Default constructor.
- string(const string& other)
- Copy constructor.
-
string(const istring_
base& other) - Copy constructor.
-
string(const istring_
base& other, size_ type position) - Copy constructor.
-
string(const istring_
base& other, size_ type position, size_ type count) - Copy constructor.
-
string(const string_
view& view) - Copy constructor.
-
string(const_
pointer char_array_ptr) - Copy constructor.
-
string(const_
pointer char_array_ptr, size_ type char_array_size) - Copy constructor.
-
string(size_
type count, value_ type value) - Constructs a string with count copies of character value.
-
string(const_
iterator first, const_ iterator last) - Constructs a string with the characters in the range [first, last).
Public functions
- auto operator=(const string& other) -> string&
- Copy assignment operator.
-
auto operator=(const istring_
base& other) -> string& - Copy assignment operator.
-
auto operator=(const string_
view& view) -> string& - Copy assignment operator.
-
auto operator=(const_
pointer char_array_ptr) -> string& - Copy assignment operator.
- auto substr() const -> string
- Returns a copy of this.
-
auto substr(size_
type position) const -> string - Returns the substring [position, size() - position).
-
auto substr(size_
type position, size_ type count) const -> string - Returns the substring [position, position + count).
Friends
-
auto operator+(const string& a,
const istring_
base& b) -> string - Concatenates a string and a istring_
base. -
auto operator+(const string& a,
value_
type b) -> string - Concatenates a string and a character.
-
auto operator+(const string& a,
const string_
view& b) -> string - Concatenates two strings.
-
auto operator+(const string& a,
const_
pointer b) -> string - Concatenates two strings.
Function documentation
template<int MaxSize>
bn:: string<MaxSize>:: string(const istring_ base& other)
Copy constructor.
Parameters | |
---|---|
other | istring_ |
template<int MaxSize>
bn:: string<MaxSize>:: string(const istring_ base& other,
size_ type position)
Copy constructor.
Parameters | |
---|---|
other | istring_ |
position | Starting character index. |
template<int MaxSize>
bn:: string<MaxSize>:: string(const istring_ base& other,
size_ type position,
size_ type count)
Copy constructor.
Parameters | |
---|---|
other | istring_ |
position | Starting character index. |
count | Number of characters to copy. |
template<int MaxSize>
bn:: string<MaxSize>:: string(const string_ view& view)
Copy constructor.
Parameters | |
---|---|
view | string_ |
template<int MaxSize>
bn:: string<MaxSize>:: string(const_ pointer char_array_ptr)
Copy constructor.
Parameters | |
---|---|
char_array_ptr | Pointer to null-terminated characters array. |
template<int MaxSize>
bn:: string<MaxSize>:: string(const_ pointer char_array_ptr,
size_ type char_array_size)
Copy constructor.
Parameters | |
---|---|
char_array_ptr | Pointer to characters array. |
char_array_size | Characters count of the characters array. |
template<int MaxSize>
bn:: string<MaxSize>:: string(size_ type count,
value_ type value)
Constructs a string with count copies of character value.
Parameters | |
---|---|
count | Number of characters to assign. |
value | Character to assign. |
template<int MaxSize>
bn:: string<MaxSize>:: string(const_ iterator first,
const_ iterator last)
Constructs a string with the characters in the range [first, last).
Parameters | |
---|---|
first | First element of the range. |
last | Last element of the range. |
template<int MaxSize>
string& bn:: string<MaxSize>:: operator=(const istring_ base& other)
Copy assignment operator.
Parameters | |
---|---|
other | istring_ |
Returns | Reference to this. |
template<int MaxSize>
string& bn:: string<MaxSize>:: operator=(const string_ view& view)
Copy assignment operator.
Parameters | |
---|---|
view | string_ |
Returns | Reference to this. |
template<int MaxSize>
string& bn:: string<MaxSize>:: operator=(const_ pointer char_array_ptr)
Copy assignment operator.
Parameters | |
---|---|
char_array_ptr | Pointer to null-terminated characters array. |
Returns | Reference to this. |
template<int MaxSize>
string operator+(const string& a,
const istring_ base& b)
Concatenates a string and a istring_
Parameters | |
---|---|
a | First string to concatenate. |
b | Second istring_ |
Returns | string containing characters from a followed by the characters from b. |
template<int MaxSize>
string operator+(const string& a,
value_ type b)
Concatenates a string and a character.
Parameters | |
---|---|
a | First string to concatenate. |
b | Second character to concatenate. |
Returns | string containing characters from a followed by b. |
template<int MaxSize>
string operator+(const string& a,
const string_ view& b)
Concatenates two strings.
Parameters | |
---|---|
a | First string to concatenate. |
b | Second string_ |
Returns | string containing characters from a followed by the characters from b. |
template<int MaxSize>
string operator+(const string& a,
const_ pointer b)
Concatenates two strings.
Parameters | |
---|---|
a | First string to concatenate. |
b | Second pointer to null-terminated characters array to concatenate. |
Returns | string containing characters from a followed by the characters from b. |