23 #ifndef O2SCL_STRING_CONV_H 24 #define O2SCL_STRING_CONV_H 37 #include <o2scl/misc.h> 39 #ifndef DOXYGEN_NO_O2NS 50 std::string
ptos(
void *p);
54 std::string
itos(
int x);
58 std::string
szttos(
size_t x);
64 std::string
btos(
bool b);
73 std::string
dtos(
double x,
int prec=6,
bool auto_prec=
false);
87 std::string
dtos(
double x, std::ostream &format);
93 int stoi(std::string s);
106 size_t stoszt(std::string s);
127 bool stob(std::string s,
bool err_on_fail=
true);
137 double stod(std::string s);
199 void split_string(std::string str, std::vector<std::string> &sv);
204 void rewrap(std::string str, std::vector<std::string> &sv,
210 template<
class size_vec_t>
215 std::vector<std::string> ranges;
217 while (k<x.length()) {
218 size_t loc=x.find(
',',k);
219 if (loc!=std::string::npos) {
220 std::string stemp=x.substr(k,loc-k);
221 ranges.push_back(stemp);
225 ranges.push_back(x.substr(k,x.length()-k));
230 size_t uitmp, uitmp2;
231 for(
size_t j=0;j<ranges.size();j++) {
232 if (ranges[j].find(
'-')==std::string::npos) {
234 if (ret!=0)
return ret;
235 list.push_back(uitmp);
237 size_t loc=ranges[j].find(
'-');
238 std::string sstart=ranges[j].substr(0,loc);
239 std::string send=ranges[j].substr(loc+1,ranges[j].size()-loc);
241 if (ret!=0)
return ret;
243 if (ret!=0)
return ret;
244 for(
size_t jk=uitmp;jk<=uitmp2;jk++) {
254 #ifndef DOXYGEN_NO_O2NS int stoszt_nothrow(std::string s, size_t &result)
Convert a string to a size_t without throwing an exception.
The main O<span style='position: relative; top: 0.3em; font-size: 0.8em'>2</span>scl O$_2$scl names...
void rewrap(std::string str, std::vector< std::string > &sv, size_t ncol=79)
Rewrap a string into a single column, avoiding strings less than a particular number of characters...
int string_to_uint_list(const std::string &x, size_vec_t &list)
Convert a string-based list of unsigned integers to a list.
std::string btos(bool b)
Convert a boolean value to a string.
size_t size_of_exponent(double x)
Returns the number of characters required to display the exponent of x in scientific mode...
bool stob(std::string s, bool err_on_fail=true)
Convert a string to a boolean value.
double function_to_double(std::string s)
Convert a formula to a double.
size_t stoszt(std::string s)
Convert a string to a size_t.
int stod_nothrow(std::string s, double &result)
Convert a string to a double returning non-zero value for failure.
bool has_minus_sign(double *x)
Find out if the number pointed to by x has a minus sign.
std::string dtos(double x, int prec=6, bool auto_prec=false)
Convert a double to a string.
int stoi_nothrow(std::string s, int &result)
Convert a string to an integer without throwing an exception.
bool is_number(std::string s)
Return true if the string s is likely a integral or floating point number.
double stod(std::string s)
Convert a string to a double.
void split_string(std::string str, std::vector< std::string > &sv)
Split a string into words using whitespace for delimiters and (partially) respecting quotes...
std::string ptos(void *p)
Convert a pointer to a string.
std::string itos(int x)
Convert an integer to a string.
std::string szttos(size_t x)
Convert a size_t to a string.
int stoi(std::string s)
Convert a string to an integer.