From f1f5ac89005c0557f66c141db6d50ce5d7563306 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Fri, 15 Dec 2023 13:28:34 +0100 Subject: [PATCH] Add operator << for printing --- library/include/mobilisis/tariff_timebase.h | 26 +++++++++++++++ library/include/mobilisis/time_range_header.h | 33 +++++++++++++++---- 2 files changed, 52 insertions(+), 7 deletions(-) diff --git a/library/include/mobilisis/tariff_timebase.h b/library/include/mobilisis/tariff_timebase.h index c0c1f01..55b73a8 100644 --- a/library/include/mobilisis/tariff_timebase.h +++ b/library/include/mobilisis/tariff_timebase.h @@ -2,6 +2,8 @@ #define TARIFF_TIME_BASE_H_INCLUDED #include +#include +#include struct ATBTimeBase { enum class TimeBaseType {ABSOLUTE=0, RELATIVE=1}; @@ -9,6 +11,30 @@ struct ATBTimeBase { ATBTimeBase() = default; TimeBaseType tbase_type; QString tbase_label; + + friend QDebug operator<<(QDebug debug, ATBTimeBase const &timeBase) { + QDebugStateSaver saver(debug); + + switch(timeBase.tbase_type) { + case ATBTimeBase::TimeBaseType::ABSOLUTE: + debug.nospace() + << " tbase_type: " << "TimeBaseType::ABSOLUTE" << "\n" + << "tbase_label: " << timeBase.tbase_label << "\n"; + break; + case ATBTimeBase::TimeBaseType::RELATIVE: + debug.nospace() + << " tbase_type: " << "TimeBaseType::RELATIVE" << "\n" + << "tbase_label: " << timeBase.tbase_label << "\n"; + break; + default: + debug.nospace() + << " tbase_type: " << "TimeBaseType::???" << "\n"; + break; + } + + return debug; + } + }; #endif // TARIFF_TIME_BASE_H_INCLUDED diff --git a/library/include/mobilisis/time_range_header.h b/library/include/mobilisis/time_range_header.h index feb5d5c..e2ca2e8 100644 --- a/library/include/mobilisis/time_range_header.h +++ b/library/include/mobilisis/time_range_header.h @@ -1,8 +1,27 @@ -#pragma once -#include +#ifndef TIME_RANGE_HEADER_H_INCLUDED +#define TIME_RANGE_HEADER_H_INCLUDED -class ATBTimeRange { -public: - time_t time_from; - time_t time_to; -}; \ No newline at end of file +#include +#include +#include +#include + +struct ATBTimeRange { + int time_range_id; + QTime time_range_from; + QTime time_range_to; + + + friend QDebug operator<<(QDebug debug, ATBTimeRange const &timeRange) { + QDebugStateSaver saver(debug); + + debug.nospace() + << " time_range_id: " << timeRange.time_range_id << "\n" + << "time_range_from: " << timeRange.time_range_from.toString(Qt::ISODate) << "\n" + << " time_range_to: " << timeRange.time_range_to.toString(Qt::ISODate) << "\n"; + + return debug; + } +}; + +#endif // TIME_RANGE_HEADER_H_INCLUDED