Static Public Member Functions | |
static bool | isNumeric (const std::string &s) |
static bool | samePrefix (const std::string &, const std::string &, char stopWhenReached) |
static std::string | trimText (const std::string &s) |
removes leading and trailing white space. | |
static void | toLower (std::string &s) |
Convert to lower case. | |
static void | toUpper (std::string &s) |
Convert to upper case. | |
static void | capitalize (std::string &s) |
Capitalize every word. | |
static size_t | split (const std::string &splitme, std::vector< std::string > *setme) |
Split a string on whitespace and put the pieces into a vector. | |
static size_t | split (const std::string &splitme, char delimiter, std::vector< std::string > *setme) |
Split a string on a character and put the pieces into a vector. | |
static size_t | splitWithoutEnds (const std::string &splitme, char delimiter, std::vector< std::string > *setme) |
Split a string on a character and put the pieces into a vector. | |
static size_t | splitOnFirst (const std::string &splitme, char delimiter, std::vector< std::string > *setme) |
Splits the string,s, on the first occurence of the character,sep, passsed in. | |
static size_t | splitToLines (const std::string &s, std::vector< std::string > &setme) |
Splits a text buf into a vector of lines. | |
static std::string | replaceCharacter (const std::string &str, char old_char, char new_char) |
In a string, replace one character with another. | |
static std::string | replaceWhiteSpace (const std::string &str, char new_char) |
Replace every white space character with another character. | |
static bool | similar (const std::string &, const std::string &) |
Compares two strings in a case-insensitive way. | |
static std::string | removeSubstrings (const std::string &original, const std::vector< std::string > &discards) |
Returns the string with any of these substrings removed. | |
static bool | isWhiteSpace (char c) |
template<typename Pred> | |
static size_t | countWords (const std::string &s, const Pred &pred, std::string::size_type pos=0) |
Counts the number of words in a string. | |
static size_t | countWords (const std::string &s, std::string::size_type pos=0) |
Convenience form of countWords() which treats whitespace as the delimiter between words. | |
template<typename Pred> | |
static bool | findNextWord (const std::string &s, std::string::size_type &setme_pos, std::string::size_type &setme_len, const Pred &pred, std::string::size_type pos_in=0) |
Finds the next word in a string. | |
static bool | findNextWord (const std::string &s, std::string::size_type &setme_pos, std::string::size_type &setme_len, std::string::size_type pos_in=0) |
Convenience form of findNextWord() which treats whitespace as the delimiter between words. | |
static void | replace (std::string &s, const std::string &from, const std::string &to) |
Replace all occurences of `from' with `to' in string `s'. | |
static bool | matches (const std::string &pattern, const std::string &test) |
*bl?h. | |
Classes | |
struct | DelimiterPred |
STL unary predicate. More... | |
struct | WhiteSpacePred |
STL unary predicate. More... |
static void code::Strings::capitalize | ( | std::string & | s | ) | [static] |
Capitalize every word.
static size_t code::Strings::countWords | ( | const std::string & | s, | |
std::string::size_type | pos = 0 | |||
) | [inline, static] |
Convenience form of countWords() which treats whitespace as the delimiter between words.
static size_t code::Strings::countWords | ( | const std::string & | s, | |
const Pred & | pred, | |||
std::string::size_type | pos = 0 | |||
) | [inline, static] |
Counts the number of words in a string.
The predicate `pred' is used to find word breaks.
static bool code::Strings::findNextWord | ( | const std::string & | s, | |
std::string::size_type & | setme_pos, | |||
std::string::size_type & | setme_len, | |||
std::string::size_type | pos_in = 0 | |||
) | [inline, static] |
Convenience form of findNextWord() which treats whitespace as the delimiter between words.
static bool code::Strings::findNextWord | ( | const std::string & | s, | |
std::string::size_type & | setme_pos, | |||
std::string::size_type & | setme_len, | |||
const Pred & | pred, | |||
std::string::size_type | pos_in = 0 | |||
) | [inline, static] |
Finds the next word in a string.
The predicate `pred' is used to find word breaks.
static bool code::Strings::isNumeric | ( | const std::string & | s | ) | [static] |
static bool code::Strings::isWhiteSpace | ( | char | c | ) | [inline, static] |
static bool code::Strings::matches | ( | const std::string & | pattern, | |
const std::string & | test | |||
) | [static] |
*bl?h.
* matches Goopblah.jpg for example...
static std::string code::Strings::removeSubstrings | ( | const std::string & | original, | |
const std::vector< std::string > & | discards | |||
) | [static] |
Returns the string with any of these substrings removed.
static void code::Strings::replace | ( | std::string & | s, | |
const std::string & | from, | |||
const std::string & | to | |||
) | [static] |
Replace all occurences of `from' with `to' in string `s'.
static std::string code::Strings::replaceCharacter | ( | const std::string & | str, | |
char | old_char, | |||
char | new_char | |||
) | [static] |
In a string, replace one character with another.
One useful application is
str = replaceCharacter( str, ' ', '_' );
which replaces white spaces with underscores. Note that this does nothing to tabs and new line characters.
str | string on which to operate | |
old_char | character to replace | |
new_char | replacement character |
static std::string code::Strings::replaceWhiteSpace | ( | const std::string & | str, | |
char | new_char | |||
) | [static] |
Replace every white space character with another character.
str | string on which to operate | |
new_char | replacement character |
static bool code::Strings::samePrefix | ( | const std::string & | , | |
const std::string & | , | |||
char | stopWhenReached | |||
) | [static] |
static bool code::Strings::similar | ( | const std::string & | , | |
const std::string & | ||||
) | [static] |
Compares two strings in a case-insensitive way.
static size_t code::Strings::split | ( | const std::string & | splitme, | |
char | delimiter, | |||
std::vector< std::string > * | setme | |||
) | [static] |
Split a string on a character and put the pieces into a vector.
splitme | the string to split | |
delimiter | split token to search for in `splitme' | |
setme | result |
static size_t code::Strings::split | ( | const std::string & | splitme, | |
std::vector< std::string > * | setme | |||
) | [static] |
Split a string on whitespace and put the pieces into a vector.
splitme | string to split | |
setme | split strings are stored here |
static size_t code::Strings::splitOnFirst | ( | const std::string & | splitme, | |
char | delimiter, | |||
std::vector< std::string > * | setme | |||
) | [static] |
Splits the string,s, on the first occurence of the character,sep, passsed in.
The pieces are placed into the vector passed in. Returns 2 if sep is in the string and zero if sep is not in the string.
Thus, the split produce a maximum of two pieces. In the absence of the sep character, no pieces are added to the vector, and zero is returned.
splitme | the string to split | |
delimiter | split token to search for in `splitme' | |
setme | result |
static size_t code::Strings::splitToLines | ( | const std::string & | s, | |
std::vector< std::string > & | setme | |||
) | [static] |
Splits a text buf into a vector of lines.
"a\nb\nc" -> "a", "b", "c" "a\nb\n\nc" -> "a", "b", "", "c" "a\nb\n\nc\n" -> "a", "b", "", "c"
static size_t code::Strings::splitWithoutEnds | ( | const std::string & | splitme, | |
char | delimiter, | |||
std::vector< std::string > * | setme | |||
) | [static] |
Split a string on a character and put the pieces into a vector.
splitme | the string to split | |
delimiter | split token to search for in `splitme' | |
setme | result |
static void code::Strings::toLower | ( | std::string & | s | ) | [static] |
Convert to lower case.
static void code::Strings::toUpper | ( | std::string & | s | ) | [static] |
Convert to upper case.
static std::string code::Strings::trimText | ( | const std::string & | s | ) | [static] |
removes leading and trailing white space.