49 std::string
toString(
const std::vector<T>& v);
52 std::string
toString(
const std::list<T>& v);
55 std::string
toString(
const std::set<T>& v);
58 std::string
toString(
const std::deque<T>& q);
60 template<
typename T,
typename U>
61 std::string
toString(
const std::pair<T, U>& p);
64 std::string
toString(
const map<std::string, std::string>& m);
73 int parseString(
const std::string& str, std::vector<T>& v);
77 template<
typename T,
bool B>
78 struct parseInfToken {
79 static bool apply(
const std::string& token, T& value);
92 std::string
padString(
const std::string& str,
int padLength,
93 unsigned char padChar =
'0');
96 std::list<string>
breakString(
const std::string& str,
unsigned lineLength);
99 std::string&
trim(std::string& str);
102 string strReplaceSubstr(
const string& str,
const string& substr,
const string& rep);
122 string strReplaceExt(
const string &fullPath,
const string &ext);
142 std::string
toString(
const std::vector<T>& v)
145 for (
unsigned i = 0; i < v.size(); i++) {
152 std::string
toString(
const std::list<T>& v)
155 for (
typename std::list<T>::const_iterator it = v.begin(); it != v.end(); ++it) {
156 if (it != v.begin()) s <<
" ";
163 std::string
toString(
const std::set<T>& v)
167 for (
typename std::set<T>::const_iterator it = v.begin(); it != v.end(); ++it) {
175 std::string
toString(
const std::deque<T>& q)
178 for (
typename std::deque<T>::const_iterator it = q.begin(); it != q.end(); ++it) {
184 template<
typename T,
typename U>
185 std::string
toString(
const std::pair<T, U>& p)
188 s <<
"(" << p.first <<
", " << p.second <<
")";
196 std::stringstream buffer;
204 int lastPosition = buffer.tellg();
209 buffer.seekg(lastPosition, ios::beg);
212 if (!parseInfToken<T, numeric_limits<T>::has_infinity>::apply(token, data)) {
219 if (buffer.eof())
break;
227 struct parseInfToken<T, true> {
228 static bool apply(
const std::string& token, T& value) {
229 if (token.compare(
"-inf") == 0) {
230 value = -numeric_limits<T>::infinity();
231 }
else if (token.compare(
"inf") == 0) {
232 value = numeric_limits<T>::infinity();
242 struct parseInfToken<T, false> {
243 static bool apply(
const std::string& token, T& value) {
string strBaseName(const string &fullPath)
returns a base filename with directory and extension stripped
Definition: drwnStrUtils.cpp:242
string strReplaceSubstr(const string &str, const string &substr, const string &rep)
replaces any occurrences in str of substr with rep
Definition: drwnStrUtils.cpp:159
string millisecondsToString(unsigned ms)
conversion of milliseconds into a pretty string with units
Definition: drwnStrUtils.cpp:226
int strFileIndex(const string &fullPath)
returns the index of a file with format base<nnn>.ext
Definition: drwnStrUtils.cpp:317
std::string padString(const std::string &str, int padLength, unsigned char padChar='0')
pads str with padChar up to padLength size
std::string DRWN_ROW_BEG
row beginning when printing tables
std::string DRWN_COL_SEP
column separator when printing tables
Definition: acknowledgments.dox:1
string strWithoutExt(const string &fullPath)
returns the full path of a file with extension stripped off
Definition: drwnStrUtils.cpp:297
string strDirectory(const string &fullPath)
returns the directory for a full path (filename stripped)
Definition: drwnStrUtils.cpp:269
string strSpacifyCamelCase(const string &str)
inserts spaces into camelCase string str (e.g., strSpacifyCamelCase becomes "str spacify camel case")...
Definition: drwnStrUtils.cpp:180
string strReplaceExt(const string &fullPath, const string &ext)
replaces the extension of a given file with ext
Definition: drwnStrUtils.cpp:290
string strFilename(const string &fullPath)
returns a filename with directory stripped
Definition: drwnStrUtils.cpp:258
std::string DRWN_ROW_END
row ending when printing tables
std::list< string > breakString(const std::string &str, unsigned lineLength)
breaks long strings into rows
Definition: drwnStrUtils.cpp:117
string strWithoutEndSlashes(const string &fullPath)
strips all terminating directory separators from a path
Definition: drwnStrUtils.cpp:309
std::string toString(const T &v)
Templated function to make conversion from simple data types like int and double to strings easy for ...
Definition: drwnStrUtils.h:134
map< string, string > parseNameValueString(std::string str)
parses a string of the form "name=value ..." into (name, value) pairs
bool trueString(const std::string &str)
returns true if string matches one of "1", "true" or "yes"
string strExtension(const string &fullPath)
returns the extension for a given filename
Definition: drwnStrUtils.cpp:279
std::string & trim(std::string &str)
trim leading and trailing spaces (modifies str inline and returns it)
string bytesToString(unsigned b)
conversion of bytes into a pretty string with units
Definition: drwnStrUtils.cpp:201
int parseString(const std::string &str, std::vector< T > &v)
parses a string representation of a vector
Definition: drwnStrUtils.h:194
int strNoCaseCompare(const std::string &A, const std::string &B)
case-insensitive comparison of two strings