@@ -46,22 +46,19 @@ class Printer {
46
46
47
47
static void print_table (std::ostream &stream, TableInternal &table);
48
48
49
- static void
50
- print_row_in_cell (std::ostream &stream, TableInternal &table,
51
- const std::pair<size_t , size_t > &index,
52
- const std::pair<size_t , size_t > &dimension,
53
- size_t num_columns, size_t row_index,
54
- const std::vector<std::string> &splitted_cell_text);
49
+ static void print_row_in_cell (std::ostream &stream, TableInternal &table,
50
+ const std::pair<size_t , size_t > &index,
51
+ const std::pair<size_t , size_t > &dimension, size_t num_columns,
52
+ size_t row_index,
53
+ const std::vector<std::string> &splitted_cell_text);
55
54
56
55
static bool print_cell_border_top (std::ostream &stream, TableInternal &table,
57
56
const std::pair<size_t , size_t > &index,
58
- const std::pair<size_t , size_t > &dimension,
59
- size_t num_columns);
60
- static bool
61
- print_cell_border_bottom (std::ostream &stream, TableInternal &table,
62
- const std::pair<size_t , size_t > &index,
63
- const std::pair<size_t , size_t > &dimension,
64
- size_t num_columns);
57
+ const std::pair<size_t , size_t > &dimension, size_t num_columns);
58
+ static bool print_cell_border_bottom (std::ostream &stream, TableInternal &table,
59
+ const std::pair<size_t , size_t > &index,
60
+ const std::pair<size_t , size_t > &dimension,
61
+ size_t num_columns);
65
62
66
63
static void apply_element_style (std::ostream &stream, Color foreground_color,
67
64
Color background_color,
@@ -72,26 +69,21 @@ class Printer {
72
69
apply_font_style (stream, style);
73
70
}
74
71
75
- static void reset_element_style (std::ostream &stream) {
76
- stream << termcolor::reset;
77
- }
72
+ static void reset_element_style (std::ostream &stream) { stream << termcolor::reset; }
78
73
79
74
private:
80
- static void print_content_left_aligned (std::ostream &stream,
81
- const std::string &cell_content,
82
- const Format &format,
83
- size_t text_with_padding_size,
75
+ static void print_content_left_aligned (std::ostream &stream, const std::string &cell_content,
76
+ const Format &format, size_t text_with_padding_size,
84
77
size_t column_width) {
85
78
86
79
// Apply font style
87
- apply_element_style (stream, *format.font_color_ ,
88
- *format.font_background_color_ , *format. font_style_ );
80
+ apply_element_style (stream, *format.font_color_ , *format. font_background_color_ ,
81
+ *format.font_style_ );
89
82
stream << cell_content;
90
83
// Only apply font_style to the font
91
84
// Not the padding. So calling apply_element_style with font_style = {}
92
85
reset_element_style (stream);
93
- apply_element_style (stream, *format.font_color_ ,
94
- *format.font_background_color_ , {});
86
+ apply_element_style (stream, *format.font_color_ , *format.font_background_color_ , {});
95
87
96
88
if (text_with_padding_size < column_width) {
97
89
for (size_t j = 0 ; j < (column_width - text_with_padding_size); ++j) {
@@ -100,10 +92,8 @@ class Printer {
100
92
}
101
93
}
102
94
103
- static void print_content_center_aligned (std::ostream &stream,
104
- const std::string &cell_content,
105
- const Format &format,
106
- size_t text_with_padding_size,
95
+ static void print_content_center_aligned (std::ostream &stream, const std::string &cell_content,
96
+ const Format &format, size_t text_with_padding_size,
107
97
size_t column_width) {
108
98
auto num_spaces = column_width - text_with_padding_size;
109
99
if (num_spaces % 2 == 0 ) {
@@ -112,14 +102,13 @@ class Printer {
112
102
stream << " " ;
113
103
114
104
// Apply font style
115
- apply_element_style (stream, *format.font_color_ ,
116
- *format.font_background_color_ , *format. font_style_ );
105
+ apply_element_style (stream, *format.font_color_ , *format. font_background_color_ ,
106
+ *format.font_style_ );
117
107
stream << cell_content;
118
108
// Only apply font_style to the font
119
109
// Not the padding. So calling apply_element_style with font_style = {}
120
110
reset_element_style (stream);
121
- apply_element_style (stream, *format.font_color_ ,
122
- *format.font_background_color_ , {});
111
+ apply_element_style (stream, *format.font_color_ , *format.font_background_color_ , {});
123
112
124
113
for (size_t j = 0 ; j < num_spaces / 2 ; ++j)
125
114
stream << " " ;
@@ -129,24 +118,21 @@ class Printer {
129
118
stream << " " ;
130
119
131
120
// Apply font style
132
- apply_element_style (stream, *format.font_color_ ,
133
- *format.font_background_color_ , *format. font_style_ );
121
+ apply_element_style (stream, *format.font_color_ , *format. font_background_color_ ,
122
+ *format.font_style_ );
134
123
stream << cell_content;
135
124
// Only apply font_style to the font
136
125
// Not the padding. So calling apply_element_style with font_style = {}
137
126
reset_element_style (stream);
138
- apply_element_style (stream, *format.font_color_ ,
139
- *format.font_background_color_ , {});
127
+ apply_element_style (stream, *format.font_color_ , *format.font_background_color_ , {});
140
128
141
129
for (size_t j = 0 ; j < num_spaces - num_spaces_before; ++j)
142
130
stream << " " ;
143
131
}
144
132
}
145
133
146
- static void print_content_right_aligned (std::ostream &stream,
147
- const std::string &cell_content,
148
- const Format &format,
149
- size_t text_with_padding_size,
134
+ static void print_content_right_aligned (std::ostream &stream, const std::string &cell_content,
135
+ const Format &format, size_t text_with_padding_size,
150
136
size_t column_width) {
151
137
if (text_with_padding_size < column_width) {
152
138
for (size_t j = 0 ; j < (column_width - text_with_padding_size); ++j) {
@@ -155,14 +141,13 @@ class Printer {
155
141
}
156
142
157
143
// Apply font style
158
- apply_element_style (stream, *format.font_color_ ,
159
- *format.font_background_color_ , *format. font_style_ );
144
+ apply_element_style (stream, *format.font_color_ , *format. font_background_color_ ,
145
+ *format.font_style_ );
160
146
stream << cell_content;
161
147
// Only apply font_style to the font
162
148
// Not the padding. So calling apply_element_style with font_style = {}
163
149
reset_element_style (stream);
164
- apply_element_style (stream, *format.font_color_ ,
165
- *format.font_background_color_ , {});
150
+ apply_element_style (stream, *format.font_color_ , *format.font_background_color_ , {});
166
151
}
167
152
168
153
static void apply_font_style (std::ostream &stream, FontStyle style) {
@@ -196,8 +181,7 @@ class Printer {
196
181
}
197
182
}
198
183
199
- static void apply_foreground_color (std::ostream &stream,
200
- Color foreground_color) {
184
+ static void apply_foreground_color (std::ostream &stream, Color foreground_color) {
201
185
switch (foreground_color) {
202
186
case Color::grey:
203
187
stream << termcolor::grey;
@@ -229,8 +213,7 @@ class Printer {
229
213
}
230
214
}
231
215
232
- static void apply_background_color (std::ostream &stream,
233
- Color background_color) {
216
+ static void apply_background_color (std::ostream &stream, Color background_color) {
234
217
switch (background_color) {
235
218
case Color::grey:
236
219
stream << termcolor::on_grey;
0 commit comments