CARMA C++
|
Common string functions Additional string-related functions can be added here. More...
#include <carma/util/StringUtils.h>
Public Types | |
typedef enum carma::util::StringUtils::sortTypeEnum | sortType |
Sort type for sort( std::string, sortType ) method. More... | |
enum | sortTypeEnum { ASCENDING_SORT, DESCENDING_SORT } |
Public Member Functions | |
StringUtils () | |
Default constructor. More... | |
static::std::vector < ::std::string > | tokenize (const ::std::string &str, const ::std::string &delimiterSet=" ", bool skipNull=true) |
split a string into substrings based on a delimiter character set More... | |
static::std::vector < ::std::string > | tokenizeN (const ::std::string &str, const size_t maxTokens, const ::std::string &delimiterSet=" ", bool skipNull=true) |
split a string into substrings based on a delimiter character set stopping if a maximum number of substrings is found More... | |
virtual | ~StringUtils () |
Destructor. More... | |
Static Public Member Functions | |
::std::string | collapse (const ::std::string &str, const ::std::vector< char > &chars) |
collapse consecutive repeats of a single character in specified character list to a single character More... | |
::std::string | collapse (const ::std::string &str, char c) |
collapse consecutive repeats of a single character in specified character list to a single character More... | |
::std::string | computeMessageDigest (const ::std::string &str, DigestType digestType) |
compute the specified message digest for the specified string More... | |
static bool | containsOnly (const ::std::string &str, const ::std::string &allowedChars) |
Checks that the input string is made up of only the characters from a given list. More... | |
::std::string | dms (double angle, int precision=3) |
static bool | equalsIgnoreCase (const std::string &aString, const std::string &anotherString) |
Compares two strings, ignoring case considerations. More... | |
::std::string | erase (const ::std::string &str, const ::std::vector< char > &chars) |
erase specified characters from a string More... | |
::std::string | hms (double angle, int precision=2) |
convert a number into sexadecimal HMS/DMS notation, with or without a sign [+/-]HH:MM:SS.ss or [+/-]DDD:MM:SS.sss (precision# digits) More... | |
static bool | isEmptyOrContainsWhiteSpace (const ::std::string &s) |
::std::string | lowASCIIAlphaNumericToLower (const ::std::string &str) |
convert a string containing low ASCII alphanumeric and punctionation characters (unicode 0x20 to 0x7E) to lower case More... | |
::std::string | lowASCIIAlphaNumericToUpper (const ::std::string &str) |
convert a string containing low ASCII alphanumeric and punctionation characters (unicode 0x20 to 0x7E) to upper case More... | |
static bool | miniGlob (const char *pattern, const char *checkString) |
::std::string | reallyUniq (const ::std::string &str) |
::std::string | replace (const ::std::string &str, const ::std::string &origStr, const ::std::string &replStr) |
replace a substring within a string with another substring More... | |
::std::string | sdms (double angle, int precision=3) |
::std::string | sexa (double angle, bool sign, bool hms, int precision) |
::std::string | shms (double angle, int precision=2) |
::std::string | sort (const ::std::string &str, const sortType direction=ASCENDING_SORT) |
static int | stringToInt (const ::std::string &str) |
convert a string representation of an integer to an int More... | |
static void | tokenizeInplace (::std::vector< ::std::string > &tokens, const ::std::string &str, const ::std::string &delimiterSet=" ", bool skipNull=true) |
split a string into substrings based on a delimiter character set More... | |
static void | tokenizeNInplace (::std::vector< ::std::string > &tokens, const ::std::string &str, const size_t maxTokens, const ::std::string &delimiterSet=" ", bool skipNull=true) |
split a string into substrings based on a delimiter character set stopping if a maximum number of substrings is found More... | |
static void | toLower (::std::vector< ::std::string > &v) |
In place conversion of a vector of string to lower case. More... | |
static void | toUpper (::std::vector< ::std::string > &v) |
In place conversion of a vector of string to upper case. More... | |
::std::string | trim (const ::std::string &str, const ::std::string &chars) |
erase specified characters from the beginning and end of a string More... | |
static void | trimInplace (::std::string &str, const ::std::string &chars) |
erase specified characters from the beginning and end of a string More... | |
::std::string | trimWhiteSpace (const ::std::string &str) |
Erase whitespace (' ', ,,) from beginning and end of string. More... | |
static void | trimWhiteSpaceInplace (::std::string &str) |
Erase whitespace (' ', ,,) from beginning and end of string. More... | |
::std::string | uniq (const ::std::string &str) |
Common string functions Additional string-related functions can be added here.
This class contains no state.
Definition at line 94 of file StringUtils.h.
Sort type for sort( std::string, sortType ) method.
Enumerator | |
---|---|
ASCENDING_SORT |
do an ascending sort |
DESCENDING_SORT |
do an descending sort |
Definition at line 101 of file StringUtils.h.
carma::util::StringUtils::StringUtils | ( | ) |
Default constructor.
|
virtual |
Destructor.
|
static |
collapse consecutive repeats of a single character in specified character list to a single character
"abc def" -> "abc def"
str | the string from which to collapse characters |
chars | characters to collapse |
|
static |
collapse consecutive repeats of a single character in specified character list to a single character
"abc def" -> "abc def"
str | the string from which to collapse characters |
c | repeated character to collapse |
|
static |
compute the specified message digest for the specified string
str | the string for which to compute the digest |
digestType | the type of digest to compute |
|
static |
Checks that the input string is made up of only the characters from a given list.
Match is case-insensitive.
str | the string to check |
allowedChars | string containing characters allowed in str |
|
static |
Compares two strings, ignoring case considerations.
Two strings are considered equal ignoring case if they are of the same length, and corresponding characters in the two strings are equal ignoring case.
aString | First string to compare |
anotherString | Second string to compare |
|
static |
erase specified characters from a string
str | the string from which to remove characters |
chars | characters to remove |
|
static |
convert a number into sexadecimal HMS/DMS notation, with or without a sign [+/-]HH:MM:SS.ss or [+/-]DDD:MM:SS.sss (precision# digits)
|
static |
s | The input string to check |
|
static |
convert a string containing low ASCII alphanumeric and punctionation characters (unicode 0x20 to 0x7E) to lower case
str | The string to be converted |
out_of_range | if any character in the input string is not in the range 0x20 to 0x7E |
|
static |
convert a string containing low ASCII alphanumeric and punctionation characters (unicode 0x20 to 0x7E) to upper case
str | The string to be converted |
out_of_range | if any character in the input string is not in the range 0x20 to 0x7E |
|
static |
|
static |
replace a substring within a string with another substring
str | the string |
origSubstr | the original substring to replace |
replSubstr | the replacement substring |
|
static |
str | The string to sort |
direction | Enum value indicating whether to do an ascending or descending sort. Default is ascending sort. |
|
static |
convert a string representation of an integer to an int
returns 5893
throws a carma::util::IllegalArgumentException
str | the string representation of the int |
carma::util::IllegalArgumentException | if str isn't really the string representation of an int |
static ::std::vector< ::std::string > carma::util::StringUtils::tokenize | ( | const ::std::string & | str, |
const ::std::string & | delimiterSet = " " , |
||
bool | skipNull = true |
||
) |
split a string into substrings based on a delimiter character set
str | the input string to tokenize |
delimiterSet | the delimiter character set to use to tokenize the string |
skipNull | skip null tokens if true |
|
static |
split a string into substrings based on a delimiter character set
tokens | vector that will be filled in with the split substrings |
str | the input string to tokenize |
delimiterSet | the delimiter character set to use to tokenize the string |
skipNull | skip null tokens if true |
static ::std::vector< ::std::string > carma::util::StringUtils::tokenizeN | ( | const ::std::string & | str, |
const size_t | maxTokens, | ||
const ::std::string & | delimiterSet = " " , |
||
bool | skipNull = true |
||
) |
split a string into substrings based on a delimiter character set stopping if a maximum number of substrings is found
str | the input string to tokenize |
maxTokens | maximum number of tokens to stop after |
delimiterSet | the delimiter character set to use to tokenize the string |
skipNull | skip null tokens if true |
|
static |
split a string into substrings based on a delimiter character set stopping if a maximum number of substrings is found
tokens | vector that will be filled in with the split substrings |
str | the input string to tokenize |
maxTokens | maximum number of tokens to stop after |
delimiterSet | the delimiter character set to use to tokenize the string |
skipNull | skip null tokens if true |
|
static |
In place conversion of a vector of string to lower case.
v | The vector<string> to be converted |
|
static |
In place conversion of a vector of string to upper case.
v | The vector<string> to be converted |
|
static |
erase specified characters from the beginning and end of a string
str | the string from which to remove characters |
chars | String with characters to remove from the beginning and end |
|
static |
erase specified characters from the beginning and end of a string
str | the string from which to remove characters |
chars | characters to remove from the beginning and end |
|
static |
Erase whitespace (' ',
,,) from beginning and end of string.
This method calls StringUtils::trim(const ::std::string&,const ::std::vector<char>&) with an appropriate set of chars.
str | the string from which to remove characters |
|
static |
Erase whitespace (' ',
,,) from beginning and end of string.
This method calls trim with the above set of chars.
str | the string from which to remove characters |
|
static |