| 41 | void print(std::ostream& stream, const Customer& customer); // Print a given customer to a given output stream |
| 42 | |
| 43 | int main() |
| 44 | { |
| 45 | DBConnectionRAII connection{ db_connect() }; |
| 46 | try |
| 47 | { |
| 48 | DBQueryResultRAII result{ db_query(connection, "SELECT * FROM CUSTOMER_TABEL") }; |
| 49 | if (!result) |
| 50 | { |
| 51 | throw DatabaseException{"Query failed"}; |
| 52 | } |
| 53 | |
| 54 | std::vector customers{ readCustomers(result) }; |
| 55 | |
| 56 | if (customers.empty()) |
| 57 | { |
| 58 | std::cerr << "No customers found?" << std::endl; |
| 59 | return 2; |
| 60 | } |
| 61 | |
| 62 | for (auto& customer : customers) |
| 63 | { |
| 64 | print(std::cout, customer); |
| 65 | } |
| 66 | } |
| 67 | catch (const std::exception& caught) |
| 68 | { |
| 69 | std::cerr << caught.what() << std::endl; |
| 70 | return 1; |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | std::vector<Customer> readCustomers(DB_QUERY_RESULT* result) |
| 75 | { |
nothing calls this directly
no test coverage detected