Darwin  1.10(beta)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Functions | Variables
drwnStrUtils.h File Reference

Generic string utilities. More...

Go to the source code of this file.


template<typename T >
std::string toString (const T &v)
 Templated function to make conversion from simple data types like int and double to strings easy for printing and debugging. Avoids messy char buffers.
template<typename T >
std::string toString (const std::vector< T > &v)
template<typename T >
std::string toString (const std::list< T > &v)
template<typename T >
std::string toString (const std::set< T > &v)
template<typename T >
std::string toString (const std::deque< T > &q)
template<typename T , typename U >
std::string toString (const std::pair< T, U > &p)
std::string toString (const map< std::string, std::string > &m)
 specialized toString() routine for name/value pairs
int drwn::strNoCaseCompare (const std::string &A, const std::string &B)
 case-insensitive comparison of two strings
template<typename T >
int drwn::parseString (const std::string &str, std::vector< T > &v)
 parses a string representation of a vector
map< string, string > drwn::parseNameValueString (std::string str)
 parses a string of the form "name=value ..." into (name, value) pairs
bool drwn::trueString (const std::string &str)
 returns true if string matches one of "1", "true" or "yes"
std::string drwn::padString (const std::string &str, int padLength, unsigned char padChar= '0')
 pads str with padChar up to padLength size
std::list< string > drwn::breakString (const std::string &str, unsigned lineLength)
 breaks long strings into rows
std::string & drwn::trim (std::string &str)
 trim leading and trailing spaces (modifies str inline and returns it)
string drwn::strReplaceSubstr (const string &str, const string &substr, const string &rep)
 replaces any occurrences in str of substr with rep
string drwn::strSpacifyCamelCase (const string &str)
 inserts spaces into camelCase string str (e.g., strSpacifyCamelCase becomes "str spacify camel case")
string drwn::bytesToString (unsigned b)
 conversion of bytes into a pretty string with units
string drwn::millisecondsToString (unsigned ms)
 conversion of milliseconds into a pretty string with units
string drwn::strBaseName (const string &fullPath)
 returns a base filename with directory and extension stripped
string drwn::strFilename (const string &fullPath)
 returns a filename with directory stripped
string drwn::strDirectory (const string &fullPath)
 returns the directory for a full path (filename stripped)
string drwn::strExtension (const string &fullPath)
 returns the extension for a given filename
string drwn::strReplaceExt (const string &fullPath, const string &ext)
 replaces the extension of a given file with ext
string drwn::strWithoutExt (const string &fullPath)
 returns the full path of a file with extension stripped off
string drwn::strWithoutEndSlashes (const string &fullPath)
 strips all terminating directory separators from a path
int drwn::strFileIndex (const string &fullPath)
 returns the index of a file with format base<nnn>.ext


std::string DRWN_COL_SEP
 column separator when printing tables
std::string DRWN_ROW_BEG
 row beginning when printing tables
std::string DRWN_ROW_END
 row ending when printing tables

Detailed Description

Generic string utilities.