18 #include <QtCore/QString>
19 #include <boost/spirit/include/qi.hpp>
20 #include <boost/spirit/include/karma.hpp>
21 #include <boost/type_traits.hpp>
46 if (!boost::spirit::qi::phrase_parse(it, this_s.end(), boost::spirit::qi::int_, boost::spirit::ascii::space, ret))
51 if (it != this_s.end())
53 throw Exception::ConversionError(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
String(
"Prefix of string '") + this_s +
"' successfully converted to an int32 value. Additional characters found at position " + (
int)(distance(this_s.begin(), it) + 1));
65 if (!boost::spirit::qi::phrase_parse(it, this_s.end(), boost::spirit::qi::long_long, boost::spirit::ascii::space, ret))
70 if (it != this_s.end())
73 String(
"Prefix of string '") + this_s +
"' successfully converted to an integer value. Additional characters found at position " +
74 (
int)(distance(this_s.begin(), it) + 1));
86 if (!boost::spirit::qi::phrase_parse(it, this_s.end(), parse_float_, boost::spirit::ascii::space, ret))
91 if (it != this_s.end())
93 throw Exception::ConversionError(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
String(
"Prefix of string '") + this_s +
"' successfully converted to a float value. Additional characters found at position " + (
int)(distance(this_s.begin(), it) + 1));
111 if (!boost::spirit::qi::phrase_parse(it, s.end(), parse_double_, boost::spirit::ascii::space, ret))
118 throw Exception::ConversionError(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
String(
"Prefix of string '") + s +
"' successfully converted to a double value. Additional characters found at position " + (
int)(distance(s.begin(), it) + 1));
127 template <
typename IteratorT>
128 static bool extractDouble(IteratorT& begin,
const IteratorT& end,
double& target)
134 return boost::spirit::qi::parse(begin, end, parse_double_, target);
146 template <
typename T>
149 template <
typename Iterator,
typename Attribute>
156 if (*first !=
'n' && *first !=
'N')
160 if (boost::spirit::qi::detail::string_parse(
"nan",
"NAN", first, last, boost::spirit::qi::unused))
162 if (first != last && *first ==
'(')
167 while (++i != last && *i !=
')')
174 attr_ = std::numeric_limits<T>::quiet_NaN();
183 static boost::spirit::qi::real_parser<double, real_policies_NANfixed_<double> >
parse_double_;
184 static boost::spirit::qi::real_parser<float, real_policies_NANfixed_<float> >
parse_float_;
188 namespace StringUtils
198 return QString(this_s.c_str());
221 template <
typename IteratorT>
222 static bool extractDouble(IteratorT& begin,
const IteratorT& end,
double& target)
Invalid conversion exception.
Definition: Exception.h:330
Definition: StringUtils.h:32
static double toDouble(const String &s)
convert String (leading and trailing whitespace allowed) to double
Definition: StringUtils.h:105
static bool extractDouble(IteratorT &begin, const IteratorT &end, double &target)
Definition: StringUtils.h:128
static Int64 toInt64(const String &this_s)
Definition: StringUtils.h:58
static float toFloat(const String &this_s)
Definition: StringUtils.h:79
static Int toInt32(const String &this_s)
Functions.
Definition: StringUtils.h:39
static boost::spirit::qi::real_parser< double, real_policies_NANfixed_< double > > parse_double_
Definition: StringUtils.h:183
static boost::spirit::qi::real_parser< float, real_policies_NANfixed_< float > > parse_float_
Definition: StringUtils.h:184
A more convenient string class.
Definition: String.h:34
const_iterator ConstIterator
Const Iterator.
Definition: String.h:46
int32_t Int32
Signed integer type (32bit)
Definition: Types.h:26
int64_t Int64
Signed integer type (64bit)
Definition: Types.h:40
int Int
Signed integer type.
Definition: Types.h:72
unsigned int UInt
Unsigned integer type.
Definition: Types.h:64
static bool extractDouble(IteratorT &begin, const IteratorT &end, double &target)
Definition: StringUtils.h:222
static String number(double d, UInt n)
Definition: StringUtils.h:191
static Int32 toInt32(const String &this_s)
Definition: StringUtils.h:201
static Int64 toInt64(const String &this_s)
Definition: StringUtils.h:206
static double toDouble(const String &this_s)
Definition: StringUtils.h:216
static float toFloat(const String &this_s)
Definition: StringUtils.h:211
static QString toQString(const String &this_s)
Definition: StringUtils.h:196
Main OpenMS namespace.
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
Definition: StringUtils.h:148
static bool parse_nan(Iterator &first, Iterator const &last, Attribute &attr_)
Definition: StringUtils.h:151