#include <StrUtil.h>
Static Public Member Functions | |
static bool | isWhiteSpace (const char C) |
Determine if the specified characater is whitespace or not. | |
static void | trim (std::string &str) |
Remove leading whitespace from a string. | |
static bool | scanForSymbol (std::string &str, const char symbol) |
Find and remove a symbol for the beginning of a string. | |
static bool | scanForLgIndex (std::string &str, LgIndex_t *value) |
Find a LgIndex_t value at the beginning of a string. | |
static void | toUpper (std::string &str) |
Convert the supplied string to uppercase. | |
static void | toLower (std::string &str) |
Convert the supplied string to uppercase. | |
static std::vector< std::string > | split (std::string str, std::string delimiters=",", bool discardEmptyStrings=false) |
Splits a string around matches of the supplied delimiters. |
static bool tecplot::toolbox::StrUtil::isWhiteSpace | ( | const char | C | ) | [static] |
Determine if the specified characater is whitespace or not.
C | Character to check. |
true
if the character is considered whitespace, false
otherwise. static void tecplot::toolbox::StrUtil::trim | ( | std::string & | str | ) | [static] |
Remove leading whitespace from a string.
str | String which should have white space removed. |
std::string strValue(" \t Hi Mom\n"); cout << strValue.c_str(); trimWhiteSpace(strValue); cout << strValue.c_str(); Output: " Hi Mom" "Hi Mom"
static bool tecplot::toolbox::StrUtil::scanForSymbol | ( | std::string & | str, | |
const char | symbol | |||
) | [static] |
Find and remove a symbol for the beginning of a string.
str | String in which to search for the symbol | |
symbol | Character to search for |
true
if symbol is the next non-whitespace character in the string. If the symbol is found, it will be removed from the front of the string. Whitespace is always trimmed from the front of the string regardless of the return value. false
if the symbol is not the next non-whitespace character.std::string strValue(" [1,2,3]\n"); cout << strValue.c_str(); scanForSymbol(strValue, '!'); cout << strValue.c_str(); scanForSymbol(strValue, '['); cout << strValue.c_str(); Output: " [1,2,3]" // Original string "[1,2,3]" // After looking for '!', the leading whitespace is trimmed "1,2,3]" // Found '[' and removed it.
static bool tecplot::toolbox::StrUtil::scanForLgIndex | ( | std::string & | str, | |
LgIndex_t * | value | |||
) | [static] |
Find a LgIndex_t value at the beginning of a string.
str | String in which to search for a LgIndex_t value. | |
value | LgIndex_t pointer in which to stuff the result. |
true
if the next non-whitspace series of characters in the string evaluate to a LgIndex_t. Whitespace is always trimmed from the front of the string. The string will be modified regardless of the return value. If this function returns false
the string may be in an unknown state.std::string strValue("1,2,3\n"); cout << strValue.c_str(); LgIndex_t value; scanForLgIndex(strValue, &value); cout << strValue.c_str(); Output: "1,2,3" // Original string ",2,3" // After looking for the LgIndex_t value
static void tecplot::toolbox::StrUtil::toUpper | ( | std::string & | str | ) | [static] |
Convert the supplied string to uppercase.
str | The string to be converted to uppercase. |
static void tecplot::toolbox::StrUtil::toLower | ( | std::string & | str | ) | [static] |
Convert the supplied string to uppercase.
str | The string to be converted to uppercase. |
static std::vector<std::string> tecplot::toolbox::StrUtil::split | ( | std::string | str, | |
std::string | delimiters = "," , |
|||
bool | discardEmptyStrings = false | |||
) | [static] |
Splits a string around matches of the supplied delimiters.
str | The delmited string to be split | |
delimiters | Zero or more characters to be used as delimiters. If the delimiter is a zero length string, the input string will not be split. | |
discardEmptyStrings | If true, empty strings will not be included in the result If false, empty strings may be included in the result |
StrUtil::split("a,b,,c,", ",", false); // result will be: { "a", "b", "", "c", "" } StrUtil::split("a,b,,c,", ",", true); // result will be: { "a", "b", "c" } StrUtil::split("hi,mom;hi,\n;dad", ",\n;", false); // result will be: {"hi", "mom", "hi", "", "", "dad"} StrUtil::split("hi,mom;hi,\n;dad", ",\n;", true); // result will be: {"hi", "mom", "hi", "dad"}