1313#include < clickhouse/base/socket.h> // for ipv4-ipv6 platform-specific stuff
1414
1515#include < iomanip>
16+ #include < sstream>
1617
1718namespace {
1819using namespace clickhouse ;
@@ -46,9 +47,9 @@ bool doPrintValue(const ColumnRef & c, const size_t row, std::ostream & ostr) {
4647 return false ;
4748}
4849
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 >()) {
5253 // via temporary stream to preserve fill and alignment of the ostr
5354 std::stringstream sstr;
5455 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
5859 return false ;
5960}
6061
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+
6167template <>
6268bool 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);
7070}
7171
7272std::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
152152 sstr << cross << std::setw (width + 2 ) << std::setfill (vertical_bar) << vertical_bar;
153153 }
154154 sstr << cross;
155- const auto split_line = sstr.str ();
155+ const std::string split_line ( sstr.str () );
156156
157157 ostr << split_line << std::endl;
158158 // column name
0 commit comments