still no clue
This commit is contained in:
37
Query.cpp
37
Query.cpp
@ -25,6 +25,10 @@ vector<Park_time> query_parktimes_for_customer(int cid) {
|
||||
return park_times;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------- customers
|
||||
|
||||
|
||||
vector<Customer> query_customer_with_name(string name) {
|
||||
/*
|
||||
We use this instead of plain customers because:
|
||||
@ -71,6 +75,22 @@ Customer query_customer_with_id(int id) {
|
||||
}
|
||||
}
|
||||
|
||||
Customer* get_customer_ptr_for_parkspot(int id) {
|
||||
if (!id) {
|
||||
return 0;
|
||||
}
|
||||
for (int i = 0; i < park_customers.size(); i++) {
|
||||
if (park_customers[i].id == id) {
|
||||
|
||||
return &park_customers[i];
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// -------------- paroking spots
|
||||
|
||||
void query_all_parking_spots() {
|
||||
SQLite::Statement query(data::db, "SELECT * FROM Park_spot WHERE id > ?;");
|
||||
query.bind(1, 0);
|
||||
@ -79,20 +99,9 @@ void query_all_parking_spots() {
|
||||
int taken = query.getColumn(1);
|
||||
int cid = query.getColumn(2);
|
||||
park_customers.push_back(query_customer_with_id(cid));
|
||||
parking_spots.push_back(
|
||||
Park_spot{get_customer_ptr_for_parkspot(cid), id, bool(taken)});
|
||||
parking_spots.push_back({id, taken, get_customer_ptr_for_parkspot(cid)});
|
||||
// parking_spots.push_back(temp);
|
||||
}
|
||||
cout << "WUT?";
|
||||
}
|
||||
|
||||
Customer* get_customer_ptr_for_parkspot(int id) {
|
||||
if (!id) {
|
||||
return nullptr;
|
||||
}
|
||||
for (int i = 0; i < park_customers.size(); i++) {
|
||||
if (park_customers[i].id == id) {
|
||||
|
||||
return &park_customers[i];
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
Reference in New Issue
Block a user