From 96587229e262fa73ca68284d35df006249900e0f Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Fri, 15 Dec 2023 13:28:04 +0100 Subject: [PATCH] Add operator << for printing --- library/include/mobilisis/tariff_customer.h | 26 +++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/library/include/mobilisis/tariff_customer.h b/library/include/mobilisis/tariff_customer.h index 32a7103..44ce444 100644 --- a/library/include/mobilisis/tariff_customer.h +++ b/library/include/mobilisis/tariff_customer.h @@ -2,6 +2,8 @@ #define TARIFF_CUSTOMER_H_INCLUDED #include +#include +#include struct ATBCustomer { enum class CustomerType {ADULT=1000, CHILD, TEEN}; @@ -10,6 +12,30 @@ struct ATBCustomer { CustomerType cust_type; QString cust_label; + + friend QDebug operator<<(QDebug debug, ATBCustomer const &customer) { + QDebugStateSaver saver(debug); + + switch(customer.cust_type) { + case ATBCustomer::CustomerType::ADULT: + debug.nospace() + << " cust_type: " << "CustomerType::ADULT" << "\n" + << "cust_label: " << customer.cust_label << "\n"; + break; + case ATBCustomer::CustomerType::CHILD: + debug.nospace() + << " cust_type: " << "CustomerType::CHILD" << "\n" + << "cust_label: " << customer.cust_label << "\n"; + break; + case ATBCustomer::CustomerType::TEEN: + debug.nospace() + << " cust_type: " << "CustomerType::TEEN" << "\n" + << "cust_label: " << customer.cust_label << "\n"; + break; + } + + return debug; + } }; #endif // TARIFF_CUSTOMER_H_INCLUDED