qb
2.0.0.0
C++17 Actor Framework
|
Fixed-size string with optimized storage. More...
#include <string.h>
Public Member Functions | |
constexpr | string () noexcept |
Default constructor. | |
template<std::size_t N> | |
constexpr | string (const char(&str)[N]) noexcept |
Constructor from C-style string literal. | |
template<typename T> | |
string (T const &rhs) noexcept | |
Constructor from string-like object. | |
string (const char *str, std::size_t size) noexcept | |
Constructor from C-style string and size. | |
string (const char *str) noexcept | |
Constructor from C-style string. | |
string (std::size_t count, char ch) noexcept | |
Fill constructor. | |
string (const string &other) noexcept=default | |
Copy constructor. | |
string (string &&other) noexcept=default | |
Move constructor. | |
string & | operator= (const string &other) noexcept=default |
Copy assignment operator. | |
string & | operator= (string &&other) noexcept=default |
Move assignment operator. | |
string & | assign (char const *rhs, std::size_t size) noexcept |
Assign from C-style string and size. | |
template<std::size_t N> | |
constexpr string & | assign (const char(&str)[N]) noexcept |
Assign from C-style string literal. | |
template<typename T> | |
string & | assign (T const &rhs) noexcept |
Assign from string-like object. | |
string & | assign (char const *rhs) noexcept |
Assign from C-style string. | |
string & | assign (std::size_t count, char ch) noexcept |
Assign with fill. | |
template<std::size_t N> | |
constexpr string & | operator= (const char(&str)[N]) noexcept |
Assignment operator for C-style string literals. | |
template<typename T> | |
string & | operator= (T const &rhs) noexcept |
Assignment operator for string-like objects. | |
string & | operator= (char const *rhs) noexcept |
Assignment operator for C-style strings. | |
string & | operator= (char ch) noexcept |
Assignment operator for single character. | |
operator std::string () const noexcept | |
Conversion operator to std::string. | |
operator std::string_view () const noexcept | |
Conversion operator to std::string_view. | |
reference | at (std::size_t pos) |
Access character at index with bounds checking. | |
const_reference | at (std::size_t pos) const |
Access character at index with bounds checking (const version) | |
reference | operator[] (std::size_t pos) noexcept |
Access character at index (no bounds checking) | |
const_reference | operator[] (std::size_t pos) const noexcept |
Access character at index (no bounds checking, const version) | |
reference | front () noexcept |
Access first character. | |
const_reference | front () const noexcept |
Access first character (const version) | |
reference | back () noexcept |
Access last character. | |
const_reference | back () const noexcept |
Access last character (const version) | |
pointer | data () noexcept |
Get pointer to underlying data. | |
const_pointer | data () const noexcept |
Get pointer to underlying data (const version) | |
const_pointer | c_str () const noexcept |
Get C-style string representation. | |
iterator | end () noexcept |
Get iterator to the end of the string. | |
const_iterator | end () const noexcept |
Get const iterator to the end of the string. | |
const_iterator | cend () const noexcept |
Get const iterator to the end of the string. | |
reverse_iterator | rbegin () noexcept |
Get reverse iterator to the beginning of the string. | |
const_reverse_iterator | rbegin () const noexcept |
Get const reverse iterator to the beginning of the string. | |
const_reverse_iterator | crbegin () const noexcept |
Get const reverse iterator to the beginning of the string. | |
constexpr bool | empty () const noexcept |
Check if the string is empty. | |
constexpr std::size_t | size () const noexcept |
Get the string length. | |
constexpr std::size_t | length () const noexcept |
Get the string length (alias for size()) | |
constexpr std::size_t | max_size () const noexcept |
Get the maximum possible size. | |
constexpr std::size_t | capacity () const noexcept |
Get the capacity. | |
void | clear () noexcept |
Clear the string. | |
void | resize (std::size_t count, char ch='\0') noexcept |
Resize the string. | |
void | swap (string &other) noexcept |
Swap contents with another string. | |
string | substr (std::size_t pos=0, std::size_t len=npos) const |
Extract substring. | |
int | compare (const string &str) const noexcept |
Compare with another string. | |
int | compare (const char *str) const noexcept |
Compare with C-style string. | |
int | compare (std::size_t pos, std::size_t len, const string &str) const |
Compare substring with another string. | |
std::size_t | find (const string &str, std::size_t pos=0) const noexcept |
Find substring. | |
std::size_t | find (const char *str, std::size_t pos=0) const noexcept |
Find C-style string. | |
std::size_t | find (char ch, std::size_t pos=0) const noexcept |
Find character. | |
std::size_t | rfind (const char *str, std::size_t pos=npos) const noexcept |
Find last occurrence of substring. | |
std::size_t | rfind (char ch, std::size_t pos=npos) const noexcept |
Find last occurrence of character. | |
string & | append (const string &str) noexcept |
Append string. | |
string & | append (const char *str) noexcept |
Append C-style string. | |
string & | append (const char *str, std::size_t len) noexcept |
Append C-style string with length. | |
string & | append (char ch) noexcept |
Append character. | |
string & | append (std::size_t count, char ch) noexcept |
Append multiple characters. | |
void | push_back (char ch) noexcept |
Add character to end. | |
void | pop_back () noexcept |
Remove last character. | |
string & | operator+= (const string &str) noexcept |
Append operator. | |
string & | operator+= (const char *str) noexcept |
Append operator for C-style string. | |
string & | operator+= (char ch) noexcept |
Append operator for character. | |
bool | starts_with (const char *prefix) const noexcept |
Check if string starts with given prefix. | |
bool | starts_with (const string &prefix) const noexcept |
Check if string starts with given prefix. | |
bool | starts_with (char ch) const noexcept |
Check if string starts with given character. | |
bool | ends_with (const char *suffix) const noexcept |
Check if string ends with given suffix. | |
bool | ends_with (const string &suffix) const noexcept |
Check if string ends with given suffix. | |
bool | ends_with (char ch) const noexcept |
Check if string ends with given character. | |
bool | contains (const char *str) const noexcept |
Check if string contains given substring. | |
bool | contains (const string &str) const noexcept |
Check if string contains given substring. | |
bool | contains (char ch) const noexcept |
Check if string contains given character. | |
template<typename T> | |
bool | operator== (T const &rhs) const noexcept |
Equality comparison with string-like object. | |
bool | operator== (char const *rhs) const noexcept |
Equality comparison with C-style string. | |
bool | operator== (const string &rhs) const noexcept |
Equality comparison with another qb::string. | |
bool | operator!= (const string &rhs) const noexcept |
Inequality comparison. | |
bool | operator!= (const char *rhs) const noexcept |
Inequality comparison with C-style string. | |
bool | operator< (const string &rhs) const noexcept |
Less than comparison. | |
bool | operator< (const char *rhs) const noexcept |
Less than comparison with C-style string. | |
bool | operator> (const string &rhs) const noexcept |
Greater than comparison. | |
bool | operator> (const char *rhs) const noexcept |
Greater than comparison with C-style string. | |
bool | operator<= (const string &rhs) const noexcept |
Less than or equal comparison. | |
bool | operator<= (const char *rhs) const noexcept |
Less than or equal comparison with C-style string. | |
bool | operator>= (const string &rhs) const noexcept |
Greater than or equal comparison. | |
bool | operator>= (const char *rhs) const noexcept |
Greater than or equal comparison with C-style string. |
Static Public Attributes | |
static constexpr std::size_t | npos = std::numeric_limits<std::size_t>::max() |
Fixed-size string with optimized storage.
A string class with a fixed maximum capacity that is more efficient than std::string for small strings. It uses a std::array for storage and provides common string operations with bounds checking.
_Size | Maximum size of the string (default: 30) |
|
inlineconstexprnoexcept |
Default constructor.
Creates an empty string with a null terminator
|
inlineconstexprnoexcept |
Constructor from C-style string literal.
N | Size of the string literal including null terminator |
str | The string literal to copy |
|
inlinenoexcept |
|
inlinenoexcept |
Constructor from C-style string and size.
str | C-style string to copy from |
size | Number of characters to copy |
|
inlinenoexcept |
Constructor from C-style string.
str | Null-terminated C-style string |
|
inlinenoexcept |
Fill constructor.
count | Number of characters to fill |
ch | Character to fill with |
|
inlinenoexcept |
Assign from C-style string and size.
rhs | C-style string to copy from |
size | Number of characters to copy |
|
inlineconstexprnoexcept |
Assign from C-style string literal.
N | Size of the string literal including null terminator |
str | The string literal to copy |
|
inlinenoexcept |
|
inlinenoexcept |
Assign from C-style string.
rhs | Null-terminated C-style string |
|
inlinenoexcept |
Assign with fill.
count | Number of characters to assign |
ch | Character to fill with |
|
inlineconstexprnoexcept |
Assignment operator for C-style string literals.
N | Size of the string literal including null terminator |
str | The string literal to assign |
|
inlinenoexcept |
|
inlinenoexcept |
Assignment operator for C-style strings.
rhs | Null-terminated C-style string to assign |
|
inlinenoexcept |
Assignment operator for single character.
ch | Character to assign |
|
inlinenoexcept |
Conversion operator to std::string.
|
inlinenoexcept |
Conversion operator to std::string_view.
|
inline |
Access character at index with bounds checking.
pos | Index of the character |
std::out_of_range | if pos >= size() |
|
inline |
Access character at index with bounds checking (const version)
pos | Index of the character |
std::out_of_range | if pos >= size() |
|
inlinenoexcept |
Access character at index (no bounds checking)
pos | Index of the character |
|
inlinenoexcept |
Access character at index (no bounds checking, const version)
pos | Index of the character |
|
inlinenoexcept |
Access first character.
|
inlinenoexcept |
Access first character (const version)
|
inlinenoexcept |
Access last character.
|
inlinenoexcept |
Access last character (const version)
|
inlinenoexcept |
Get pointer to underlying data.
|
inlinenoexcept |
Get pointer to underlying data (const version)
|
inlinenodiscardnoexcept |
Get C-style string representation.
|
inlinenoexcept |
Get iterator to the end of the string.
|
inlinenoexcept |
Get const iterator to the end of the string.
|
inlinenoexcept |
Get const iterator to the end of the string.
|
inlinenoexcept |
Get reverse iterator to the beginning of the string.
|
inlinenoexcept |
Get const reverse iterator to the beginning of the string.
|
inlinenoexcept |
Get const reverse iterator to the beginning of the string.
|
inlinenodiscardconstexprnoexcept |
Check if the string is empty.
|
inlinenodiscardconstexprnoexcept |
Get the string length.
|
inlinenodiscardconstexprnoexcept |
Get the string length (alias for size())
|
inlinenodiscardconstexprnoexcept |
Get the maximum possible size.
|
inlinenodiscardconstexprnoexcept |
Get the capacity.
|
inlinenoexcept |
Clear the string.
Sets the string to an empty state with a null terminator
|
inlinenoexcept |
Resize the string.
count | New size of the string |
ch | Character to fill with if expanding |
|
inlinenoexcept |
Swap contents with another string.
other | String to swap with |
|
inline |
Extract substring.
pos | Starting position |
len | Number of characters to extract |
|
inlinenoexcept |
Compare with another string.
str | String to compare with |
|
inlinenoexcept |
Compare with C-style string.
str | C-style string to compare with |
|
inline |
Compare substring with another string.
pos | Starting position in this string |
len | Number of characters to compare |
str | String to compare with |
|
inlinenoexcept |
Find substring.
str | Substring to find |
pos | Starting position |
|
inlinenoexcept |
Find C-style string.
str | C-style string to find |
pos | Starting position |
|
inlinenoexcept |
Find character.
ch | Character to find |
pos | Starting position |
|
inlinenoexcept |
Find last occurrence of substring.
str | Substring to find |
pos | Starting position (searches backwards from here) |
|
inlinenoexcept |
Find last occurrence of character.
ch | Character to find |
pos | Starting position (searches backwards from here) |
|
inlinenoexcept |
Append string.
str | String to append |
|
inlinenoexcept |
Append C-style string.
str | C-style string to append |
|
inlinenoexcept |
Append C-style string with length.
str | C-style string to append |
len | Number of characters to append |
|
inlinenoexcept |
Append character.
ch | Character to append |
|
inlinenoexcept |
Append multiple characters.
count | Number of characters to append |
ch | Character to append |
|
inlinenoexcept |
Add character to end.
ch | Character to add |
|
inlinenoexcept |
Append operator.
str | String to append |
|
inlinenoexcept |
Append operator for C-style string.
str | C-style string to append |
|
inlinenoexcept |
Append operator for character.
ch | Character to append |
|
inlinenoexcept |
Check if string starts with given prefix.
prefix | Prefix to check |
|
inlinenoexcept |
Check if string starts with given prefix.
prefix | Prefix to check |
|
inlinenoexcept |
Check if string starts with given character.
ch | Character to check |
|
inlinenoexcept |
Check if string ends with given suffix.
suffix | Suffix to check |
|
inlinenoexcept |
Check if string ends with given suffix.
suffix | Suffix to check |
|
inlinenoexcept |
Check if string ends with given character.
ch | Character to check |
|
inlinenoexcept |
Check if string contains given substring.
str | Substring to find |
|
inlinenoexcept |
Check if string contains given substring.
str | Substring to find |
|
inlinenoexcept |
Check if string contains given character.
ch | Character to find |
|
inlinenoexcept |
Equality comparison with string-like object.
T | Type with operator== for C-style strings |
rhs | String-like object to compare with |
|
inlinenoexcept |
Equality comparison with C-style string.
rhs | C-style string to compare with |
|
inlinenoexcept |
Equality comparison with another qb::string.
rhs | String to compare with |
|
inlinenoexcept |
Inequality comparison.
rhs | String to compare with |
|
inlinenoexcept |
Inequality comparison with C-style string.
rhs | C-style string to compare with |
|
inlinenoexcept |
Less than comparison.
rhs | String to compare with |
|
inlinenoexcept |
Less than comparison with C-style string.
rhs | C-style string to compare with |
|
inlinenoexcept |
Greater than comparison.
rhs | String to compare with |
|
inlinenoexcept |
Greater than comparison with C-style string.
rhs | C-style string to compare with |
|
inlinenoexcept |
Less than or equal comparison.
rhs | String to compare with |
|
inlinenoexcept |
Less than or equal comparison with C-style string.
rhs | C-style string to compare with |
|
inlinenoexcept |
Greater than or equal comparison.
rhs | String to compare with |
|
inlinenoexcept |
Greater than or equal comparison with C-style string.
rhs | C-style string to compare with |