43 #include <boost/spirit/include/qi.hpp>
44 #include <boost/spirit/include/karma.hpp>
45 #include <boost/type_traits.hpp>
55 namespace StringConversions
90 return writtenDigits<T>();
96 if (boost::spirit::traits::test_zero(n))
97 return base_policy_type::fmtflags::fixed;
99 T abs_n = boost::spirit::traits::get_absolute_value(n);
102 return (abs_n >= 1e4 || abs_n < 1e-2)
103 ? base_policy_type::fmtflags::scientific : base_policy_type::fmtflags::fixed;
117 template <
typename T>
120 std::back_insert_iterator<std::string> sink(target);
121 boost::spirit::karma::generate(sink, i);
125 template <
typename T>
141 std::back_insert_iterator<std::string> sink(target);
142 boost::spirit::karma::generate(sink, f);
157 std::back_insert_iterator<std::string> sink(target);
158 boost::spirit::karma::generate(sink, d);
172 std::back_insert_iterator<std::string> sink(target);
173 boost::spirit::karma::generate(sink, ld);
188 std::back_insert_iterator<std::string> sink(target);
204 std::back_insert_iterator<std::string> sink(target);
219 std::back_insert_iterator<std::string> sink(target);
233 target += d.
toString(full_precision);
244 return std::string(1,
c);
254 return std::string(s);
267 while (count < length)
Class to hold strings, numeric values, lists of strings and lists of numeric values.
Definition: DataValue.h:59
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:61
static unsigned precision(T)
Definition: StringConversions.h:64
static unsigned floatfield(T n)
Definition: StringConversions.h:94
boost::spirit::karma::real_policies< T > base_policy_type
Definition: StringConversions.h:62
A more convenient string class.
Definition: String.h:60
const double c
Definition: Constants.h:209
boost::spirit::karma::real_generator< long double, BK_PrecPolicy< long double > > BK_PrecPolicyLongDouble_type
Definition: StringConversions.h:110
boost::spirit::karma::real_generator< float, BK_PrecPolicy< float > > BK_PrecPolicyFloat_type
Definition: StringConversions.h:106
const BK_PrecPolicyLongDouble_type BK_PrecPolicyLongDouble
Definition: StringConversions.h:111
String toStringLowP(float f)
low precision (3 fractional digits) conversion to string (Karma default)
Definition: StringConversions.h:145
void appendLowP(float f, String &target)
Definition: StringConversions.h:139
const BK_PrecPolicyDouble_type BK_PrecPolicyDouble
Definition: StringConversions.h:109
String toString(const T &i)
fallback template for general purpose using Boost::Karma; more specializations below
Definition: StringConversions.h:126
void append(const T &i, String &target)
Definition: StringConversions.h:118
const BK_PrecPolicyFloat_type BK_PrecPolicyFloat
Definition: StringConversions.h:107
boost::spirit::karma::real_generator< double, BK_PrecPolicy< double > > BK_PrecPolicyDouble_type
Definition: StringConversions.h:108
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47