15#include <OpenMS/OpenMSConfig.h>
17#include <boost/spirit/include/qi.hpp>
18#include <boost/spirit/include/karma.hpp>
19#include <boost/spirit/home/karma/numeric/detail/real_utils.hpp>
20#include <boost/type_traits.hpp>
21#include <boost/functional/hash.hpp>
49 namespace StringConversions
59 static unsigned precision(T ) {
return writtenDigits<T>(); }
63 if (boost::spirit::traits::test_zero(n))
return base_policy_type::fmtflags::fixed;
64 T abs_n = boost::spirit::traits::get_absolute_value(n);
66 return (abs_n >= 1e4 || abs_n < 1e-2) ? base_policy_type::fmtflags::scientific
67 : base_policy_type::fmtflags::fixed;
70 template<
typename CharEncoding,
typename Tag,
typename OutputIterator>
71 static bool nan(OutputIterator& sink, T n,
bool force_sign)
73 return boost::spirit::karma::sign_inserter::call(
74 sink,
false, boost::spirit::traits::test_negative(n), force_sign)
75 && boost::spirit::karma::string_inserter<CharEncoding, Tag>::call(sink,
"NaN");
85 template<
typename CharEncoding,
typename Tag,
typename OutputIterator>
86 static bool nan(OutputIterator& sink, T n,
bool force_sign)
88 return boost::spirit::karma::sign_inserter::call(
89 sink,
false, boost::spirit::traits::test_negative(n), force_sign)
90 && boost::spirit::karma::string_inserter<CharEncoding, Tag>::call(sink,
"NaN");
94 using FloatFullGen = boost::spirit::karma::real_generator<float, BK_PrecPolicyFull<float>>;
95 using DoubleFullGen = boost::spirit::karma::real_generator<double, BK_PrecPolicyFull<double>>;
96 using LDFullGen = boost::spirit::karma::real_generator<long double, BK_PrecPolicyFull<long double>>;
98 using FloatShortGen = boost::spirit::karma::real_generator<float, BK_PrecPolicyShort<float>>;
99 using DoubleShortGen = boost::spirit::karma::real_generator<double, BK_PrecPolicyShort<double>>;
100 using LDShortGen = boost::spirit::karma::real_generator<long double, BK_PrecPolicyShort<long double>>;
129 template <
typename IteratorT>
130 static bool extractDouble(IteratorT& begin,
const IteratorT& end,
double& target)
132 return boost::spirit::qi::parse(begin, end, parse_double_, target);
137 template <
typename IteratorT>
138 static bool extractInt(IteratorT& begin,
const IteratorT& end,
int& target)
140 return boost::spirit::qi::parse(begin, end, parse_int_, target);
144 template <
typename T>
147 template <
typename Iterator,
typename Attribute>
150 if (first == last)
return false;
151 if (*first !=
'n' && *first !=
'N')
return false;
152 if (boost::spirit::qi::detail::string_parse(
"nan",
"NAN", first, last, boost::spirit::qi::unused))
154 if (first != last && *first ==
'(')
157 while (++i != last && *i !=
')') ;
158 if (i == last)
return false;
161 attr_ = std::numeric_limits<T>::quiet_NaN();
168 static boost::spirit::qi::real_parser<double, real_policies_NANfixed_<double>>
parse_double_;
169 static boost::spirit::qi::real_parser<float, real_policies_NANfixed_<float>>
parse_float_;
177 namespace StringUtils
185 template <
typename T>
188 std::back_insert_iterator<std::string> sink(target);
189 boost::spirit::karma::generate(sink, i);
194 { appendToStr<int>(i, target); }
196 { appendToStr<unsigned int>(i, target); }
198 { appendToStr<short int>(i, target); }
199 inline void appendToStr(
short unsigned int i, std::string& target)
200 { appendToStr<short unsigned int>(i, target); }
202 { appendToStr<long int>(i, target); }
204 { appendToStr<long unsigned int>(i, target); }
205 inline void appendToStr(
long long unsigned int i, std::string& target)
206 { appendToStr<long long unsigned int>(i, target); }
207 inline void appendToStr(
long long signed int i, std::string& target)
208 { appendToStr<long long signed int>(i, target); }
213 std::back_insert_iterator<std::string> sink(target);
219 std::back_insert_iterator<std::string> sink(target);
226 std::back_insert_iterator<std::string> sink(target);
232 std::back_insert_iterator<std::string> sink(target);
239 std::back_insert_iterator<std::string> sink(target);
245 std::back_insert_iterator<std::string> sink(target);
259 inline std::string
toStr(
unsigned int i)
261 inline std::string
toStr(
short int i)
263 inline std::string
toStr(
short unsigned int i)
265 inline std::string
toStr(
long int i)
267 inline std::string
toStr(
long unsigned int i)
269 inline std::string
toStr(
long long unsigned int i)
271 inline std::string
toStr(
long long signed int i)
275 inline std::string
toStr(
float f,
bool full_precision =
true)
282 inline std::string
toStr(
double d,
bool full_precision =
true)
289 inline std::string
toStr(
long double ld,
bool full_precision =
true)
297 {
return std::string(1, c); }
299 inline std::string
toStr(
const std::string& s)
302 inline std::string
toStr(
const char* s)
303 {
return std::string(s); }
341 template <
typename IteratorT>
342 inline bool extractDouble(IteratorT& begin,
const IteratorT& end,
double& target)
345 template <
typename IteratorT>
346 inline bool extractInt(IteratorT& begin,
const IteratorT& end,
int& target)
360 auto pos =
skipWhitespace(data.data(), data.data() + data.size());
361 return static_cast<int>(pos - data.data());
371 return static_cast<int>(pos - data.data());
383 std::snprintf(buf,
sizeof(buf),
"%.*f",
static_cast<int>(n), d);
384 return std::string(buf);
391 Int sign = (d < 0) ? 1 : 0;
393 if (d < std::pow(10.0,
Int(n - sign - 2)))
396 if (sign == 1) s <<
'-';
402 while (d > std::pow(10.0,
Int(n - sign - 4)))
407 d =
static_cast<int>(d) / 10.0;
409 if (sign == 1) s <<
'-';
411 if (exp < 10) s <<
'0';
414 return s.str().substr(0, n);
420 srand(time(
nullptr));
421 std::string tmp(length,
'.');
422 for (
Size i = 0; i < length; ++i)
424 size_t r =
static_cast<size_t>(
425 std::floor((
static_cast<double>(rand()) / (
double(RAND_MAX) + 1)) * 62.0));
426 if (r < 10) tmp[i] =
static_cast<char>(r + 48);
427 else if (r < 36) tmp[i] =
static_cast<char>(r + 55);
428 else tmp[i] =
static_cast<char>(r + 61);
440 if (
prefix.size() > s.size())
return false;
441 if (
prefix.empty())
return true;
445 {
return !s.empty() && s.front() == c; }
447 inline bool hasSuffix(
const std::string& s,
const std::string& sfx)
449 if (sfx.size() > s.size())
return false;
450 if (sfx.empty())
return true;
451 return s.compare(s.size() - sfx.size(), sfx.size(), sfx) == 0;
454 {
return !s.empty() && s.back() == c; }
458 return s.find(sub) != std::string::npos;
461 {
return s.find(c) != std::string::npos; }
463 inline bool has(
const std::string& s,
Byte byte)
465 return s.find(
static_cast<char>(
byte)) != std::string::npos;
467 inline bool has(
const std::string& s,
char c)
468 {
return s.find(c) != std::string::npos; }
475 inline std::string
prefix(
const std::string& s,
size_t length)
477 if (length > s.size())
479 return s.substr(0, length);
482 inline std::string
suffix(
const std::string& s,
size_t length)
484 if (length > s.size())
486 return s.substr(s.size() - length, length);
489 inline std::string
prefix(
const std::string& s,
Int length)
493 return prefix(s,
static_cast<size_t>(length));
496 inline std::string
suffix(
const std::string& s,
Int length)
500 return suffix(s,
static_cast<size_t>(length));
503 inline std::string
prefix(
const std::string& s,
char delim)
505 size_t pos = s.find(delim);
506 if (pos == std::string::npos)
508 return s.substr(0, pos);
511 inline std::string
suffix(
const std::string& s,
char delim)
513 size_t pos = s.rfind(delim);
514 if (pos == std::string::npos)
516 return s.substr(pos + 1);
520 inline std::string
substr(
const std::string& s,
size_t pos = 0,
size_t n = std::string::npos)
522 size_t begin = std::min(pos, s.size());
523 return s.substr(begin, n);
526 inline std::string
substr(std::string_view s,
size_t pos = 0,
size_t n = std::string::npos)
528 size_t begin = std::min(pos, s.size());
529 return std::string(s.substr(begin, n));
533 inline std::string
toStr(std::string_view sv) {
return std::string(sv); }
538 inline bool hasSuffix(std::string_view s,
const std::string& sfx)
539 {
return s.size() >= sfx.size() && s.substr(s.size() - sfx.size()) == sfx; }
541 {
return s.find(sub) != std::string_view::npos; }
544 inline std::string
chop(
const std::string& s,
Size n)
546 size_t end = (n < s.size()) ? s.size() - n : 0;
547 return std::string(s.begin(), s.begin() + end);
555 inline std::string&
trim(std::string& s)
557 auto begin = s.begin();
558 while (begin != s.end() && (*begin ==
' ' || *begin ==
'\t' || *begin ==
'\n' || *begin ==
'\r'))
560 if (begin == s.end()) { s.clear();
return s; }
561 auto end = s.end() - 1;
562 while (end != begin && (*end ==
' ' || *end ==
'\n' || *end ==
'\t' || *end ==
'\r'))
565 if (begin != s.begin() || end != s.end())
566 s.assign(begin, end);
571 inline std::string
trimmed(std::string s) {
return std::move(
trim(s)); }
575 std::transform(s.begin(), s.end(), s.begin(), [](
unsigned char c){ return std::toupper(c); });
581 std::transform(s.begin(), s.end(), s.begin(), [](
unsigned char c){ return std::tolower(c); });
591 if (!s.empty()) s[0] =
static_cast<char>(std::toupper(
static_cast<unsigned char>(s[0])));
597 std::reverse(s.begin(), s.end());
604 result.reserve(s.size());
605 bool last_ws =
false;
608 if (c ==
' ' || c ==
'\n' || c ==
'\t' || c ==
'\r')
610 if (!last_ws) result +=
' ';
626 s.insert(s.begin(), size - s.size(), c);
633 s.append(size - s.size(), c);
637 inline std::string&
substitute(std::string& s,
char from,
char to)
639 std::replace(s.begin(), s.end(), from, to);
644 inline std::string&
substitute(std::string& s,
const std::string& from,
const std::string& to)
646 if (from.empty())
return s;
648 result.reserve(s.size());
651 while ((pos = s.find(from, start)) != std::string::npos)
653 result.append(s, start, pos - start);
655 start = pos + from.size();
657 result.append(s, start, std::string::npos);
663 inline std::string
substituted(std::string s,
const std::string& from,
const std::string& to) {
return std::move(
substitute(s, from, to)); }
665 inline std::string&
remove(std::string& s,
char what)
667 s.erase(std::remove(s.begin(), s.end(), what), s.end());
677 if (s.empty() || s.back() != end) s.push_back(end);
687 auto it = s.cbegin() + start;
688 auto dest = s.begin() + start;
689 auto it_end = s.cend();
690 bool has_spaces =
false;
694 if (c ==
' ' || c ==
'\t' || c ==
'\n' || c ==
'\r')
700 if (has_spaces) *dest = *it;
704 if (has_spaces) s.resize(
static_cast<size_t>(dest - s.begin()));
710 return s.size() >= 2 && s.front() == q && s.back() == q;
717 substitute(s, std::string(
"\\"), std::string(
"\\\\"));
718 substitute(s, std::string(1, q), std::string(
"\\") + q);
722 substitute(s, std::string(1, q), std::string(2, q));
724 s.insert(s.begin(), q);
733 "'" + s +
"' does not have the expected format of a quoted string");
738 substitute(s, std::string(
"\\") + q, std::string(1, q));
739 substitute(s, std::string(
"\\\\"), std::string(
"\\"));
743 substitute(s, std::string(2, q), std::string(1, q));
756 inline bool split(
const std::string& s,
char splitter,
757 std::vector<std::string>& substrings,
758 bool quote_protect =
false)
761 if (s.empty())
return false;
763 size_t nsplits =
static_cast<size_t>(std::count(s.begin(), s.end(), splitter));
765 if (!quote_protect && nsplits == 0)
767 substrings.push_back(s);
771 substrings.reserve(nsplits + 1);
776 auto begin = s.cbegin();
777 auto end = s.cbegin();
778 for (; end != s.cend(); ++end)
780 if (*end ==
'"') ++quote_count;
781 if ((quote_count % 2 == 0) && (*end == splitter))
783 std::string block(begin, end);
785 bool has_start = block.size() >= 1 && block.front() ==
'"';
786 bool has_end = block.size() >= 1 && block.back() ==
'"';
787 if (block.size() >= 2 && (has_start ^ has_end))
789 "Could not dequote string '" + block +
"' due to wrongly placed '\"'.");
790 if (block.size() >= 2 && has_start && has_end)
791 block = block.substr(1, block.size() - 2);
792 substrings.push_back(std::move(block));
796 if (substrings.empty()) { substrings.push_back(s);
return false; }
797 std::string block(begin, end);
799 bool has_start = block.size() >= 1 && block.front() ==
'"';
800 bool has_end = block.size() >= 1 && block.back() ==
'"';
801 if (block.size() >= 2 && (has_start ^ has_end))
803 "Could not dequote string '" + block +
"' due to wrongly placed '\"'.");
804 if (block.size() >= 2 && has_start && has_end)
805 block = block.substr(1, block.size() - 2);
806 substrings.push_back(std::move(block));
810 auto begin = s.cbegin();
811 for (
auto it = s.cbegin(); it != s.cend(); ++it)
815 substrings.emplace_back(begin, it);
819 substrings.emplace_back(begin, s.cend());
826 inline bool split(
const std::string& s,
const std::string& splitter,
827 std::vector<std::string>& substrings)
830 if (s.empty())
return false;
831 if (splitter.empty())
833 substrings.resize(s.size());
834 for (
size_t i = 0; i < s.size(); ++i) substrings[i] = std::string(1, s[i]);
837 size_t len = splitter.size();
839 size_t pos = s.find(splitter);
840 while (pos != std::string::npos)
842 substrings.push_back(s.substr(start, pos - start));
844 pos = s.find(splitter, start);
846 substrings.push_back(s.substr(start));
847 return substrings.size() > 1;
852 inline bool split_quoted(
const std::string& s,
const std::string& splitter,
853 std::vector<std::string>& substrings,
857 if (s.empty() || splitter.empty())
return false;
859 bool in_quote =
false;
860 char targets[2] = {q, splitter[0]};
861 std::string rest = splitter.substr(1);
864 for (
size_t i = 0; i < s.size(); ++i)
868 bool embedded =
false;
871 for (; i < s.size(); ++i)
873 if (s[i] ==
'\\') embedded = !embedded;
874 else if (s[i] == q && !embedded)
break;
875 else embedded =
false;
880 for (; i < s.size(); ++i)
885 if (i + 1 < s.size() && s[i + 1] == q) embedded = !embedded;
886 else if (!embedded)
break;
887 else embedded =
false;
895 i = s.find_first_of(targets, i, 2);
896 if (i == std::string::npos)
break;
897 if (s[i] == q) { in_quote =
true; }
898 else if (s.compare(i + 1, rest.size(), rest) == 0)
900 substrings.push_back(s.substr(start, i - start));
901 start = i + splitter.size();
908 "unbalanced quotation marks in string '" + s +
"'");
909 substrings.push_back(s.substr(start));
910 return substrings.size() > 1;
914 template <
class StringIterator>
916 StringIterator first, StringIterator last,
917 const std::string& glue =
"")
919 if (first == last) { target.clear();
return; }
921 for (
auto it = ++first; it != last; ++it)
929 template <
class StringIterator>
930 inline std::string
concatenate(StringIterator first, StringIterator last,
931 const std::string& glue =
"")
949 template <std::ranges::range Container>
950 inline std::string
concatenate(
const Container& container,
const std::string& glue =
"")
952 return concatenate(container.begin(), container.end(), glue);
962 namespace StringConversions
964 template <
typename T>
965 inline void append(
const T& i, std::string& target)
968 inline void append(
float f, std::string& target)
970 inline void append(
double d, std::string& target)
972 inline void append(
long double ld, std::string& target)
983 template <
typename T>
986 inline std::string
toString(
float f,
bool fp =
true)
988 inline std::string
toString(
double d,
bool fp =
true)
990 inline std::string
toString(
long double ld,
bool fp =
true)
1020inline std::string&
operator+=(std::string& s,
short unsigned int i)
1024inline std::string&
operator+=(std::string& s,
long unsigned int i)
1026inline std::string&
operator+=(std::string& s,
long long unsigned int i)
1028inline std::string&
operator+=(std::string& s,
long long signed int i)
1039{
return std::move(s += i); }
1041{
return std::move(s += i); }
1043{
return std::move(s += i); }
1044inline std::string
operator+(std::string s,
short unsigned int i)
1045{
return std::move(s += i); }
1047{
return std::move(s += i); }
1048inline std::string
operator+(std::string s,
long unsigned int i)
1049{
return std::move(s += i); }
1050inline std::string
operator+(std::string s,
long long unsigned int i)
1051{
return std::move(s += i); }
1052inline std::string
operator+(std::string s,
long long signed int i)
1053{
return std::move(s += i); }
1055{
return std::move(s += f); }
1057{
return std::move(s += d); }
1059{
return std::move(s += ld); }
std::string & operator+=(std::string &s, int i)
Definition StringUtils.h:1014
std::string operator+(std::string s, int i)
Definition StringUtils.h:1038
Class to hold strings, numeric values, lists of strings and lists of numeric values.
Definition DataValue.h:32
Invalid conversion exception.
Definition Exception.h:331
Element could not be found exception.
Definition Exception.h:654
Int overflow exception.
Definition Exception.h:211
Int underflow exception.
Definition Exception.h:175
Class to hold strings, numeric values, vectors of strings and vectors of numeric values using the stl...
Definition ParamValue.h:31
Karma full-precision float/double/long double policy with NaN→"NaN".
Definition StringUtils.h:56
static unsigned precision(T)
Definition StringUtils.h:59
static unsigned floatfield(T n)
Definition StringUtils.h:61
static bool nan(OutputIterator &sink, T n, bool force_sign)
Definition StringUtils.h:71
boost::spirit::karma::real_policies< T > base_policy_type
Definition StringUtils.h:57
Karma low-precision (≤3 fractional digits) policy with NaN→"NaN".
Definition StringUtils.h:82
static bool nan(OutputIterator &sink, T n, bool force_sign)
Definition StringUtils.h:86
boost::spirit::karma::real_policies< T > base_policy_type
Definition StringUtils.h:83
Definition StringUtils.h:116
static boost::spirit::qi::int_parser parse_int_
Definition StringUtils.h:170
static double toDouble(const std::string &s)
Parse double from string (leading/trailing whitespace allowed)
static bool extractDouble(IteratorT &begin, const IteratorT &end, double &target)
Definition StringUtils.h:130
static Int64 toInt64(const std::string &s)
Parse int64 from string (leading/trailing whitespace allowed)
static boost::spirit::qi::real_parser< double, real_policies_NANfixed_< double > > parse_double_
Definition StringUtils.h:168
static boost::spirit::qi::real_parser< float, real_policies_NANfixed_< float > > parse_float_
Definition StringUtils.h:169
static Int32 toInt32(const std::string &s)
Parse int32 from string (leading/trailing whitespace allowed)
static float toFloat(const std::string &s)
Parse float from string (leading/trailing whitespace allowed)
static bool extractInt(IteratorT &begin, const IteratorT &end, int &target)
Definition StringUtils.h:138
int32_t Int32
Signed integer type (32bit)
Definition Types.h:26
int64_t Int64
Signed integer type (64bit)
Definition Types.h:40
uint8_t Byte
Byte type.
Definition Types.h:81
int Int
Signed integer type.
Definition Types.h:72
unsigned int UInt
Unsigned integer type.
Definition Types.h:64
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition Types.h:97
boost::spirit::karma::real_generator< float, BK_PrecPolicyFull< float > > FloatFullGen
Definition StringUtils.h:94
const DoubleShortGen doubleShort
Definition StringUtils.h:106
const FloatFullGen floatFull
Definition StringUtils.h:102
const FloatShortGen floatShort
Definition StringUtils.h:105
boost::spirit::karma::real_generator< long double, BK_PrecPolicyShort< long double > > LDShortGen
Definition StringUtils.h:100
boost::spirit::karma::real_generator< float, BK_PrecPolicyShort< float > > FloatShortGen
Definition StringUtils.h:98
const LDFullGen ldFull
Definition StringUtils.h:104
const DoubleFullGen doubleFull
Definition StringUtils.h:103
boost::spirit::karma::real_generator< long double, BK_PrecPolicyFull< long double > > LDFullGen
Definition StringUtils.h:96
boost::spirit::karma::real_generator< double, BK_PrecPolicyFull< double > > DoubleFullGen
Definition StringUtils.h:95
const LDShortGen ldShort
Definition StringUtils.h:107
boost::spirit::karma::real_generator< double, BK_PrecPolicyShort< double > > DoubleShortGen
Definition StringUtils.h:99
void append(const T &i, std::string &target)
Definition StringUtils.h:965
void appendLowP(float f, std::string &target)
Definition StringUtils.h:974
std::string toStringLowP(float f)
Definition StringUtils.h:997
std::string toString()
Definition StringUtils.h:994
float toFloat(const std::string &s)
Definition StringUtils.h:338
std::string & fillRight(std::string &s, char c, UInt size)
Definition StringUtils.h:630
bool extractDouble(IteratorT &begin, const IteratorT &end, double &target)
Definition StringUtils.h:342
bool extractInt(IteratorT &begin, const IteratorT &end, int &target)
Definition StringUtils.h:346
Int64 toInt64(const std::string &s)
Definition StringUtils.h:337
std::string substituted(std::string s, char from, char to)
substitute on a copy (for chained/rvalue expressions)
Definition StringUtils.h:662
bool hasPrefix(const std::string &s, const std::string &prefix)
Definition StringUtils.h:438
std::string & toUpper(std::string &s)
Definition StringUtils.h:573
std::string chop(const std::string &s, Size n)
Remove n characters from the end; returns empty string if n >= size.
Definition StringUtils.h:544
void appendToStr(const T &i, std::string &target)
Append i to target (Boost.Karma, fast)
Definition StringUtils.h:186
std::string & trim(std::string &s)
Definition StringUtils.h:555
std::string & unquote(std::string &s, char q='"', QuotingMethod method = QuotingMethod::ESCAPE)
Definition StringUtils.h:729
bool hasSuffix(const std::string &s, const std::string &sfx)
Definition StringUtils.h:447
std::string & fillLeft(std::string &s, char c, UInt size)
Definition StringUtils.h:623
std::string & firstToUpper(std::string &s)
Definition StringUtils.h:589
void appendToStrLowP(float f, std::string &target)
Append float (low precision, 3 fractional digits) to target.
Definition StringUtils.h:217
std::string suffix(const std::string &s, size_t length)
Definition StringUtils.h:482
std::string substr(const std::string &s, size_t pos=0, size_t n=std::string::npos)
Wrapper around std::string::substr; clamps pos to [0, size].
Definition StringUtils.h:520
std::string random(UInt length)
Returns a random string of length characters from [0-9a-zA-Z].
Definition StringUtils.h:418
bool isQuoted(const std::string &s, char q)
Definition StringUtils.h:708
std::string toLowered(std::string s)
Returns a lower-cased copy of s (for use in chained/rvalue expressions)
Definition StringUtils.h:587
std::string & removeWhitespaces(std::string &s)
Definition StringUtils.h:683
std::string numberLength(double d, UInt n)
Returns a string for d with at most n characters total (scientific notation if needed)
Definition StringUtils.h:388
std::string number(double d, UInt n)
Returns a string with exactly n decimal places for d.
Definition StringUtils.h:380
std::string prefix(const std::string &s, size_t length)
Definition StringUtils.h:475
const char * skipNonWhitespace(const char *p, const char *p_end)
Returns pointer to first whitespace character in [p, p_end), or p_end.
bool hasSubstring(const std::string &s, const std::string &sub)
Definition StringUtils.h:456
const char * skipWhitespace(const char *p, const char *p_end)
Returns pointer to first non-whitespace character in [p, p_end), or p_end.
std::string trimmed(std::string s)
Returns a trimmed copy of s (for use in chained/rvalue expressions)
Definition StringUtils.h:571
std::string toStr(int i)
Definition StringUtils.h:257
bool split(const std::string &s, char splitter, std::vector< std::string > &substrings, bool quote_protect=false)
Definition StringUtils.h:756
std::string & ensureLastChar(std::string &s, char end)
Definition StringUtils.h:675
void concatenate(std::string &target, StringIterator first, StringIterator last, const std::string &glue="")
Join elements [first, last) with glue between them, storing result in target.
Definition StringUtils.h:915
std::string & simplify(std::string &s)
Definition StringUtils.h:601
std::string & reverse(std::string &s)
Definition StringUtils.h:595
bool has(const std::string &s, Byte byte)
Definition StringUtils.h:463
double toDouble(const std::string &s)
Definition StringUtils.h:339
std::string & toLower(std::string &s)
Definition StringUtils.h:579
std::string & remove(std::string &s, char what)
Definition StringUtils.h:665
std::string toUppered(std::string s)
Returns an upper-cased copy of s (for use in chained/rvalue expressions)
Definition StringUtils.h:585
Int32 toInt32(const std::string &s)
Definition StringUtils.h:336
bool split_quoted(const std::string &s, const std::string &splitter, std::vector< std::string > &substrings, char q='"', QuotingMethod method = QuotingMethod::ESCAPE)
Definition StringUtils.h:852
std::string & quote(std::string &s, char q='"', QuotingMethod method = QuotingMethod::ESCAPE)
Definition StringUtils.h:713
std::string & substitute(std::string &s, char from, char to)
Definition StringUtils.h:637
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
QuotingMethod
How to handle embedded quotes when quoting strings.
Definition StringUtils.h:43
constexpr Int writtenDigits(const FloatingPointType &=FloatingPointType())
Number of digits commonly used for writing a floating point type (a.k.a. precision)....
Definition Types.h:264
Definition StringUtils.h:146
static bool parse_nan(Iterator &first, Iterator const &last, Attribute &attr_)
Definition StringUtils.h:148