src/TabularPrefetchingHandler.h
branchv_0
changeset 31 c22577615ce4
parent 30 3c6374467a82
child 36 3b75b9f38abc
equal deleted inserted replaced
30:3c6374467a82 31:c22577615ce4
   150 		// Compute column widths and paddings:
   150 		// Compute column widths and paddings:
   151 		vector<integer_t> paddings(columnCount);
   151 		vector<integer_t> paddings(columnCount);
   152 		for (size_t i = 0; i < columnCount; i++) {
   152 		for (size_t i = 0; i < columnCount; i++) {
   153 			string_t typeCode = columnTypeCodes[i];
   153 			string_t typeCode = columnTypeCodes[i];
   154 			string_t columnName = columnNames[i];
   154 			string_t columnName = columnNames[i];
   155 			integer_t minWidth = columnName.size() + (getConfiguration(printTypes) ? typeCode.size() + 3 : 0); // 3 = " ()" in "columnName (typeCode)"
   155 			integer_t minWidth = columnName.size() + (getConfiguration(writeTypes) ? typeCode.size() + 3 : 0); // 3 = " ()" in "columnName (typeCode)"
   156 			columnWidths[i] = max(columnWidths[i], minWidth);
   156 			columnWidths[i] = max(columnWidths[i], minWidth);
   157 			paddings[i] = columnWidths[i] - minWidth;
   157 			paddings[i] = columnWidths[i] - minWidth;
   158 		}
   158 		}
   159 
   159 
   160 		printHorizontalLine(L"╭", L"┬", L"╮");
   160 		printHorizontalLine(L"╭", L"┬", L"╮");
   164 		for (size_t i = 0; i < columnCount; i++) {
   164 		for (size_t i = 0; i < columnCount; i++) {
   165 			output << " " << convertor.to_bytes(formatValue(columnNames[i], ESC_HEADER));
   165 			output << " " << convertor.to_bytes(formatValue(columnNames[i], ESC_HEADER));
   166 			for (integer_t p = 0; p < paddings[i]; p++) {
   166 			for (integer_t p = 0; p < paddings[i]; p++) {
   167 				output << " ";
   167 				output << " ";
   168 			}
   168 			}
   169 			if (getConfiguration(printTypes)) output << " (" << convertor.to_bytes(columnTypeCodes[i]) << ")";
   169 			if (getConfiguration(writeTypes)) output << " (" << convertor.to_bytes(columnTypeCodes[i]) << ")";
   170 			output << ESC_BORDER << " │" << ESC_RESET;
   170 			output << ESC_BORDER << " │" << ESC_RESET;
   171 		}
   171 		}
   172 		output << std::endl;
   172 		output << std::endl;
   173 		printHorizontalLine(L"├", L"┼", L"┤");
   173 		printHorizontalLine(L"├", L"┼", L"┤");
   174 
   174 
   187 			output << ESC_BORDER << " │" << ESC_RESET;
   187 			output << ESC_BORDER << " │" << ESC_RESET;
   188 			if (columnIndex == (columnCount - 1)) output << std::endl;
   188 			if (columnIndex == (columnCount - 1)) output << std::endl;
   189 		}
   189 		}
   190 		printHorizontalLine(L"╰", L"┴", L"╯");
   190 		printHorizontalLine(L"╰", L"┴", L"╯");
   191 
   191 
   192 		if (getConfiguration(printRecordCount)) {
   192 		if (getConfiguration(writeRecordCount)) {
   193 			integer_t recordCount = values.size() / columnCount;
   193 			integer_t recordCount = values.size() / columnCount;
   194 			output << ESC_YELLOW << "Record count: " << ESC_RESET << recordCount << std::endl;
   194 			output << ESC_YELLOW << "Record count: " << ESC_RESET << recordCount << std::endl;
   195 		}
   195 		}
   196 
   196 
   197 		values.clear();
   197 		values.clear();
   211 				currentRelationConfiguration = &configuration.relationConfigurations[i];
   211 				currentRelationConfiguration = &configuration.relationConfigurations[i];
   212 				break; // it there are multiple matches, only the first configuration is used
   212 				break; // it there are multiple matches, only the first configuration is used
   213 			}
   213 			}
   214 		}
   214 		}
   215 
   215 
   216 		if (getConfiguration(printRelationName)) output << ESC_RED << convertor.to_bytes(name) << ":" << ESC_RESET << endl;
   216 		if (getConfiguration(writeRelationName)) output << ESC_RED << convertor.to_bytes(name) << ":" << ESC_RESET << endl;
   217 		columnCount = attributes.size();
   217 		columnCount = attributes.size();
   218 		columnTypes.resize(columnCount);
   218 		columnTypes.resize(columnCount);
   219 		columnTypeCodes.resize(columnCount);
   219 		columnTypeCodes.resize(columnCount);
   220 		columnNames.resize(columnCount);
   220 		columnNames.resize(columnCount);
   221 		columnWidths.resize(columnCount, 0);
   221 		columnWidths.resize(columnCount, 0);