12 #ifndef CARMA_UTIL_STRINGUTILS_H
13 #define CARMA_UTIL_STRINGUTILS_H
46 template <
typename T> ::std::string vectorToString
47 (const ::std::vector<T>& v, const ::std::string& delimiter=
", ") {
48 ::std::ostringstream os;
50 for(
int i=0; i<size; i++) {
71 template <
typename T> ::std::string setToString
72 (const ::std::set<T>& s, const ::std::string& delimiter=
", ") {
73 ::std::ostringstream os;
75 typename ::std::set<T>::iterator iter;
77 for(iter=s.begin(); iter != s.end(); iter++) {
134 static void toLower(::std::vector< ::std::string > & v);
141 static void toUpper(::std::vector< ::std::string > & v);
159 static ::std::string
erase(const ::std::string& str,
160 const ::std::vector<char>& chars);
168 const ::std::string & chars );
176 static ::std::string
trim( const ::std::string & str,
177 const ::std::string & chars );
209 static ::std::string
collapse(const ::std::string& str,
210 const ::std::vector<char>& chars);
222 static ::std::string
collapse(const ::std::string& str,
char c);
231 static ::std::string
replace(const ::std::string& str,
232 const ::std::string& origStr,
233 const ::std::string& replStr);
245 const ::std::string & str,
246 const ::std::string & delimiterSet =
" ",
247 bool skipNull =
true );
257 static ::std::vector< ::std::string >
258 tokenize( const ::std::string & str,
259 const ::std::string & delimiterSet =
" ",
260 bool skipNull =
true );
274 const ::std::string & str,
275 const size_t maxTokens,
276 const ::std::string & delimiterSet =
" ",
277 bool skipNull =
true );
289 static ::std::vector< ::std::string >
291 const size_t maxTokens,
292 const ::std::string & delimiterSet =
" ",
293 bool skipNull =
true );
295 static bool miniGlob(
const char *pattern,
const char *checkString);
319 static ::std::string
hms(
double angle,
int precision=2);
320 static ::std::string dms(
double angle,
int precision=3);
321 static ::std::string shms(
double angle,
int precision=2);
322 static ::std::string sdms(
double angle,
int precision=3);
323 static ::std::string sexa(
double angle,
bool sign,
bool hms,
int precision);
346 const std::string & anotherString);
361 const ::std::string & allowedChars );
369 static ::std::string
sort( const ::std::string & str,
377 static ::std::string
uniq( const ::std::string & str);
384 static ::std::string
reallyUniq( const ::std::string & str);
398 #endif // CARMA_UTIL_STRINGUTILS_H
::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)
static void trimWhiteSpaceInplace(::std::string &str)
Erase whitespace (' ', ,,) from beginning and end of string.
static void trimInplace(::std::string &str, const ::std::string &chars)
erase specified characters from the beginning and end of a string
virtual ~StringUtils()
Destructor.
::std::string uniq(const ::std::string &str)
::std::string lowASCIIAlphaNumericToLower(const ::std::string &str)
convert a string containing low ASCII alphanumeric and punctionation characters (unicode 0x20 to 0x7E...
static void toUpper(::std::vector< ::std::string > &v)
In place conversion of a vector of string to upper case.
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
Common string functions Additional string-related functions can be added here.
static void toLower(::std::vector< ::std::string > &v)
In place conversion of a vector of string to lower case.
static bool isEmptyOrContainsWhiteSpace(const ::std::string &s)
static int stringToInt(const ::std::string &str)
convert a string representation of an integer to an int
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
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 sub...
::std::string trim(const ::std::string &str, const ::std::string &chars)
erase specified characters from the beginning and end of a string
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 sub...
DigestType
digest type <ui> MD5 md5 SHA1 sha1
static bool equalsIgnoreCase(const std::string &aString, const std::string &anotherString)
Compares two strings, ignoring case considerations.
::std::string lowASCIIAlphaNumericToUpper(const ::std::string &str)
convert a string containing low ASCII alphanumeric and punctionation characters (unicode 0x20 to 0x7E...
enum carma::util::StringUtils::sortTypeEnum sortType
Sort type for sort( std::string, sortType ) method.
::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 ...
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. ...
::std::string replace(const ::std::string &str, const ::std::string &origStr, const ::std::string &replStr)
replace a substring within a string with another substring
::std::string sort(const ::std::string &str, const sortType direction=ASCENDING_SORT)
::std::string reallyUniq(const ::std::string &str)
::std::string trimWhiteSpace(const ::std::string &str)
Erase whitespace (' ', ,,) from beginning and end of string.
::std::string computeMessageDigest(const ::std::string &str, DigestType digestType)
compute the specified message digest for the specified string
::std::string erase(const ::std::string &str, const ::std::vector< char > &chars)
erase specified characters from a string
StringUtils()
Default constructor.