12 #ifndef SST_CORE_STRINGIZE_H
13 #define SST_CORE_STRINGIZE_H
24 __attribute__((deprecated(
25 "SST::to_string() is deprecated and will be removed in SST 13. Please use std::to_string() instead"))) inline std::
29 return std::to_string(val);
32 __attribute__((deprecated(
33 "SST::to_string() is deprecated and will be removed in SST 13. Please use std::to_string() instead"))) inline std::
37 return std::to_string(val);
40 __attribute__((deprecated(
41 "SST::to_string() is deprecated and will be removed in SST 13. Please use std::to_string() instead"))) inline std::
43 to_string(int32_t val)
45 return std::to_string(val);
48 __attribute__((deprecated(
49 "SST::to_string() is deprecated and will be removed in SST 13. Please use std::to_string() instead"))) inline std::
51 to_string(int64_t val)
53 return std::to_string(val);
56 __attribute__((deprecated(
57 "SST::to_string() is deprecated and will be removed in SST 13. Please use std::to_string() instead"))) inline std::
59 to_string(uint32_t val)
61 return std::to_string(val);
64 __attribute__((deprecated(
65 "SST::to_string() is deprecated and will be removed in SST 13. Please use std::to_string() instead"))) inline std::
67 to_string(uint64_t val)
69 return std::to_string(val);
73 strcasecmp(
const std::string& s1,
const std::string& s2)
75 return !::strcasecmp(s1.c_str(), s2.c_str());
79 to_lower(std::string& s)
81 for (
size_t i = 0; i < s.size(); i++ ) {
82 s[i] = std::tolower(s[i]);
89 auto start = s.find_first_not_of(
" \t\n\r\v\f");
90 if ( start != 0 ) { s.replace(s.begin(), s.begin() + (start),
""); }
91 auto end = s.find_last_not_of(
" \t\n\r\v\f");
92 if ( end != s.size() - 1 ) { s.replace(s.begin() + end + 1, s.end(),
""); }
97 typedef std::string::const_iterator iter;
98 const std::string delim;
99 char_delimiter(
const std::string& delim =
" \t\v\f\n\r") : delim(delim) {}
109 while ( first != last && delim.find(*first) != std::string::npos )
112 while ( first != last && delim.find(*first) == std::string::npos )
119 typedef std::string::const_iterator iter;
125 const std::string& esc =
"\\",
const std::string& sep =
",",
const std::string& quote =
"\"") :
138 bool inside_quotes =
false;
139 bool in_escape =
false;
140 while ( first != last ) {
147 else if ( s.find(c) != std::string::npos && !inside_quotes ) {
151 else if ( q.find(c) != std::string::npos ) {
152 inside_quotes = !inside_quotes;
154 else if ( e.find(c) != std::string::npos ) {
164 template <
typename TokenizerFunc =
char_delimiter>
168 template <
typename Func>
169 struct token_iter :
public std::iterator<std::input_iterator_tag, std::string>
172 std::string::const_iterator first;
173 std::string::const_iterator last;
177 explicit token_iter(Func& f_, std::string::const_iterator& first_, std::string::const_iterator& last_) :
182 f(first, last, token);
184 token_iter& operator++()
186 f(first, last, token);
189 token_iter operator++(
int)
191 token_iter retval = *
this;
195 bool operator==(token_iter other)
const
197 return (first == other.first) && (last == other.last) && (token == other.token);
199 bool operator!=(token_iter other)
const {
return !(*
this == other); }
200 const std::string& operator*()
const {
return token; }
201 const std::string& operator->()
const {
return token; }
204 typedef token_iter<TokenizerFunc> iter;
207 typedef iter iterator;
208 typedef iter const_iterator;
209 typedef std::string value_type;
211 iter begin() {
return iter(f, first, last); }
212 iter end() {
return iter(f, last, last); }
214 Tokenizer(
const std::string& s,
const TokenizerFunc& f = TokenizerFunc()) : first(s.begin()), last(s.end()), f(f) {}
217 std::string::const_iterator first, last;
237 std::string vformat_string(
size_t max_length,
const char* format, va_list args);
253 std::string vformat_string(
const char* format, va_list args);
270 std::string format_string(
size_t max_length,
const char* format, ...) __attribute__((format(printf, 2, 3)));
286 std::
string format_string(const
char* format, ...) __attribute__((format(printf, 1, 2)));
290 #endif // SST_CORE_STRINGIZE_H
Definition: stringize.h:117
void operator()(iter &first, iter last, std::string &token)
Definition: stringize.h:134
Definition: stringize.h:165
Definition: stringize.h:95
void operator()(iter &first, iter last, std::string &token)
Definition: stringize.h:104