From 171b23eebb0c6cc01fa3cc3467ddc73990b28ce5 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Sun, 18 Aug 2024 19:27:06 +0200 Subject: [PATCH] added parsing for new duration fields --- library/src/configuration.cpp | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/library/src/configuration.cpp b/library/src/configuration.cpp index 3b1c8ea..a73acc2 100644 --- a/library/src/configuration.cpp +++ b/library/src/configuration.cpp @@ -144,7 +144,7 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json) continue; } - qCritical() << " -" << mb_name; + // qCritical() << " -" << mb_name; // Get array for each JSON object member auto mb_array = document[mb_name].GetArray(); @@ -797,9 +797,25 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json) Duration.pun_fixed = k->value.GetBool(); } } - else if (strcmp(inner_obj_name, "pun_requires_change") == 0) { + else if (strcmp(inner_obj_name, "pun_mutable") == 0) { if (k->value.IsBool()) { - Duration.pun_requires_change = k->value.GetBool(); + Duration.pun_mutable = k->value.GetBool(); + } + } + else if (strcmp(inner_obj_name, "pun_round_to_next_24h_boundary") == 0) { + if (k->value.IsBool()) { + Duration.pun_round_to_next_24h_boundary = k->value.GetBool(); + } + } + else if (strcmp(inner_obj_name, "pun_round_to_prev_24h_boundary") == 0) { + if (k->value.IsBool()) { + Duration.pun_round_to_prev_24h_boundary = k->value.GetBool(); + } + } + else if (strcmp(inner_obj_name, "pun_align_with_timepoint") == 0) { + if (k->value.IsString()) { + QDateTime const &dt = QDateTime::fromString(k->value.GetString(), Qt::ISODate); + Duration.pun_align_with_timepoint = dt; } } break; @@ -866,7 +882,7 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json) } break; case MemberType::DurationType: cfg->Duration.insert(pair(Duration.pun_id, Duration)); - // qCritical() << Duration; + //qCritical() << Duration; break; case MemberType::SpecialDaysWorktimeType: cfg->SpecialDaysWorktime.insert(pair(SpecialDaysWorktime.pedwt_period_exc_day_id, SpecialDaysWorktime)); @@ -922,7 +938,7 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json) break; case MemberType::PrepaidOptionType: cfg->TariffPrepayOptions.insert(pair(TariffPrepayOption.id, TariffPrepayOption)); - qCritical() << TariffPrepayOption; + //qCritical() << TariffPrepayOption; break; default: break;