Add operator << for printing
This commit is contained in:
		@@ -3,29 +3,80 @@
 | 
			
		||||
 | 
			
		||||
#include <QString>
 | 
			
		||||
#include <QDateTime>
 | 
			
		||||
#include <QVector>
 | 
			
		||||
#include <QDebug>
 | 
			
		||||
#include <QDebugStateSaver>
 | 
			
		||||
 | 
			
		||||
struct DailyTicket {
 | 
			
		||||
    DailyTicket() = default;
 | 
			
		||||
 | 
			
		||||
#include "tariff_customer.h"
 | 
			
		||||
#include "tariff_time_range.h"
 | 
			
		||||
#include "tariff_timebase.h"
 | 
			
		||||
 | 
			
		||||
struct ATBDailyTicket {
 | 
			
		||||
    ATBDailyTicket() = default;
 | 
			
		||||
 | 
			
		||||
    int daily_ticket_payment_option_id;
 | 
			
		||||
    int daily_ticket_unit_id;
 | 
			
		||||
    double daily_ticket_price;
 | 
			
		||||
 | 
			
		||||
    int daily_ticket_tbase_id;                  // time base setting for ticket:
 | 
			
		||||
                                                // 1: absolute: using time stamps
 | 
			
		||||
                                                // 2: relative: use offsets from
 | 
			
		||||
                                                //    some reference time point,
 | 
			
		||||
                                                //    typically "start time".
 | 
			
		||||
    ATBTimeBase::TimeBaseType daily_ticket_tbase_type;
 | 
			
		||||
                                        // time base setting for ticket:
 | 
			
		||||
                                        // absolute: using time stamps
 | 
			
		||||
                                        // relative: use offsets from
 | 
			
		||||
                                        //    some reference time point,
 | 
			
		||||
                                        //    typically "start time".
 | 
			
		||||
 | 
			
		||||
    QVector<int> daily_ticket_clearance_type;   // who is allowed to buy the ticket:
 | 
			
		||||
                                                // list of customer types
 | 
			
		||||
    ATBCustomer::CustomerType daily_ticket_clearance_customer_type;
 | 
			
		||||
                                        // who is allowed to buy the ticket:
 | 
			
		||||
                                        // list of customer types
 | 
			
		||||
 | 
			
		||||
    QTime daily_ticket_from_min;                // used in case time base == 1
 | 
			
		||||
    QTime daily_ticket_to_max;
 | 
			
		||||
    int daily_ticket_weekday_range;  // [mon-sun]
 | 
			
		||||
    int daily_ticket_special_day_range;
 | 
			
		||||
 | 
			
		||||
    int daily_ticket_from_offset_min;           // used in case time base == 2
 | 
			
		||||
    int daily_ticket_to_offset_max;
 | 
			
		||||
 | 
			
		||||
    friend QDebug operator<<(QDebug debug, ATBDailyTicket const &ticket) {
 | 
			
		||||
        QDebugStateSaver saver(debug);
 | 
			
		||||
 | 
			
		||||
        debug.nospace()
 | 
			
		||||
                << "      daily_ticket_payment_option_id: " << ticket.daily_ticket_payment_option_id << "\n"
 | 
			
		||||
                << "                daily_ticket_unit_id: " << ticket.daily_ticket_unit_id << "\n"
 | 
			
		||||
                << "                  daily_ticket_price: " << ticket.daily_ticket_price << "\n";
 | 
			
		||||
 | 
			
		||||
        switch(ticket.daily_ticket_tbase_type) {
 | 
			
		||||
        case ATBTimeBase::TimeBaseType::ABSOLUTE:
 | 
			
		||||
            debug.nospace()
 | 
			
		||||
                << "             daily_ticket_tbase_type: " << "TimeBaseType::ABSOLUTE" << "\n";
 | 
			
		||||
            break;
 | 
			
		||||
        case ATBTimeBase::TimeBaseType::RELATIVE:
 | 
			
		||||
            debug.nospace()
 | 
			
		||||
                << "             daily_ticket_tbase_type: " << "TimeBaseType::RELATIVE" << "\n";
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        switch(ticket.daily_ticket_clearance_customer_type) {
 | 
			
		||||
        case ATBCustomer::CustomerType::ADULT:
 | 
			
		||||
            debug.nospace()
 | 
			
		||||
                << "daily_ticket_clearance_customer_type: " << "CustomerType::ADULT" << "\n";
 | 
			
		||||
            break;
 | 
			
		||||
        case ATBCustomer::CustomerType::CHILD:
 | 
			
		||||
            debug.nospace()
 | 
			
		||||
                << "daily_ticket_clearance_customer_type: " << "CustomerType::CHILD" << "\n";
 | 
			
		||||
            break;
 | 
			
		||||
        case ATBCustomer::CustomerType::TEEN:
 | 
			
		||||
            debug.nospace()
 | 
			
		||||
                << "daily_ticket_clearance_customer_type: " << "CustomerType::TEEN" << "\n";
 | 
			
		||||
            break;
 | 
			
		||||
        default:
 | 
			
		||||
            debug.nospace()
 | 
			
		||||
                << "daily_ticket_clearance_customer_type: " << "CustomerType::???" << "\n";
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        debug.nospace()
 | 
			
		||||
            << "          daily_ticket_weekday_range: " << ticket.daily_ticket_weekday_range << "\n"
 | 
			
		||||
            << "      daily_ticket_special_day_range: " << ticket.daily_ticket_special_day_range << "\n";
 | 
			
		||||
 | 
			
		||||
        return debug;
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif // TARIFF_DAILY_TICKET_H_INCLUDED
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user