30 #ifndef CORE_UTIL_STRINGUTIL_H
31 #define CORE_UTIL_STRINGUTIL_H 1
57 std::string
data = str;
58 for (
size_t j=0; j<data.size(); j++)
59 if ((data[j] ==
'\t')||(data[j] ==
'\r')||(data[j] ==
'\n')||(data[j]==
'"')) data[j] =
' ';
61 std::vector<std::string> nums;
62 for (
size_t p=0;p<data.size();)
64 while((data[p] ==
' ')&&(p<data.size())) p++;
65 if (p >= data.size())
break;
68 if (next_space == std::string::npos) next_space = data.size();
70 if (
from_string(data.substr(p,next_space-p), value)) values.push_back(value);
73 if (p >= data.size())
break;
75 if (values.size() > 0)
return (
true);
82 std::istringstream iss(str+
" ");
83 iss.exceptions(std::ifstream::eofbit | std::ifstream::failbit | std::ifstream::badbit);
109 std::ostringstream oss;
117 std::ostringstream oss;
118 oss.precision(precision);
128 inline std::string
basename(
const std::string &path)
129 {
return (path.substr(path.rfind(
'/')+1)); }
133 inline std::string
pathname(
const std::string &path)
134 {
return (path.substr(0, path.rfind(
'/')+1)); }
149 const std::string &substr,
150 const std::string &replacement);
std::string string_tolower(std::string str)
Definition: StringUtil.cc:154
std::vector< std::string > split_string(const std::string &str, char sep)
Definition: StringUtil.cc:50
std::string to_string(const MatrixHandle &mat)
Definition: Matrix.h:213
bool string_to_int(const std::string &str, int &result)
Definition: StringUtil.h:98
std::string string_toupper(std::string str)
Definition: StringUtil.cc:144
std::string string_Cify(const std::string &str)
C++ify a string, turn newlines into , use , , \ ", etc.
Definition: StringUtil.cc:78
#define SCISHARE
Definition: share.h:39
bool string_to_double(const std::string &str, double &result)
Definition: StringUtil.h:100
list values
Definition: readAllFields.py:22
bool from_string(const std::string &str, double &value)
Definition: StringUtil.cc:163
void strip_surrounding_spaces(std::string &str)
Definition: StringUtil.cc:374
bool string_to_unsigned_long(const std::string &str, unsigned long &result)
Definition: StringUtil.h:102
std::string replace_substring(std::string str, const std::string &substr, const std::string &replacement)
Definition: StringUtil.cc:120
long long size_type
Definition: Types.h:40
dictionary data
Definition: eabLatVolData.py:11
bool string_to_bool(const std::string &str, bool &result)
Definition: StringUtil.h:96
void strip_spaces(std::string &str)
Definition: StringUtil.cc:357
std::string pathname(const std::string &path)
Return directory name.
Definition: StringUtil.h:133
bool multiple_from_string(const std::string &str, std::vector< T > &values)
Definition: StringUtil.h:53
char * ccast_unsafe(const std::string &str)
Unsafe cast from string to char *, used to export strings to C functions.
Definition: StringUtil.cc:41
bool ends_with(const std::string &str, const std::string &substr)
Definition: StringUtil.cc:137
std::string basename(const std::string &path)
Remove directory name.
Definition: StringUtil.h:128