23 using namespace impala;
43 DCHECK_EQ(row.size(),
labels_.size());
45 for (
int i = 0; i < row.size(); ++i) {
51 const vector<int>& widths)
const {
52 DCHECK_EQ(row.size(),
labels_.size());
53 stringstream& ss = *s;
54 for (
int i = 0; i < row.size(); ++i) {
60 ss << setw(widths[i]);
62 if (i != 0) tmp <<
" ";
64 tmp << string(row[i].data(), widths[i] -
COLUMN_PAD - 3) <<
"...";
68 if (i != row.size() - 1) tmp <<
" ";
76 for (
int i = 0; i < output_widths.size(); ++i) {
81 total_width += output_widths[i];
92 for (
int i = 0; i < total_width; ++i) {
98 for (
int i = 0; i <
rows_.size(); ++i) {
100 if (i !=
rows_.size() - 1) ss << endl;
std::string ToString(const std::string &prefix="") const
Print to a table with prefix coming before the output.
void AddColumn(const std::string &label, bool left_align)
std::vector< std::vector< std::string > > rows_
std::vector< bool > left_align_
For each column, true if the value should be left aligned, right aligned otherwise.
std::vector< std::string > labels_
int max_output_width_
-1 to indicate unlimited.
std::vector< int > max_col_widths_
void AddRow(const std::vector< std::string > &row)
Add a row to the table. This must have the same width as labels.
void set_max_output_width(int width)
void PrintRow(std::stringstream *ss, const std::vector< std::string > &row, const std::vector< int > &widths) const
Helper function to print one row to ss.