| 1373 | } |
| 1374 | |
| 1375 | int Result_buffer::print_result() { |
| 1376 | int col; |
| 1377 | int spaces; |
| 1378 | bool is_header = true; |
| 1379 | std::ostream &out = (printmode & DISP_STDERR) ? std::cerr : std::cout; |
| 1380 | |
| 1381 | if (width.size() == 0) { |
| 1382 | return 0; |
| 1383 | } |
| 1384 | |
| 1385 | print_separator(); |
| 1386 | |
| 1387 | while (!result.empty()) { |
| 1388 | std::list<std::string> row = result.front(); |
| 1389 | out << "|"; |
| 1390 | col = 0; |
| 1391 | while (!row.empty()) { |
| 1392 | std::string column = row.front(); |
| 1393 | out << " " << column; |
| 1394 | /* Fill spaces */ |
| 1395 | spaces = width[col] - column.length(); |
| 1396 | for (int i = 0; i < spaces; i ++) { |
| 1397 | out << " "; |
| 1398 | } |
| 1399 | out << " |"; |
| 1400 | row.pop_front(); |
| 1401 | col ++; |
| 1402 | } |
| 1403 | out << std::endl; |
| 1404 | |
| 1405 | result.pop_front(); |
| 1406 | |
| 1407 | if (is_header || result.empty()) { |
| 1408 | print_separator(); |
| 1409 | is_header = false; |
| 1410 | } |
| 1411 | } |
| 1412 | return 0; |
| 1413 | } |
| 1414 | |
| 1415 | int process_bind(const char *sql) |
| 1416 | { |