tecplot::toolbox::StrUtil Class Reference

#include <StrUtil.h>


Static Public Member Functions

static bool isWhiteSpace (const char C)
 Determine if the specified characater is whitespace or not.
static void trim (std::string &str)
 Remove leading whitespace from a string.
static bool scanForSymbol (std::string &str, const char symbol)
 Find and remove a symbol for the beginning of a string.
static bool scanForLgIndex (std::string &str, LgIndex_t *value)
 Find a LgIndex_t value at the beginning of a string.
static void toUpper (std::string &str)
 Convert the supplied string to uppercase.
static void toLower (std::string &str)
 Convert the supplied string to uppercase.
static std::vector< std::string > split (std::string str, std::string delimiters=",", bool discardEmptyStrings=false)
 Splits a string around matches of the supplied delimiters.


Member Function Documentation

static bool tecplot::toolbox::StrUtil::isWhiteSpace ( const char  C  )  [static]

Determine if the specified characater is whitespace or not.

Parameters:
C Character to check.
Returns:
true if the character is considered whitespace, false otherwise.

static void tecplot::toolbox::StrUtil::trim ( std::string &  str  )  [static]

Remove leading whitespace from a string.

Parameters:
str String which should have white space removed.
   std::string strValue("   \t   Hi Mom\n");
   cout << strValue.c_str();
   trimWhiteSpace(strValue);
   cout << strValue.c_str();

   Output:
   "           Hi Mom"
   "Hi Mom"

static bool tecplot::toolbox::StrUtil::scanForSymbol ( std::string &  str,
const char  symbol 
) [static]

Find and remove a symbol for the beginning of a string.

Parameters:
str String in which to search for the symbol
symbol Character to search for
Returns:
true if symbol is the next non-whitespace character in the string. If the symbol is found, it will be removed from the front of the string. Whitespace is always trimmed from the front of the string regardless of the return value. false if the symbol is not the next non-whitespace character.
   std::string strValue("  [1,2,3]\n");
   cout << strValue.c_str();
   scanForSymbol(strValue, '!');
   cout << strValue.c_str();
   scanForSymbol(strValue, '[');
   cout << strValue.c_str();

   Output:
   "  [1,2,3]"  // Original string
   "[1,2,3]"    // After looking for '!', the leading whitespace is trimmed
   "1,2,3]"     // Found '[' and removed it.

See also:
StrUtil::scanForLgIndex

static bool tecplot::toolbox::StrUtil::scanForLgIndex ( std::string &  str,
LgIndex_t value 
) [static]

Find a LgIndex_t value at the beginning of a string.

Parameters:
str String in which to search for a LgIndex_t value.
value LgIndex_t pointer in which to stuff the result.
Returns:
true if the next non-whitspace series of characters in the string evaluate to a LgIndex_t. Whitespace is always trimmed from the front of the string. The string will be modified regardless of the return value. If this function returns false the string may be in an unknown state.
   std::string strValue("1,2,3\n");
   cout << strValue.c_str();
   LgIndex_t value;
   scanForLgIndex(strValue, &value);
   cout << strValue.c_str();

   Output:
   "1,2,3"  // Original string
   ",2,3"   // After looking for the LgIndex_t value

static void tecplot::toolbox::StrUtil::toUpper ( std::string &  str  )  [static]

Convert the supplied string to uppercase.

Parameters:
str The string to be converted to uppercase.

static void tecplot::toolbox::StrUtil::toLower ( std::string &  str  )  [static]

Convert the supplied string to uppercase.

Parameters:
str The string to be converted to uppercase.

static std::vector<std::string> tecplot::toolbox::StrUtil::split ( std::string  str,
std::string  delimiters = ",",
bool  discardEmptyStrings = false 
) [static]

Splits a string around matches of the supplied delimiters.

Parameters:
str The delmited string to be split
delimiters Zero or more characters to be used as delimiters. If the delimiter is a zero length string, the input string will not be split.
discardEmptyStrings If true, empty strings will not be included in the result If false, empty strings may be included in the result
Returns:
Returns a vector of strings computed by splitting the supplied string around matches of the supplied delimiters.
   StrUtil::split("a,b,,c,", ",", false);
   // result will be: { "a", "b", "", "c", "" }

   StrUtil::split("a,b,,c,", ",", true);
   // result will be: { "a", "b", "c" }

   StrUtil::split("hi,mom;hi,\n;dad", ",\n;", false);
   // result will be: {"hi", "mom", "hi", "", "", "dad"}

   StrUtil::split("hi,mom;hi,\n;dad", ",\n;", true);
   // result will be: {"hi", "mom", "hi", "dad"}


Generated on Tue Mar 12 02:24:48 2013 for Tecplot by  doxygen 1.5.5