libxr
1.0
Want to be the best embedded framework
|
A fixed-length string class with safe operations. More...
#include <libxr_string.hpp>
Public Member Functions | |
String () | |
Default constructor, initializes an empty string. | |
String (const char *str) | |
Constructs a String from a C-style string. | |
String (const char *str, size_t len) | |
Constructs a String from a C-style string with a given length. | |
const char * | Raw () const |
Gets the raw C-style string. | |
char | operator[] (unsigned int i) |
Accesses a character at a given index. | |
char | operator[] (unsigned int i) const |
Accesses a character at a given index (const version). | |
const char * | operator+ (unsigned int i) |
Returns a pointer to a substring starting from index i. | |
String & | operator+= (const char *str) |
Appends a C-style string to the current string. | |
int | Find (const char *str) const |
Finds the first occurrence of a substring. | |
template<unsigned int NextStrLength> | |
bool | operator== (const String< NextStrLength > &other) const |
Compares two strings for equality. | |
template<unsigned int NextStrLength> | |
bool | operator!= (const String< NextStrLength > &other) const |
Compares two strings for inequality. | |
template<unsigned int NextStrLength> | |
bool | operator< (const String< NextStrLength > &other) const |
Less than comparison between two strings. | |
template<unsigned int NextStrLength> | |
bool | operator> (const String< NextStrLength > &other) const |
Greater than comparison between two strings. | |
template<unsigned int NextStrLength> | |
bool | operator<= (const String< NextStrLength > &other) const |
Less than or equal comparison. | |
template<unsigned int NextStrLength> | |
bool | operator>= (const String< NextStrLength > &other) const |
Greater than or equal comparison. | |
size_t | Length () const |
Gets the length of the string. | |
void | Clear () |
Clears the string, making it empty. | |
template<unsigned int SubStrLength> | |
String< SubStrLength > | Substr (size_t pos) const |
Extracts a substring starting at a given position. | |
Private Attributes | |
std::array< char, MaxLength+1 > | raw_string_ |
A fixed-length string class with safe operations.
MaxLength | The maximum length of the string. |
具有固定长度的字符串类,提供安全的字符串操作。
Definition at line 20 of file libxr_string.hpp.
|
inline |
Default constructor, initializes an empty string.
默认构造函数,初始化为空字符串。
Definition at line 28 of file libxr_string.hpp.
|
inline |
Constructs a String from a C-style string.
str | The C-style string to copy from. |
从 C 风格字符串构造 String。
Definition at line 36 of file libxr_string.hpp.
|
inline |
Constructs a String from a C-style string with a given length.
str | The C-style string to copy from. |
len | The maximum number of characters to copy. |
从 C 风格字符串构造 String,并指定最大拷贝长度。
Definition at line 49 of file libxr_string.hpp.
|
inline |
Clears the string, making it empty.
清空字符串,使其变为空字符串。
Definition at line 229 of file libxr_string.hpp.
|
inline |
Finds the first occurrence of a substring.
str | The substring to search for. |
查找子字符串的首次出现位置。
Definition at line 122 of file libxr_string.hpp.
|
inline |
Gets the length of the string.
获取字符串的长度。
Definition at line 222 of file libxr_string.hpp.
|
inline |
Compares two strings for inequality.
NextStrLength | The length of the other string. |
other | The other string to compare. |
比较两个字符串是否不相等。
Definition at line 155 of file libxr_string.hpp.
|
inline |
Returns a pointer to a substring starting from index i.
i | The starting index. |
返回从索引 i 开始的子字符串的指针。
Definition at line 97 of file libxr_string.hpp.
|
inline |
Appends a C-style string to the current string.
str | The string to append. |
将 C 风格字符串追加到当前字符串。
Definition at line 106 of file libxr_string.hpp.
|
inline |
Less than comparison between two strings.
NextStrLength | The length of the other string. |
other | The other string to compare. |
比较两个字符串,判断当前字符串是否小于另一个字符串。
Definition at line 169 of file libxr_string.hpp.
|
inline |
Less than or equal comparison.
NextStrLength | The length of the other string. |
other | The other string to compare. |
比较两个字符串,判断当前字符串是否小于或等于另一个字符串。
Definition at line 197 of file libxr_string.hpp.
|
inline |
Compares two strings for equality.
NextStrLength | The length of the other string. |
other | The other string to compare. |
比较两个字符串是否相等。
Definition at line 141 of file libxr_string.hpp.
|
inline |
Greater than comparison between two strings.
NextStrLength | The length of the other string. |
other | The other string to compare. |
比较两个字符串,判断当前字符串是否大于另一个字符串。
Definition at line 183 of file libxr_string.hpp.
|
inline |
Greater than or equal comparison.
NextStrLength | The length of the other string. |
other | The other string to compare. |
比较两个字符串,判断当前字符串是否大于或等于另一个字符串。
Definition at line 211 of file libxr_string.hpp.
|
inline |
Accesses a character at a given index.
i | The index of the character. |
访问指定索引的字符。
Definition at line 71 of file libxr_string.hpp.
|
inline |
Accesses a character at a given index (const version).
i | The index of the character. |
访问指定索引的字符(常量版本)。
Definition at line 84 of file libxr_string.hpp.
|
inline |
Gets the raw C-style string.
获取原始 C 风格字符串。
Definition at line 62 of file libxr_string.hpp.
|
inline |
Extracts a substring starting at a given position.
SubStrLength | The length of the substring. |
pos | The starting position. |
提取从指定位置开始的子字符串。
Definition at line 240 of file libxr_string.hpp.
|
private |
The raw character array storing the string. 原始字符数组存储字符串。
Definition at line 248 of file libxr_string.hpp.