60 template <
class Pred = IsSpace>
74 static void tokenize(std::vector<std::string>& tokens,
const std::string& stringToParse,
const Pred& predFxn = Pred());
85 static void tokenize(std::vector<std::string>& tokens,
const std::string& stringToParse,
const std::string& delimiter);
103 std::string::const_iterator it = stringToParse.begin();
104 std::string::const_iterator itTokenEnd = stringToParse.begin();
105 while (it != stringToParse.end())
115 itTokenEnd = std::find_if(it, stringToParse.end(), predFxn);
119 tokens.push_back(std::string(it, itTokenEnd));
137 IsSpace(
const std::locale& loc = std::locale(DEFAULT_LOCALE_NAME.c_str())) : mLocale(loc) {}
139 const std::locale&
GetLocale()
const {
return mLocale; }
140 bool operator()(
char c)
const {
return std::isspace(c, mLocale); }
254 : mString(mainString)
255 , mCaseSensitive(caseSensitive)
259 bool operator() (
const std::string& toCompare)
261 return StrCompare(toCompare, mString, mCaseSensitive) == 0;
286 template<
class VecType>
287 bool ParseVec(
const std::string& value, VecType& vec,
unsigned size,
unsigned numberPrecision = 16)
292 if (value.empty() || value ==
"NULL")
294 for (i = 0; i < size; ++i)
301 std::istringstream iss(value);
302 iss.precision(numberPrecision);
303 for (i = 0; i < size && !iss.eof(); ++i)
334 std::string
ToString(
const T& t,
int precision = -1)
336 std::ostringstream ss;
339 ss.precision(precision);
365 std::istringstream is;
bool operator()(char c) const
A functor for using std::find or whatever that will compare two strings case sensitive or insensitive...
A unary function created to have a compatibility to the old std::unary_function while still using c++...
A functor which tests if a character is whitespace.
#define TR_DISABLE_WARNING_START_MSVC(...)
static const std::string DEFAULT_LOCALE_NAME
Generic string delimeter check function class.
const std::string & mString
The predicate should evaluate to true when applied to a separator.
bool TR_UTIL_EXPORT Match(const char *wildCards, const char *str)
Matches.
static const std::string STR_BLANK("")
Constant value for a blank String.
bool ParseVec(const std::string &value, VecType &vec, unsigned size, unsigned numberPrecision=16)
A templated function for taking any of the osg vector types and reading the data from a string...
std::string ToString(const T &t, int precision=-1)
A utility function to convert a basic type into a string.
bool operator()(char c) const
bool TR_UTIL_EXPORT TakeToken(std::string &data, std::string &outToken, char openChar, char closeChar)
Reads the next token fromm the given string data.
void TR_UTIL_EXPORT FindAndReplace(std::string &modifiedString, const std::string &findWhat, const std::string &replaceWith)
Finds all instances of the findWhat string in the string modifiedString and replaces them with the re...
static void tokenize(std::vector< std::string > &tokens, const std::string &stringToParse, const Pred &predFxn=Pred())
The predicate should evaluate to true when applied to a separator.
#define TR_DISABLE_WARNING_END
bool TR_UTIL_EXPORT FromString< bool >(const std::string &u)
Special exception for bool where things like "True", "TRUE", and "true" should be accepted...
T FromString(const std::string &u)
Converts a string to a specified type.
TR_UTIL_EXPORT const std::string & Trim(std::string &toTrim)
Trims whitespace off the front and end of a string.
A class that represents date time utility.
StrCompareFunc(const std::string &mainString, bool caseSensitive=true)
Constructor.
bool operator()(char c) const
TR_UTIL_EXPORT void ToUpperCase(std::string &str)
Converts the whole string to upper case.
TR_UTIL_EXPORT int StrCompare(const std::string &one, const std::string &two, bool caseSensitive=true)
Compares strings like strcmp or stricmp or strcasecmp.
void TR_UTIL_EXPORT MakeIndexString(unsigned index, std::string &toFill, unsigned paddedLength=4)
Makes index string.
IsSpace(const std::locale &loc=std::locale(DEFAULT_LOCALE_NAME.c_str()))
Determines if the current character is a forward slash.
TR_UTIL_EXPORT void ToLowerCase(std::string &str)
Converts the whole string to lower case.
const std::locale & GetLocale() const