Base class for working with mutable strings. More...
#include <sstring.h>
Public Member Functions | |
| K * | str () noexcept |
| Get a pointer to the string buffer. | |
| operator K* () noexcept | |
| Get a pointer to the string buffer. | |
| Impl & | trim () |
| Remove whitespace from the beginning and end of a line. | |
| Impl & | trim_left () |
| Remove whitespace at the beginning of a line. | |
| Impl & | trim_right () |
| Remove whitespace from the end of a line. | |
| template<typename T, size_t N = const_lit_for<K, T>::Count> requires is_const_pattern<N> | |
| Impl & | trim (T &&pattern) |
| Remove characters included in a string literal at the beginning and end of the line. | |
| template<typename T, size_t N = const_lit_for<K, T>::Count> requires is_const_pattern<N> | |
| Impl & | trim_left (T &&pattern) |
| Remove characters included in a string literal at the beginning of the line. | |
| template<typename T, size_t N = const_lit_for<K, T>::Count> requires is_const_pattern<N> | |
| Impl & | trim_right (T &&pattern) |
| Remove characters included in a string literal at the end of the line. | |
| template<typename T, size_t N = const_lit_for<K, T>::Count> requires is_const_pattern<N> | |
| Impl & | trim_with_spaces (T &&pattern) |
| Remove characters included in a string literal, as well as whitespace, at the beginning and end of the string. | |
| template<typename T, size_t N = const_lit_for<K, T>::Count> requires is_const_pattern<N> | |
| Impl & | trim_left_with_spaces (T &&pattern) |
| Remove characters included in a string literal, as well as whitespace, at the beginning of a line. | |
| template<typename T, size_t N = const_lit_for<K, T>::Count> requires is_const_pattern<N> | |
| Impl & | trim_right_with_wpaces (T &&pattern) |
| Remove characters included in a string literal, as well as whitespace, at the end of a string. | |
| Impl & | trim (str_piece pattern) |
| Remove characters included in the passed string at the beginning and end of the line. | |
| Impl & | trim_left (str_piece pattern) |
| Remove characters included in the passed string at the beginning of the line. | |
| Impl & | trim_right (str_piece pattern) |
| Remove characters included in the passed string from the end of the string. | |
| Impl & | trim_with_spaces (str_piece pattern) |
| Remove characters included in the passed string, as well as whitespace characters, at the beginning and end of the string. | |
| Impl & | trim_left_with_spaces (str_piece pattern) |
| Remove characters included in the passed string, as well as whitespace, at the beginning of the string. | |
| Impl & | trim_right_with_spaces (str_piece pattern) |
| Remove characters included in the passed string, as well as whitespace at the end of the string. | |
| Impl & | upper_only_ascii () |
| Convert ASCII characters to uppercase. | |
| Impl & | lower_only_ascii () |
| Convert ASCII characters to lowercase. | |
| Impl & | upper () |
| Convert first plane characters (<0xFFFF) to uppercase Unicode. | |
| Impl & | lower () |
| Convert first plane characters (<0xFFFF) to lowercase Unicode. | |
| Impl & | append (str_piece other) |
| Add another line to the end of the line. | |
| template<StrExprForType< K > A> | |
| Impl & | append (const A &expr) |
| Add a string expression to the end of the line. | |
| Impl & | operator+= (str_piece other) |
| Add another line to the end of the line. | |
| template<StrExprForType< K > A> | |
| Impl & | operator+= (const A &expr) |
| Add a string expression to the end of the line. | |
| Impl & | append_in (size_t pos, str_piece other) |
| Add another line starting at the given position. | |
| template<StrExprForType< K > A> | |
| Impl & | append_in (size_t pos, const A &expr) |
| Add a string expression starting at the given position. | |
| Impl & | change (size_t from, size_t len, str_piece other) |
| Replace a piece of string with another string. | |
| template<StrExprForType< K > A> | |
| Impl & | change (size_t from, size_t len, const A &expr) |
| Replace a piece of string with a string expression. | |
| Impl & | insert (size_t to, str_piece other) |
| Insert a line at the specified position. | |
| template<StrExprForType< K > A> | |
| Impl & | insert (size_t to, const A &expr) |
| Insert a string expression at the specified position. | |
| Impl & | remove (size_t from, size_t len) |
| Remove part of a line. | |
| Impl & | prepend (str_piece other) |
| Add another line to the beginning of the line. | |
| template<StrExprForType< K > A> | |
| Impl & | prepend (const A &expr) |
| Add a string expression to the beginning of a line. | |
| Impl & | replace (str_piece pattern, str_piece repl, size_t offset=0, size_t maxCount=0) |
| Replace occurrences of a substring with another string. | |
| template<StrType< K > From> | |
| Impl & | replace_from (const From &f, str_piece pattern, str_piece repl, size_t offset=0, size_t maxCount=0) |
| Copy the source string, replacing occurrences of substrings with another string. | |
| template<typename Op> | |
| Impl & | fill (size_t from, const Op &fillFunction) |
| Fill a string buffer using a functor. | |
| template<typename Op> requires std::is_invocable_v<Op, K*, size_t> | |
| Impl & | operator<< (const Op &fillFunction) |
| Fills a string with the fill method from position zero. | |
| template<typename Op> requires std::is_invocable_v<Op, K*, size_t> | |
| Impl & | operator<<= (const Op &fillFunction) |
| Fills a string with the fill method after the end of the string. | |
| template<typename Op> requires std::is_invocable_v<Op, my_type&> | |
| Impl & | operator<< (const Op &fillFunction) |
| Calls the passed functor, passing a reference to itself. | |
| template<typename... T> requires (is_one_of_std_char_v<K>) | |
| Impl & | printf_from (size_t from, const K *format, T &&... args) |
| Appends sprintf formatted output starting at the specified position. | |
| template<typename... T> requires (is_one_of_std_char_v<K>) | |
| Impl & | printf (const K *format, T &&... args) |
| Formats a string using sprintf. | |
| template<typename... T> requires (is_one_of_std_char_v<K>) | |
| Impl & | append_printf (const K *format, T &&... args) |
| Appends sprintf formatted output to the end of the line. | |
| template<typename... T> requires (is_one_of_std_char_v<K>) | |
| Impl & | format_from (size_t from, const FmtString< K, T... > &format, T &&... args) |
| Appends std::format-formatted output starting at the specified position. | |
| template<typename... T> requires (is_one_of_std_char_v<K>) | |
| Impl & | vformat_from (size_t from, size_t max_write, str_piece format, T &&... args) |
| Appends std::vformat formatted output starting at the specified position. | |
| template<typename... T> requires (is_one_of_std_char_v<K>) | |
| Impl & | format (const FmtString< K, T... > &pattern, T &&... args) |
| Formats a string using std::format. | |
| template<typename... T> requires (is_one_of_std_char_v<K>) | |
| Impl & | append_formatted (const FmtString< K, T... > &format, T &&... args) |
| Appends std::format-formatted output to the end of the line. | |
| template<typename... T> requires (is_one_of_std_char_v<K>) | |
| Impl & | vformat (str_piece format, T &&... args) |
| Formats a string using std::vformat. | |
| template<typename... T> requires (is_one_of_std_char_v<K>) | |
| Impl & | append_vformatted (str_piece format, T &&... args) |
| Appends std::vformat-formatted output to the end of the line. | |
| template<typename... T> requires (is_one_of_std_char_v<K>) | |
| Impl & | vformat_n (size_t max_write, str_piece format, T &&... args) |
| Formats a string using std::vformat up to the specified size. | |
| template<typename... T> requires (is_one_of_std_char_v<K>) | |
| Impl & | append_vformatted_n (size_t max_write, str_piece format, T &&... args) |
| Appends std::vformat-formatted output to the end of the line, writing no more than the specified number of characters. | |
| template<typename Op, typename... Args> | |
| Impl & | with (const Op &fillFunction, Args &&... args) |
| Call a functor with a string and passed arguments. | |
Base class for working with mutable strings.
| K | - character type |
| Impl | - the final type of the successor |
Still knows nothing about where the heir stores the string and its size. Simply calls its methods to get the space, and fills it as needed. To work, the descendant class must implement the following methods:
size_t length() const noexcept - returns the length of the stringconst K* symbols() const - returns a pointer to the beginning of the linebool is_empty() const noexcept - checks whether the string is emptyK* str() noexcept - Non-const pointer to the beginning of the stringK* set_size(size_t size) - Change the size of the string, either larger or smaller. The contents of the line must be left.K* reserve_no_preserve(size_t size) - allocate space for a line, you don’t have to save the old oneK* alloc_for_copy(size_t size) - allocate space for a copy of a string of a given size, without changing it yet the string itself, you can return the current buffer if space allows.set_from_copy(K* str, size_t size) - assign a string from memory previously allocated in alloc_for_copy. If space was allocated in the current buffer, do nothing.size_t capacity() const noexcept - return the current capacity of the string, as much as can fit without allocation.
|
inline |
Add a string expression to the end of the line.
| expr | - string expression. |
|
inline |
Add another line to the end of the line.
| other | - another string. |
|
inline |
Appends std::format-formatted output to the end of the line.
| format | - format string, constant. |
| ...args | - arguments for std::format. |
Automatically increases the string buffer size if necessary.
|
inline |
Add a string expression starting at the given position.
| pos | - the position from which to add. First, the string is shortened to the specified value size, and then a string expression is added. |
| expr | - string expression. |
If the string is longer than pos, then it is shortened to this size, and then expr is added.
|
inline |
Add another line starting at the given position.
| pos | - the position from which to add. First, the string is shortened to the specified value size, and then another line is added. |
| other | - another string. |
If the string is longer than pos, then it is shortened to this size, and then other is added.
|
inline |
Appends sprintf formatted output to the end of the line.
| format | - format string. |
| ...args | - arguments for sprintf. |
Automatically increases the row buffer size if necessary.
|
inline |
Appends std::vformat-formatted output to the end of the line.
| format | - format string. |
| ... | - arguments for std::vformat. |
Automatically increases the string buffer size if necessary.
|
inline |
Appends std::vformat-formatted output to the end of the line, writing no more than the specified number of characters.
| max_write | - the maximum number of characters to write. |
| format | - format string. |
| ...args | - arguments for std::vformat. |
Automatically increases the string buffer size if necessary.
|
inline |
Replace a piece of string with a string expression.
| from | - starting position for replacement. |
| len | - length of the part to be replaced. |
| expr | - string expression. |
|
inline |
Replace a piece of string with another string.
| from | - starting position for replacement. |
| len | - length of the part to be replaced. |
| other | - the string this part is changed to. |
|
inline |
Fill a string buffer using a functor.
| from | - starting position to fill. |
| fillFunction | - size_t(K*, size_t) functor that receives the address of the string buffer and its capacity, returning the required string size. |
The function calls the functor, passing it the address of the string buffer and its capacity. The functor can modify the buffer within the allocated capacity, and must return the size of the resulting string. As long as the returned size is larger than capacity (i.e. the string cannot fit into the buffer), memory of at least the returned size is allocated and the functor is called again. Until the returned size fits into the string buffer. This size becomes the length of the line.
|
inline |
Formats a string using std::format.
| pattern | - format string, constant. |
| ...args | - arguments for std::format. |
Automatically increases the string buffer size if necessary.
|
inline |
Appends std::format-formatted output starting at the specified position.
| from | - starting position of adding. |
| format | - format string, constant. |
| ...args | - arguments for std::format. |
Automatically increases the string buffer size if necessary.
|
inline |
Insert a string expression at the specified position.
| to | - insertion position. |
| expr | - string expression. |
|
inline |
Insert a line at the specified position.
| to | - insertion position. |
| other | - the string to be inserted. |
|
inline |
Convert first plane characters (<0xFFFF) to lowercase Unicode.
Case is changed by simplified tables, where one code_point is always changed to one code_point (but for UTF-8 it is possible that the length in code units will change).
|
inline |
Convert ASCII characters to lowercase.
|
inlineexplicitnoexcept |
Get a pointer to the string buffer.
|
inline |
Add a string expression to the end of the line.
| expr | - string expression. |
|
inline |
Add another line to the end of the line.
| other | - another line. |
|
inline |
Fills a string with the fill method from position zero.
| fillFunction | - string filling functor, size_t(K*, size_t). |
|
inline |
Calls the passed functor, passing a reference to itself.
| fillFunction | - фуктор void(my_type&). |
|
inline |
Fills a string with the fill method after the end of the string.
| fillFunction | - string filling functor, size_t(K*, size_t). |
|
inline |
Add a string expression to the beginning of a line.
| expr | - string expression. |
|
inline |
Add another line to the beginning of the line.
| other | - another string. |
|
inline |
Formats a string using sprintf.
| format | - format string. |
| ...args | - arguments for sprintf. |
Automatically increases the string buffer size if necessary.
|
inline |
Appends sprintf formatted output starting at the specified position.
| from | - starting position of adding. |
| format | - format string. |
| ...args | - arguments for sprintf. |
Automatically increases the string buffer size if necessary.
|
inline |
Remove part of a line.
| from | - the position from which to delete. |
| len | - length of the part to be deleted. |
|
inline |
Replace occurrences of a substring with another string.
| pattern | - the substring to search for. |
| repl | - replacement string. |
| offset | - the starting position for the search. |
| maxCount | - maximum number of replacements, 0 - no restrictions. |
|
inline |
Copy the source string, replacing occurrences of substrings with another string.
| f | - source string. |
| pattern | - the substring to search for. |
| repl | - replacement string. |
| offset | - the starting position for the search. |
| maxCount | - maximum number of replacements, 0 - no restrictions. |
|
inlinenoexcept |
Get a pointer to the string buffer.
|
inline |
Remove whitespace from the beginning and end of a line.
|
inline |
Remove characters included in the passed string at the beginning and end of the line.
| pattern | - a string containing the characters to be removed. |
|
inline |
Remove characters included in a string literal at the beginning and end of the line.
| pattern | is a string literal containing the characters to be removed. |
|
inline |
Remove whitespace at the beginning of a line.
|
inline |
Remove characters included in the passed string at the beginning of the line.
| pattern | - a string containing the characters to be removed. |
|
inline |
Remove characters included in a string literal at the beginning of the line.
| pattern | is a string literal containing the characters to be removed. |
|
inline |
Remove characters included in the passed string, as well as whitespace, at the beginning of the string.
| pattern | - a string containing the characters to be removed. |
|
inline |
Remove characters included in a string literal, as well as whitespace, at the beginning of a line.
| pattern | is a string literal containing the characters to be removed. |
|
inline |
Remove whitespace from the end of a line.
|
inline |
Remove characters included in the passed string from the end of the string.
| pattern | - a string containing the characters to be removed. |
|
inline |
Remove characters included in a string literal at the end of the line.
| pattern | is a string literal containing the characters to be removed. |
|
inline |
Remove characters included in the passed string, as well as whitespace at the end of the string.
| pattern | - a string containing the characters to be removed. |
|
inline |
Remove characters included in a string literal, as well as whitespace, at the end of a string.
| pattern | is a string literal containing the characters to be removed. |
|
inline |
Remove characters included in the passed string, as well as whitespace characters, at the beginning and end of the string.
| pattern | - a string containing the characters to be removed. |
|
inline |
Remove characters included in a string literal, as well as whitespace, at the beginning and end of the string.
| pattern | is a string literal containing the characters to be removed. |
|
inline |
Convert first plane characters (<0xFFFF) to uppercase Unicode.
Case is changed by simplified tables, where one code_point is always changed to one code_point (but for UTF-8 it is possible that the length in code units will change).
|
inline |
Convert ASCII characters to uppercase.
|
inline |
Formats a string using std::vformat.
| format | - format string. |
| ...args | - arguments for std::vformat. |
Automatically increases the string buffer size if necessary.
|
inline |
Appends std::vformat formatted output starting at the specified position.
| from | - starting position of adding. |
| max_write | - the maximum number of characters to write. |
| format | - format string. |
| ...args | - arguments for std::vformat. |
Automatically increases the string buffer size if necessary.
|
inline |
Formats a string using std::vformat up to the specified size.
| max_write | - the maximum number of characters to write. |
| format | - format string. |
| ...args | - arguments for std::vformat. |
Automatically increases the string buffer size if necessary.
|
inline |
Call a functor with a string and passed arguments.
| fillFunction | - a functor that takes a string reference as its first parameter. |
| ...args | - arguments passed to the functor. |