28#include <boost/lexical_cast.hpp>
40 : m_stream_holder(
std::move(stream_holder)) {}
45 <<
"has started is not allowed";
47 if (indicator.
empty()) {
57 <<
"has started is not allowed";
66 <<
"format is not allowed";
71 while (!message_stream.eof()) {
89 auto& info = *table.getColumnInfo();
91 for (
size_t i = 0; i < info.size(); ++i) {
92 auto& desc = info.getDescription(i);
95 if (!desc.unit.empty()) {
96 out <<
" (" << desc.unit <<
")";
98 if (!desc.description.empty()) {
99 out <<
" - " << desc.description;
109 for (
size_t i = 0; i < info.size(); ++i) {
110 out <<
std::setw(column_lengths[i]) <<
quoted(info.getDescription(i).name);
121 for (
auto row : table) {
122 for (
size_t i = 0; i < row.size(); ++i) {
TableWriter implementation for writing ASCII tables to streams.
std::unique_ptr< InstOrRefHolder< std::ostream > > m_stream_holder
void append(const Table &table) override
void init(const Table &table) override
AsciiWriter & showColumnInfo(bool show)
Sets if the column information will be written to the stream.
void addComment(const std::string &message) override
Adds a comment to the stream.
AsciiWriter(std::ostream &stream)
Constructs an AsciiWriter which writes to the given stream.
AsciiWriter & setCommentIndicator(const std::string &indicator)
Set the comment indicator.
std::vector< size_t > calculateColumnLengths(const Table &table)
Calculates the sizes in characters each column of the table needs.
std::string quoted(const std::string &str)
std::string typeToKeyword(std::type_index type)
Converts a type to its string representation.