17 #include <boost/spirit/include/qi.hpp>
18 #include <boost/spirit/include/karma.hpp>
19 #include <boost/type_traits.hpp>
21 #include <boost/spirit/home/karma/numeric/detail/real_utils.hpp>
31 namespace StringConversions
69 return writtenDigits<T>();
75 if (boost::spirit::traits::test_zero(n))
return base_policy_type::fmtflags::fixed;
77 T abs_n = boost::spirit::traits::get_absolute_value(n);
80 return (abs_n >= 1e4 || abs_n < 1e-2) ? base_policy_type::fmtflags::scientific : base_policy_type::fmtflags::fixed;
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(sink,
false, boost::spirit::traits::test_negative(n), force_sign)
89 && boost::spirit::karma::string_inserter<CharEncoding, Tag>::call(sink,
"NaN");
102 template<
typename CharEncoding,
typename Tag,
typename OutputIterator>
103 static bool nan(OutputIterator& sink, T n,
bool force_sign)
105 return boost::spirit::karma::sign_inserter::call(sink,
false, boost::spirit::traits::test_negative(n), force_sign)
106 && boost::spirit::karma::string_inserter<CharEncoding, Tag>::call(sink,
"NaN");
132 template <
typename T>
135 std::back_insert_iterator<std::string> sink(target);
136 boost::spirit::karma::generate(sink, i);
140 template <
typename T>
156 std::back_insert_iterator<std::string> sink(target);
172 std::back_insert_iterator<std::string> sink(target);
187 std::back_insert_iterator<std::string> sink(target);
203 std::back_insert_iterator<std::string> sink(target);
219 std::back_insert_iterator<std::string> sink(target);
234 std::back_insert_iterator<std::string> sink(target);
248 target += d.
toString(full_precision);
259 return std::string(1,
c);
269 return std::string(s);
Class to hold strings, numeric values, lists of strings and lists of numeric values.
Definition: DataValue.h:33
String toString(bool full_precision=true) const
Conversion to String full_precision Controls number of fractional digits for all double types or list...
Definition: StringConversions.h:39
static unsigned precision(T)
Definition: StringConversions.h:43
static unsigned floatfield(T n)
Definition: StringConversions.h:73
static bool nan(OutputIterator &sink, T n, bool force_sign)
Definition: StringConversions.h:86
boost::spirit::karma::real_policies< T > base_policy_type
Definition: StringConversions.h:40
Definition: StringConversions.h:96
static bool nan(OutputIterator &sink, T n, bool force_sign)
Definition: StringConversions.h:103
boost::spirit::karma::real_policies< T > base_policy_type
Definition: StringConversions.h:97
A more convenient string class.
Definition: String.h:34
const double c
Definition: Constants.h:188
const BK_PrecPolicyFloatShort_type BK_PrecPolicyFloatShort
Definition: StringConversions.h:118
boost::spirit::karma::real_generator< double, BK_PrecPolicyFull< double > > BK_PrecPolicyDoubleFull_type
Definition: StringConversions.h:112
const BK_PrecPolicyDoubleFull_type BK_PrecPolicyDoubleFull
Definition: StringConversions.h:113
const BK_PrecPolicyDoubleShort_type BK_PrecPolicyDoubleShort
Definition: StringConversions.h:120
const BK_PrecPolicyLongDoubleFull_type BK_PrecPolicyLongDoubleFull
Definition: StringConversions.h:115
boost::spirit::karma::real_generator< double, BK_PrecPolicyShort< double > > BK_PrecPolicyDoubleShort_type
Definition: StringConversions.h:119
boost::spirit::karma::real_generator< long double, BK_PrecPolicyFull< long double > > BK_PrecPolicyLongDoubleFull_type
Definition: StringConversions.h:114
boost::spirit::karma::real_generator< float, BK_PrecPolicyShort< float > > BK_PrecPolicyFloatShort_type
Definition: StringConversions.h:117
const BK_PrecPolicyFloatFull_type BK_PrecPolicyFloatFull
Definition: StringConversions.h:111
boost::spirit::karma::real_generator< float, BK_PrecPolicyFull< float > > BK_PrecPolicyFloatFull_type
Definition: StringConversions.h:110
const BK_PrecPolicyLongDoubleShort_type BK_PrecPolicyLongDoubleShort
Definition: StringConversions.h:122
boost::spirit::karma::real_generator< long double, BK_PrecPolicyShort< long double > > BK_PrecPolicyLongDoubleShort_type
Definition: StringConversions.h:121
String toStringLowP(float f)
low precision (3 fractional digits) conversion to string (Karma default)
Definition: StringConversions.h:160
void appendLowP(float f, String &target)
Definition: StringConversions.h:154
String toString(const T &i)
fallback template for general purpose using Boost::Karma; more specializations below
Definition: StringConversions.h:141
void append(const T &i, String &target)
Definition: StringConversions.h:133
Main OpenMS namespace.
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19