MinitScript
0.9.31 PRE-BETA
|
String tools class. More...
#include <minitscript/utilities/StringTools.h>
Static Public Member Functions | |
static const bool | startsWith (const string &str, const string &prefix) |
Checks if string starts with prefix. More... | |
static const bool | viewStartsWith (const string_view &str, const string_view &prefix) |
Checks if string starts with prefix. More... | |
static const bool | endsWith (const string &str, const string &suffix) |
Checks if string ends with suffix. More... | |
static const bool | viewEndsWith (const string_view &str, const string_view &suffix) |
Checks if string ends with suffix. More... | |
static const string | replace (const string &str, const char what, const char by, int64_t beginIndex=0) |
Replace char with another char. More... | |
static const string | replace (const string &str, const string &what, const string &by, int64_t beginIndex=0) |
Replace string with another string. More... | |
static int64_t | indexOf (const string &str, char what, int64_t beginIndex=0) |
Finds first index of given character. More... | |
static int64_t | indexOf (const string &str, const string &what, int64_t beginIndex=0) |
Finds first index of given string. More... | |
static int64_t | firstIndexOf (const string &str, char what, int64_t beginIndex=0) |
Finds first index of given character. More... | |
static int64_t | firstIndexOf (const string &str, const string &what, int64_t beginIndex=0) |
Finds first index of given string. More... | |
static int64_t | lastIndexOf (const string &str, const char what, int64_t endIndex=string::npos) |
Finds last index of given character. More... | |
static int64_t | lastIndexOf (const string &str, const string &what, int64_t endIndex=string::npos) |
Finds last index of given string. More... | |
static int64_t | firstIndexOfChar (const string &str, char what, int64_t beginIndex=0) |
Finds first index of character provided within given string. More... | |
static int64_t | firstIndexOfChars (const string &str, const string &what, int64_t beginIndex=0) |
Finds first index of characters provided within given string. More... | |
static int64_t | lastIndexOfChar (const string &str, char what, int64_t endIndex=string::npos) |
Finds last index of character provided within given string. More... | |
static int64_t | lastIndexOfChars (const string &str, const string &what, int64_t endIndex=string::npos) |
Finds last index of characters provided within given string. More... | |
static const string | substring (const string &str, int64_t beginIndex) |
Returns substring of given string from begin index. More... | |
static const string_view | viewSubstring (const string_view &str, int64_t beginIndex) |
Returns substring of given string from begin index. More... | |
static const string | substring (const string &str, int64_t beginIndex, int64_t endIndex) |
Returns substring of given string from begin index to end index. More... | |
static const string_view | viewSubstring (const string_view &str, int64_t beginIndex, int64_t endIndex) |
Returns substring of given string from begin index to end index. More... | |
static bool | equalsIgnoreCase (const string &string1, const string &string2) |
Checks if strings equal ignoring case. More... | |
static const string | trim (const string &str) |
Trim string. More... | |
static const string_view | viewTrim (const string_view &str) |
Trim string. More... | |
static const string | toLowerCase (const string &str) |
Transform string to lower case. More... | |
static const string | toUpperCase (const string &str) |
Transform string to upper case. More... | |
static bool | regexMatch (const string &str, const string &pattern, smatch *matches=nullptr) |
Check if pattern matches whole string. More... | |
static bool | regexSearch (const string &str, const string &pattern, smatch *matches=nullptr) |
Do regex pattern search. More... | |
static const string | regexReplace (const string &str, const string &pattern, const string &by) |
Replace regex pattern with given string. More... | |
static const vector< string > | tokenize (const string &str, const string &delimiters, bool emptyTokens=false) |
Tokenize. More... | |
static const string | padLeft (const string &str, const string &by, int64_t toSize) |
Pad a string left. More... | |
static const string | padRight (const string &str, const string &by, int64_t toSize) |
Pad a string right. More... | |
static const string | indent (const string &str, const string &with, int64_t count) |
Indent a string. More... | |
static const string | generate (const string &what, int64_t count=1) |
Generate a string. More... | |
static int64_t | getUTF8Length (const string &str) |
Get UTF8 string length. More... | |
static const string | getUTF8CharAt (const string &str, int64_t index) |
Get UTF8 character at given index. More... | |
static int64_t | getUTF8BinaryIndex (const string &str, int64_t charIdx) |
Get UTF8 binary buffer index. More... | |
String tools class.
Definition at line 20 of file StringTools.h.
|
inlinestatic |
Checks if string starts with prefix.
str | string |
prefix | prefix string |
Definition at line 29 of file StringTools.h.
|
inlinestatic |
Checks if string starts with prefix.
str | string |
prefix | prefix string |
Definition at line 39 of file StringTools.h.
|
inlinestatic |
Checks if string ends with suffix.
str | string |
suffix | suffix string |
Definition at line 49 of file StringTools.h.
|
inlinestatic |
Checks if string ends with suffix.
str | string |
suffix | suffix string |
Definition at line 61 of file StringTools.h.
|
static |
Replace char with another char.
str | string |
what | what to replace |
by | to replace by |
beginIndex | index to begin with |
Definition at line 33 of file StringTools.cpp.
|
static |
Replace string with another string.
str | string |
what | what to replace |
by | to replace by |
beginIndex | index to begin with |
Definition at line 39 of file StringTools.cpp.
|
inlinestatic |
Finds first index of given character.
str | string |
what | what |
beginIndex | begin index |
Definition at line 94 of file StringTools.h.
|
inlinestatic |
Finds first index of given string.
str | string |
what | what |
beginIndex | begin index |
Definition at line 105 of file StringTools.h.
|
inlinestatic |
Finds first index of given character.
str | string |
what | what |
beginIndex | begin index |
Definition at line 116 of file StringTools.h.
|
inlinestatic |
Finds first index of given string.
str | string |
what | what |
beginIndex | begin index |
Definition at line 127 of file StringTools.h.
|
inlinestatic |
Finds last index of given character.
str | string |
what | what |
endIndex | end index or string::npos |
Definition at line 138 of file StringTools.h.
|
inlinestatic |
Finds last index of given string.
str | string |
what | what |
endIndex | end index or string::npos |
Definition at line 149 of file StringTools.h.
|
inlinestatic |
Finds first index of character provided within given string.
str | string |
what | what |
beginIndex | begin index |
Definition at line 160 of file StringTools.h.
|
inlinestatic |
Finds first index of characters provided within given string.
str | string |
what | what |
beginIndex | begin index |
Definition at line 171 of file StringTools.h.
|
inlinestatic |
Finds last index of character provided within given string.
str | string |
what | what |
endIndex | end index or string::npos |
Definition at line 182 of file StringTools.h.
|
inlinestatic |
Finds last index of characters provided within given string.
str | string |
what | what |
endIndex | end index or string::npos |
Definition at line 193 of file StringTools.h.
|
inlinestatic |
Returns substring of given string from begin index.
str | string |
beginIndex | begin index |
Definition at line 203 of file StringTools.h.
|
inlinestatic |
Returns substring of given string from begin index.
str | string |
beginIndex | begin index |
Definition at line 213 of file StringTools.h.
|
inlinestatic |
Returns substring of given string from begin index to end index.
str | string |
beginIndex | begin index |
endIndex | end index |
Definition at line 224 of file StringTools.h.
|
inlinestatic |
Returns substring of given string from begin index to end index.
str | string |
beginIndex | begin index |
endIndex | end index |
Definition at line 235 of file StringTools.h.
|
static |
Checks if strings equal ignoring case.
string1 | string 1 |
string2 | string 2 |
Definition at line 49 of file StringTools.cpp.
|
static |
Trim string.
str | string |
Definition at line 57 of file StringTools.cpp.
|
static |
Trim string.
str | string |
Definition at line 82 of file StringTools.cpp.
|
static |
Transform string to lower case.
str | string |
Definition at line 94 of file StringTools.cpp.
|
static |
Transform string to upper case.
str | string |
Definition at line 100 of file StringTools.cpp.
|
static |
Check if pattern matches whole string.
str | string |
pattern | pattern |
matches | matches |
Definition at line 106 of file StringTools.cpp.
|
static |
Do regex pattern search.
str | string |
pattern | pattern |
matches | matches |
Definition at line 114 of file StringTools.cpp.
|
static |
Replace regex pattern with given string.
str | string |
pattern | pattern |
by | replace string |
Definition at line 122 of file StringTools.cpp.
|
static |
Tokenize.
str | string |
delimiters | delimiters |
emptyTokens | include empty tokens |
Definition at line 126 of file StringTools.cpp.
|
inlinestatic |
Pad a string left.
str | string |
by | by |
toSize | to size |
Definition at line 318 of file StringTools.h.
|
inlinestatic |
Pad a string right.
str | string |
by | by |
toSize | to size |
Definition at line 331 of file StringTools.h.
|
inlinestatic |
Indent a string.
str | string |
with | with |
count | count |
Definition at line 344 of file StringTools.h.
|
inlinestatic |
Generate a string.
what | what |
count | count |
Definition at line 356 of file StringTools.h.
|
static |
Get UTF8 string length.
str | string |
Definition at line 132 of file StringTools.cpp.
|
static |
Get UTF8 character at given index.
str | string |
index | index |
cache | UTF8 position cache |
Definition at line 138 of file StringTools.cpp.
|
static |
Get UTF8 binary buffer index.
str | string |
charIdx | character index |
Definition at line 146 of file StringTools.cpp.