Add handling for TimeStepConfig.

This commit is contained in:
Gerhard Hoffmann 2024-01-18 14:53:01 +01:00
parent 0b901954aa
commit 7f8ed9165d
4 changed files with 20 additions and 0 deletions

View File

@ -1,6 +1,7 @@
#include "configuration.h" #include "configuration.h"
#include "tariff_timebase.h" #include "tariff_timebase.h"
#include "time_range_header.h" #include "time_range_header.h"
#include "tariff_timestep_config.h"
#include <QString> #include <QString>
#include <QDebug> #include <QDebug>
@ -22,6 +23,7 @@ MemberType Configuration::IdentifyJsonMember(const char* member_name)
if (strcmp(member_name, "TimeBase") == 0) return MemberType::TimeBaseType; if (strcmp(member_name, "TimeBase") == 0) return MemberType::TimeBaseType;
if (strcmp(member_name, "Customer") == 0) return MemberType::CustomerType; if (strcmp(member_name, "Customer") == 0) return MemberType::CustomerType;
if (strcmp(member_name, "TimeRange") == 0) return MemberType::TimeRangeType; if (strcmp(member_name, "TimeRange") == 0) return MemberType::TimeRangeType;
if (strcmp(member_name, "TimeStepConfig") == 0) return MemberType::TimeStepConfigType;
else return MemberType::UnknownType; else return MemberType::UnknownType;
} }
@ -91,6 +93,7 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
ATBTimeBase TimeBase; ATBTimeBase TimeBase;
ATBCustomer Customer; ATBCustomer Customer;
ATBTimeRange TimeRange; ATBTimeRange TimeRange;
ATBTimeStepConfig TimeStepConfig;
MemberType mb_type = MemberType::UnknownType; MemberType mb_type = MemberType::UnknownType;
@ -188,6 +191,18 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
} }
} }
break; break;
case MemberType::TimeStepConfigType:
if (QString(inner_obj_name) == QString("tsconfig_id")) {
if (k->value.IsInt()) {
TimeStepConfig.tsconfig_id = k->value.GetInt();
}
} else
if (QString(inner_obj_name) == QString("tsconfig_label")) {
if (k->value.IsString()) {
TimeStepConfig.tsconfig_label = QString::fromStdString(k->value.GetString());
}
}
break;
case MemberType::DailyTicketType: case MemberType::DailyTicketType:
if (QString(inner_obj_name) == QString("daily_ticket_payment_option_id")) { if (QString(inner_obj_name) == QString("daily_ticket_payment_option_id")) {
if (k->value.IsInt()) { if (k->value.IsInt()) {
@ -396,6 +411,11 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
break; break;
case MemberType::TimeRangeType: case MemberType::TimeRangeType:
qCritical() << TimeRange; qCritical() << TimeRange;
cfg->TimeRange.insert(pair<int, ATBTimeRange>(TimeRange.time_range_id, TimeRange));
break;
case MemberType::TimeStepConfigType:
qCritical() << TimeStepConfig;
cfg->TimeStepConfig.insert(pair<int, ATBTimeStepConfig>(TimeStepConfig.tsconfig_id, TimeStepConfig));
break; break;
default: default:
break; break;

Binary file not shown.