13
13
#include < clickhouse/base/socket.h> // for ipv4-ipv6 platform-specific stuff
14
14
15
15
#include < iomanip>
16
+ #include < sstream>
16
17
17
18
namespace {
18
19
using namespace clickhouse ;
@@ -46,9 +47,9 @@ bool doPrintValue(const ColumnRef & c, const size_t row, std::ostream & ostr) {
46
47
return false ;
47
48
}
48
49
49
- template <>
50
- bool doPrintValue<ColumnEnum8> (const ColumnRef & c, const size_t row, std::ostream & ostr) {
51
- if (const auto & casted_c = c->As <ColumnEnum8 >()) {
50
+ template <typename ColumnEnumType >
51
+ bool doPrintEnumValue (const ColumnRef & c, const size_t row, std::ostream & ostr) {
52
+ if (const auto & casted_c = c->As <ColumnEnumType >()) {
52
53
// via temporary stream to preserve fill and alignment of the ostr
53
54
std::stringstream sstr;
54
55
sstr << casted_c->NameAt (row) << " (" << static_cast <int64_t >(casted_c->At (row)) << " )" ;
@@ -58,15 +59,14 @@ bool doPrintValue<ColumnEnum8>(const ColumnRef & c, const size_t row, std::ostre
58
59
return false ;
59
60
}
60
61
62
+ template <>
63
+ bool doPrintValue<ColumnEnum8>(const ColumnRef & c, const size_t row, std::ostream & ostr) {
64
+ return doPrintEnumValue<ColumnEnum8>(c, row, ostr);
65
+ }
66
+
61
67
template <>
62
68
bool doPrintValue<ColumnEnum16>(const ColumnRef & c, const size_t row, std::ostream & ostr) {
63
- if (const auto & casted_c = c->As <ColumnEnum16>()) {
64
- std::stringstream sstr;
65
- sstr << casted_c->NameAt (row) << " (" << static_cast <int64_t >(casted_c->At (row)) << " )" ;
66
- ostr << sstr.str ();
67
- return true ;
68
- }
69
- return false ;
69
+ return doPrintEnumValue<ColumnEnum16>(c, row, ostr);
70
70
}
71
71
72
72
std::ostream & printColumnValue (const ColumnRef& c, const size_t row, std::ostream & ostr) {
@@ -152,7 +152,7 @@ std::ostream& operator<<(std::ostream & ostr, const PrettyPrintBlock & pretty_pr
152
152
sstr << cross << std::setw (width + 2 ) << std::setfill (vertical_bar) << vertical_bar;
153
153
}
154
154
sstr << cross;
155
- const auto split_line = sstr.str ();
155
+ const std::string split_line ( sstr.str () );
156
156
157
157
ostr << split_line << std::endl;
158
158
// column name
0 commit comments