38std::string convertToString<std::string>(
const std::string &value,
int precision )
40 static_cast<void>( precision );
46char convertFromString<char>(
const std::string &str )
48 return (
char)atoi( str.c_str() );
53char16_t convertFromString<char16_t>(
const std::string &str )
55 return (
char16_t)atoi( str.c_str() );
60char32_t convertFromString<char32_t>(
const std::string &str )
62 return (
char32_t)atoi( str.c_str() );
67wchar_t convertFromString<wchar_t>(
const std::string &str )
69 return (
wchar_t)atoi( str.c_str() );
74signed char convertFromString<signed char>(
const std::string &str )
76 return (
signed char)atoi( str.c_str() );
81unsigned char convertFromString<unsigned char>(
const std::string &str )
83 return (
unsigned char)atoi( str.c_str() );
88short convertFromString<short>(
const std::string &str )
90 return (
short)atoi( str.c_str() );
95unsigned short convertFromString<unsigned short>(
const std::string &str )
97 return (
unsigned short)atoi( str.c_str() );
102int convertFromString<int>(
const std::string &str )
105 return std::stoi( str );
110unsigned int convertFromString<unsigned int>(
const std::string &str )
112 return (
unsigned int)strtoul( str.c_str(), 0, 0 );
117long convertFromString<long>(
const std::string &str )
119 return strtol( str.c_str(), 0, 0 );
124unsigned long convertFromString<unsigned long>(
const std::string &str )
126 return strtoul( str.c_str(), 0, 0 );
131long long convertFromString<long long>(
const std::string &str )
133 return strtoll( str.c_str(), 0, 0 );
138unsigned long long convertFromString<unsigned long long>(
const std::string &str )
140 return strtoull( str.c_str(), 0, 0 );
145float convertFromString<float>(
const std::string &str )
147 return strtof( str.c_str(), 0 );
152double convertFromString<double>(
const std::string &str )
154 return strtod( str.c_str(), 0 );
159long double convertFromString<long double>(
const std::string &str )
161 return strtold( str.c_str(), 0 );
170 while( isspace( c ) && i < str.length() )
173 if( c ==
'0' || c ==
'f' || c ==
'F' )
175 if( c ==
'1' || c ==
't' || c ==
'T' )
178 return (
bool)convertFromString<int>( str );
182void toLower( std::string &outstr,
const std::string &instr )
184 outstr.resize( instr.size() );
186 for(
size_t i = 0; i < instr.size(); ++i )
187 outstr[i] = tolower( instr[i] );
191std::string
toLower(
const std::string &instr )
201void toUpper( std::string &outstr,
const std::string &instr )
203 outstr.resize( instr.size() );
205 for(
size_t i = 0; i < instr.size(); ++i )
206 outstr[i] = toupper( instr[i] );
210std::string
toUpper(
const std::string &instr )
224 outstr.erase( std::remove_if( outstr.begin(), outstr.end(), ::isspace ), outstr.end() );
238int stringWrap( std::vector<std::string> &lines,
const std::string &str,
int width )
240 int L = str.length();
244 int startPos, tmpPos, endPos;
255 endPos = startPos + width;
259 lines.push_back( str.substr( startPos, L - startPos ) );
266 while( !isspace( str[tmpPos] ) && tmpPos >= startPos )
270 if( tmpPos > startPos )
273 lines.push_back( str.substr( startPos, endPos - startPos ) );
278 if( str[startPos] ==
' ' )
void toUpper(std::string &outstr, const std::string &instr)
Convert a string to all upper case.
int stringWrap(std::vector< std::string > &lines, const std::string &str, int width)
Wrap a string by breaking it into smaller sized portions of a desired width.
void toLower(std::string &outstr, const std::string &instr)
Convert a string to all lower case.
bool convertFromString< bool >(const std::string &str)
Template specialization of convertFromString for bool.
void removeWhiteSpace(std::string &outstr, const std::string &instr)
Remove all white space from a string.
Utilities for working with strings.