1 #if defined(USE_BOOST_KARMA)
2 #include <boost/spirit/include/karma.hpp>
3 namespace karma = boost::spirit::karma;
7 #if defined(USE_BOOST_KARMA)
8 template<
typename T>
void TablePrinter::OutputDecimalNumber(T input){
9 *out_stream_ << karma::format(
10 karma::maxwidth(column_widths_.at(j_))[
11 karma::right_align(column_widths_.at(j_))[
18 *out_stream_ <<
"|\n";
22 *out_stream_ << separator_;
27 template<
typename T>
void TablePrinter::OutputDecimalNumber(T input){
29 if (input < 10*(column_widths_.at(j_)-1) || input > 10*column_widths_.at(j_)){
30 std::stringstream string_out;
31 string_out << std::setiosflags(std::ios::fixed)
32 << std::setprecision(column_widths_.at(j_))
33 << std::setw(column_widths_.at(j_))
36 std::string string_rep_of_number = string_out.str();
39 std::string string_to_print = string_rep_of_number.substr(0, column_widths_.at(j_));
40 *out_stream_ << string_to_print;
44 int precision = column_widths_.at(j_) - 1;
49 if (input < -1 || input > 1){
50 int num_digits_before_decimal = 1 + (int)log10(std::abs(input));
51 precision -= num_digits_before_decimal;
59 *out_stream_ << std::setiosflags(std::ios::fixed)
60 << std::setprecision(precision)
61 << std::setw(column_widths_.at(j_))
66 *out_stream_ <<
"|\n";
70 *out_stream_ << separator_;
74 #endif //USE_BOOST_KARMA