diag::Writer & PrintTable::verbose_print( diag::Writer & dout) const { calculate_column_widths(); dout << m_title << diag::dendl; for (Table::const_iterator row_it = m_header.begin(); row_it != m_header.end(); ++row_it) { dout << ""; printRow(dout.getStream(), *row_it); dout << diag::dendl; } if (m_header.size() > 0) { dout << ""; printHeaderBar(dout.getStream()); dout << diag::dendl; } for (Table::const_iterator row_it = m_table.begin(); row_it != m_table.end(); ++row_it) { dout << ""; printRow(dout.getStream(), *row_it); dout << diag::dendl; } return dout; }
diag::Writer & PrintTable::verbose_print( diag::Writer & dout) const { // const ColumnWidthVector &column_width = calculate_column_widths(); // for (Table::const_iterator row_it = m_header.begin(); row_it != m_header.end(); ++row_it) { // printRow(os, *row_it); // os << '\n'; // } // if (m_header.size() > 0) // printHeaderBar(os); // for (Table::const_iterator row_it = m_table.begin(); row_it != m_table.end(); ++row_it) { // int i = 0; // for (Row::const_iterator cell_it = (*row_it).begin(); cell_it != (*row_it).end(); ++cell_it, ++i) // if ((*cell_it).m_flags & Cell::SPAN) // dout << (*cell_it).m_string; // else // dout << std::setw(column_width[i]) << (*cell_it).m_string; // dout << dendl; // } calculate_column_widths(); dout << m_title << std::endl; for (Table::const_iterator row_it = m_header.begin(); row_it != m_header.end(); ++row_it) { dout << ""; printRow(dout.getStream(), *row_it); dout << diag::dendl; } if (m_header.size() > 0) { dout << ""; printHeaderBar(dout.getStream()); dout << diag::dendl; } for (Table::const_iterator row_it = m_table.begin(); row_it != m_table.end(); ++row_it) { dout << ""; printRow(dout.getStream(), *row_it); dout << diag::dendl; } return dout; }
std::ostream & PrintTable::print( std::ostream & os) const { if (m_flags & COMMA_SEPARATED_VALUES) csvPrint(os); else { if (m_flags & PRINT_TRANSPOSED) transpose_table(); calculate_column_widths(); if (!m_title.empty()) { int prespaces = 0; if(m_title.length() < m_tableWidth) prespaces = (m_tableWidth - m_title.length())/2;; os << m_commentPrefix; os << std::left << std::setw(prespaces) << "" << m_title << '\n'; } for (Table::const_iterator row_it = m_header.begin(); row_it != m_header.end(); ++row_it) { os << m_commentPrefix; printRow(os, *row_it); os << '\n'; } if (m_header.size() > 0) { os << m_commentPrefix; printHeaderBar(os); os << '\n'; } for (Table::const_iterator row_it = m_table.begin(); row_it != m_table.end(); ++row_it) { os << std::left << std::setw(m_commentPrefix.size()) << ""; printRow(os, *row_it); os << '\n'; } } return os; }