equal
deleted
inserted
replaced
38 |
38 |
39 using namespace relpipe::reader; |
39 using namespace relpipe::reader; |
40 |
40 |
41 class TabularPrefetchingHandler : public handlers::RelationalReaderStringHandler { |
41 class TabularPrefetchingHandler : public handlers::RelationalReaderStringHandler { |
42 private: |
42 private: |
|
43 |
|
44 class ColorScheme { |
|
45 }; |
|
46 |
43 std::wstring_convert<std::codecvt_utf8<wchar_t>> convertor; // TODO: support also other encodings. |
47 std::wstring_convert<std::codecvt_utf8<wchar_t>> convertor; // TODO: support also other encodings. |
44 const char* ESC_BRIGHT = "\u001b[1m"; |
48 const char* ESC_BRIGHT = "\u001b[1m"; |
45 const char* ESC_RED = "\u001b[31m"; |
49 const char* ESC_RED = "\u001b[31m"; |
46 const char* ESC_GREEN = "\u001b[32m"; |
50 const char* ESC_GREEN = "\u001b[32m"; |
47 const char* ESC_YELLOW = "\u001b[33m"; |
51 const char* ESC_YELLOW = "\u001b[33m"; |
49 const char* ESC_RESET = "\u001b[0m"; |
53 const char* ESC_RESET = "\u001b[0m"; |
50 |
54 |
51 const char* ESC_HEADER = ESC_BRIGHT; |
55 const char* ESC_HEADER = ESC_BRIGHT; |
52 const char* ESC_BORDER = ESC_GREEN; |
56 const char* ESC_BORDER = ESC_GREEN; |
53 const char* ESC_VALUE = ESC_CYAN; |
57 const char* ESC_VALUE = ESC_CYAN; |
|
58 const char* ESC_RELATION = ESC_RED; |
54 const char* ESC_REPLACEMENT = ESC_RED; |
59 const char* ESC_REPLACEMENT = ESC_RED; |
|
60 const char* ESC_COUNT = ESC_YELLOW; |
55 |
61 |
56 const char* INDENT = " "; // table indent from the left |
62 const char* INDENT = " "; // table indent from the left |
57 |
63 |
58 std::ostream& output; |
64 std::ostream& output; |
59 Configuration& configuration; |
65 Configuration& configuration; |
218 else if (configuration.tableStyle == Configuration::TableStyle::Ascii) printHorizontalLine(L"+", L"+", L"+", L"-"); |
224 else if (configuration.tableStyle == Configuration::TableStyle::Ascii) printHorizontalLine(L"+", L"+", L"+", L"-"); |
219 else throw RelpipeReaderException(L"Unsupported TableStyle: " + std::to_wstring((int) configuration.tableStyle)); |
225 else throw RelpipeReaderException(L"Unsupported TableStyle: " + std::to_wstring((int) configuration.tableStyle)); |
220 |
226 |
221 if (getConfiguration(writeRecordCount)) { |
227 if (getConfiguration(writeRecordCount)) { |
222 integer_t recordCount = values.size() / columnCount; |
228 integer_t recordCount = values.size() / columnCount; |
223 output << ESC_YELLOW << "Record count: " << ESC_RESET << recordCount << std::endl; |
229 output << ESC_COUNT << "Record count: " << ESC_RESET << recordCount << std::endl; |
224 } |
230 } |
225 |
231 |
226 values.clear(); |
232 values.clear(); |
227 } |
233 } |
228 |
234 |
240 currentRelationConfiguration = &configuration.relationConfigurations[i]; |
246 currentRelationConfiguration = &configuration.relationConfigurations[i]; |
241 break; // it there are multiple matches, only the first configuration is used |
247 break; // it there are multiple matches, only the first configuration is used |
242 } |
248 } |
243 } |
249 } |
244 |
250 |
245 if (getConfiguration(writeRelationName)) output << ESC_RED << convertor.to_bytes(name) << ":" << ESC_RESET << endl; |
251 if (getConfiguration(writeRelationName)) output << ESC_RELATION << convertor.to_bytes(name) << ":" << ESC_RESET << endl; |
246 columnCount = attributes.size(); |
252 columnCount = attributes.size(); |
247 columnTypes.resize(columnCount); |
253 columnTypes.resize(columnCount); |
248 columnTypeCodes.resize(columnCount); |
254 columnTypeCodes.resize(columnCount); |
249 columnNames.resize(columnCount); |
255 columnNames.resize(columnCount); |
250 columnWidths.resize(columnCount, 0); |
256 columnWidths.resize(columnCount, 0); |