Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Static Public Member Functions | List of all members
BIAS::StringUtils Class Reference

Contains some useful methods for string manipulation. More...

#include <Utils/StringUtils.hh>

Static Public Member Functions

static bool CompareNoCase (const std::string &str1, const std::string &str2)
 compare two strings ignoring their case More...
 
static void Explode (const std::string &str, const std::string &seperator, std::vector< std::string > &ret)
 Explodes the given string into tokens which are separated by the given separator string. More...
 
static std::string LeadingZeroString (int value, int num)
 
static std::string PadUintByMaxValue (unsigned int value, unsigned int max)
 Pads the given value with leading zeroes so that the string representation will use the same number of characters as max. More...
 
static std::string PadUintByNumChars (unsigned int value, unsigned int num)
 Pads the given number with leading zeroes so that the string representation will use the number of characters determined by num (if it is not already bigger). More...
 
static void SplitByChars (const std::string &str, std::vector< std::string > &ret, const std::string &charsToSplit="\t\n ,;")
 Splits the given string into tokens which are separated by any of the given separator characters (similar to #StringUtils::Explode). More...
 
static void Trim (const std::string &str, std::string &ret, const std::string &charsToTrim=" \t\n")
 Trims the given string, i.e. More...
 

Detailed Description

Contains some useful methods for string manipulation.

Author
rwulff 04/2010

Definition at line 47 of file StringUtils.hh.

Member Function Documentation

static bool BIAS::StringUtils::CompareNoCase ( const std::string &  str1,
const std::string &  str2 
)
inlinestatic

compare two strings ignoring their case

Parameters
[in]str1first string to compare
[in]str2second string to compare
Returns
true if strings are equal, false otherwise

Definition at line 122 of file StringUtils.hh.

void BIAS::StringUtils::Explode ( const std::string &  str,
const std::string &  seperator,
std::vector< std::string > &  ret 
)
static

Explodes the given string into tokens which are separated by the given separator string.

Usage example:

std::vector<std::string> retVec; StringUtils.Explode("token1 token2 token3", " ", retVec);

retVec will now contain the three elements "token1", "token2" and "token3"

Parameters
strthe string to explode
seperatorthe string that separates each token from the next
reta vector that contains the single tokens

Definition at line 27 of file StringUtils.cpp.

static std::string BIAS::StringUtils::LeadingZeroString ( int  value,
int  num 
)
inlinestatic
Deprecated:
call PadUintByNumChars() instead

Definition at line 134 of file StringUtils.hh.

static std::string BIAS::StringUtils::PadUintByMaxValue ( unsigned int  value,
unsigned int  max 
)
inlinestatic

Pads the given value with leading zeroes so that the string representation will use the same number of characters as max.

Parameters
valuethe value to pad
maxvalue is padded to use the same number of characters as this one
Returns
the padded string

Definition at line 171 of file StringUtils.hh.

static std::string BIAS::StringUtils::PadUintByNumChars ( unsigned int  value,
unsigned int  num 
)
inlinestatic

Pads the given number with leading zeroes so that the string representation will use the number of characters determined by num (if it is not already bigger).

Parameters
valuethe value to pad
numvalue is padded to use this number of characters
Returns
the padded string

Definition at line 152 of file StringUtils.hh.

void BIAS::StringUtils::SplitByChars ( const std::string &  str,
std::vector< std::string > &  ret,
const std::string &  charsToSplit = "\t\n ,;" 
)
static

Splits the given string into tokens which are separated by any of the given separator characters (similar to #StringUtils::Explode).

Parameters
strthe string to split
reta vector that contains the single tokens
seperatorthe characters that separate each token from the next

Definition at line 59 of file StringUtils.cpp.

void BIAS::StringUtils::Trim ( const std::string &  str,
std::string &  ret,
const std::string &  charsToTrim = " \t\n" 
)
static

Trims the given string, i.e.

removes all permutations of the given charsToTrim from the front and the end of the string.

Usage example:

std::string retStr; StringUtils::Trim("_/_string_/_", retStr, "/_");

retStr will now be "string"

Parameters
strthe string to trim
retthe trimmed string
charsToTrimthe characters to remove from the front and the end of the string. the default is to remove all whitespace charakters (spaces, tabs and newlines). note that the order of characters is irrelevant

Definition at line 81 of file StringUtils.cpp.


The documentation for this class was generated from the following files: