Add operator << for printing
This commit is contained in:
		| @@ -2,6 +2,8 @@ | ||||
| #define TARIFF_CUSTOMER_H_INCLUDED | ||||
|  | ||||
| #include <QString> | ||||
| #include <QDebug> | ||||
| #include <QDebugStateSaver> | ||||
|  | ||||
| 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 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user