Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

string_util Namespace Reference


Detailed Description

some common string processing functions, for std::string


Functions

char localeToUpper (char c)
 uses the standard library's "locale" to convert case of a single character
char localeToLower (char c)
 uses the standard library's "locale" to convert case of a single character
string makeUpper (const std::string &s) ATTR_must_check
 returns upper case version of s
string makeLower (const std::string &s) ATTR_must_check
 returns lower case version of s
string removePrefix (const std::string &str, const std::string &pre) ATTR_must_check
 returns str with pre removed - if pre is not fully matched, str is returned unchanged
string tildeExpansion (const std::string &str) ATTR_must_check
 replaces ~USER prefix with specified user's home directory, or ~ prefix with current HOME environment setting; returns str if no valid expansion is found
string trim (const std::string &str) ATTR_must_check
 removes whitespace (as defined by isspace()) from the beginning and end of str, and returns the result
bool parseArgs (const std::string &input, std::vector< std::string > &args, std::vector< unsigned int > &offsets)
 parses the input string into an arg list, with corresponding offsets of each arg in the original input
bool reMatch (const std::string &str, const std::string &regex)
 returns true if str matches re (assumes 'extended' regular expression, not 'basic'), false otherwise and throws std::string message on error
bool reMatch (const std::string &str, const std::string &regex, int flags)
 returns true if str matches re (with optional flags to control interpretation), false otherwise and throws std::string message on error

Variables

static const std::locale & curLocale = std::locale::classic()
 reference to the current standard library 'locale'


Function Documentation

char string_util::localeToLower ( char  c  ) 

uses the standard library's "locale" to convert case of a single character

Definition at line 19 of file string_util.cc.

char string_util::localeToUpper ( char  c  ) 

uses the standard library's "locale" to convert case of a single character

Definition at line 15 of file string_util.cc.

std::string string_util::makeLower ( const string &  s  ) 

std::string string_util::makeUpper ( const string &  s  ) 

returns upper case version of s

Definition at line 23 of file string_util.cc.

Referenced by WalkCalibration::setupReady().

bool string_util::parseArgs ( const string &  input,
vector< string > &  args,
vector< unsigned int > &  offsets 
)

parses the input string into an arg list, with corresponding offsets of each arg in the original input

Definition at line 78 of file string_util.cc.

Referenced by EchoBehavior::processEvent(), ControlBase::takeInput(), and Controller::takeLine().

bool string_util::reMatch ( const std::string &  str,
const std::string &  regex,
int  flags 
)

returns true if str matches re (with optional flags to control interpretation), false otherwise and throws std::string message on error

Parameters:
str The string to match
regex The regular expression which should be parsed and executed
flags pass flags for regex (e.g. REG_EXTENDED)
This compiles the regex and then executes it... for repeated usage of the same regular expression, you could be better off compiling it yourself and using the regex library directly.

Definition at line 139 of file string_util.cc.

bool string_util::reMatch ( const std::string &  str,
const std::string &  regex 
)

returns true if str matches re (assumes 'extended' regular expression, not 'basic'), false otherwise and throws std::string message on error

Parameters:
str The string to match
regex The (extended) regular expression which should be parsed and executed
This compiles the regex and then executes it... for repeated usage of the same regular expression, you could be better off compiling it yourself and using the regex library directly.

Definition at line 135 of file string_util.cc.

Referenced by PostureEngine::loadLine().

std::string string_util::removePrefix ( const string &  str,
const string &  pre 
)

returns str with pre removed - if pre is not fully matched, str is returned unchanged

Definition at line 35 of file string_util.cc.

std::string string_util::tildeExpansion ( const string &  str  ) 

replaces ~USER prefix with specified user's home directory, or ~ prefix with current HOME environment setting; returns str if no valid expansion is found

Definition at line 41 of file string_util.cc.

std::string string_util::trim ( const string &  str  ) 

removes whitespace (as defined by isspace()) from the beginning and end of str, and returns the result

Definition at line 66 of file string_util.cc.

Referenced by Config::parseLine(), and Controller::setConfig().


Variable Documentation

const std::locale& string_util::curLocale = std::locale::classic() [static]

reference to the current standard library 'locale'

Definition at line 13 of file string_util.cc.

Referenced by localeToLower(), Config::localeToLower(), and localeToUpper().


Tekkotsu v4.0
Generated Thu Nov 22 00:58:59 2007 by Doxygen 1.5.4