Files
YYCCommonplace/doc/src/string_helper.dox

44 lines
1.8 KiB
Plaintext
Raw Normal View History

2024-06-28 11:38:19 +08:00
/**
\page string_helper String Helper
\section string_helper_lower_upper Lower Upper
String helper provides Python-like string lower and upper function.
Both lower and upper function have 2 overloads:
\code
yycc_u8string Lower(const yycc_char8_t*);
void Lower(yycc_u8string&);
\endcode
First overload accepts a NULL-terminated string as argument and return a \b copy whose content are all the lower case of original string.
Second overload accepts a mutable string container as argument and will make all characters stored in it become their lower case.
You can choose on of them for your flavor and requirements.
Upper also has similar 2 overloads.
\section string_helper_split Split
String helper provides Python-like string split function.
It has 2 types for you:
\code
std::vector<yycc_u8string> Split(const yycc_u8string_view&, const yycc_char8_t*);
std::vector<yycc_u8string_view> SplitView(const yycc_u8string_view&, const yycc_char8_t*);
\endcode
2024-07-15 13:47:14 +08:00
All these overloads take a string view as the first argument representing the string need to be split.
The second argument is a raw string pointer representing the decilmer for splitting.
The only difference between these 2 split function are overt according to their names.
The first split function will return a list of copied string as its split result.
The second split function will return a list of string view as its split result,
and it will keep valid as long as the life time of your given string view argument.
2024-07-15 13:47:14 +08:00
It also means that the last overload will cost less memory if you don't need the copy of original string.
If the source string (the string need to be split) is empty, or the decilmer is \c nullptr or empty,
the result will only has 1 item and this item is source string itself.
2024-07-15 13:47:14 +08:00
There is no way that these methods return an empty list, except the code is buggy.
2024-06-28 11:38:19 +08:00
*/