39 std::string convertToString<std::string>(
const std::string & value,
43 static_cast<void>(precision);
49 char convertFromString<char>(
const std::string & str )
51 return (
char) atoi(str.c_str());
56 char16_t convertFromString<char16_t>(
const std::string & str )
58 return (char16_t) atoi(str.c_str());
63 char32_t convertFromString<char32_t>(
const std::string & str )
65 return (char32_t) atoi(str.c_str());
70 wchar_t convertFromString<wchar_t>(
const std::string & str )
72 return (
wchar_t) atoi(str.c_str());
77 signed char convertFromString<signed char>(
const std::string & str )
79 return (
signed char) atoi(str.c_str());
84 unsigned char convertFromString<unsigned char>(
const std::string & str )
86 return (
unsigned char) atoi(str.c_str());
92 short convertFromString<short>(
const std::string & str )
94 return (
short) atoi(str.c_str());
99 unsigned short convertFromString<unsigned short>(
const std::string & str )
101 return (
unsigned short) atoi(str.c_str());
106 int convertFromString<int>(
const std::string & str )
108 return atoi(str.c_str());
113 unsigned int convertFromString<unsigned int>(
const std::string & str )
115 return (
unsigned int) strtoul(str.c_str(),0,0);
120 long convertFromString<long>(
const std::string & str )
122 return strtol(str.c_str(), 0, 0);
127 unsigned long convertFromString<unsigned long>(
const std::string & str)
129 return strtoul(str.c_str(), 0, 0);
134 long long convertFromString<long long>(
const std::string & str )
136 return strtoll(str.c_str(), 0, 0);
141 unsigned long long convertFromString<unsigned long long>(
const std::string & str )
143 return strtoull(str.c_str(), 0, 0);
148 float convertFromString<float>(
const std::string & str )
150 return strtof(str.c_str(), 0);
155 double convertFromString<double>(
const std::string & str )
157 return strtod(str.c_str(), 0);
162 long double convertFromString<long double>(
const std::string & str )
164 return strtold(str.c_str(), 0);
173 while(isspace(
c) && i < str.length())
c = str[i++];
175 if(
c ==
'0' ||
c ==
'f' ||
c ==
'F')
return false;
176 if(
c ==
'1' ||
c ==
't' ||
c ==
'T')
return true;
178 return (
bool) convertFromString<int>(str);
183 const std::string & instr
186 outstr.resize(instr.size());
188 for(
size_t i=0; i < instr.size(); ++i) outstr[i] = tolower(instr[i]);
193 std::string
toLower(
const std::string & instr )
204 const std::string & instr
207 outstr.resize(instr.size());
209 for(
size_t i=0; i < instr.size(); ++i) outstr[i] = toupper(instr[i]);
214 std::string
toUpper(
const std::string & instr )
225 const std::string & instr
230 outstr.erase(std::remove_if(outstr.begin(), outstr.end(), ::isspace), outstr.end());
245 const std::string & str,
249 int L = str.length();
252 int startPos, tmpPos, endPos;
260 if(startPos == L) --startPos;
262 endPos = startPos + width;
266 lines.push_back( str.substr( startPos, L-startPos ));
273 while( !isspace(str[tmpPos]) && tmpPos >= startPos ) --tmpPos;
276 if(tmpPos > startPos) endPos = tmpPos;
279 lines.push_back( str.substr( startPos, endPos-startPos) );
285 if( str[startPos] ==
' ') ++startPos;
constexpr units::realT c()
The speed of light.
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.