ParseJson():
Add parsing for prepaid-options.
This commit is contained in:
		| @@ -591,6 +591,49 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json) | |||||||
|                                 QTime const &t = QTime::fromString(k->value.GetString(), Qt::ISODate); |                                 QTime const &t = QTime::fromString(k->value.GetString(), Qt::ISODate); | ||||||
|                                 TariffPrepaidOption.static_end = t; |                                 TariffPrepaidOption.static_end = t; | ||||||
|                             } |                             } | ||||||
|  |                         } else | ||||||
|  |                         if (QString(inner_obj_name) == QString("prepaid_week")) { | ||||||
|  |                             if (k->value.IsArray()) { | ||||||
|  |                                 auto days = k->value.GetArray(); | ||||||
|  |                                 for (rapidjson::SizeType j=0; j < days.Size(); ++j) { | ||||||
|  |                                     if (days[j].IsObject()) { | ||||||
|  |                                         auto weekday = days[j].GetObject(); | ||||||
|  |                                         for (auto w = weekday.MemberBegin(); w != weekday.MemberEnd(); ++w) { | ||||||
|  |                                             int day = j+1; // 8 entries | ||||||
|  |  | ||||||
|  |                                             TariffPrepaidOption.prepaid[day].day = 0; | ||||||
|  |  | ||||||
|  |                                             QString member(QString::fromStdString(w->name.GetString())); | ||||||
|  |                                             if (member == "prepaid_day") { | ||||||
|  |                                                 if (w->value.IsInt()) { | ||||||
|  |                                                     rapidjson::SizeType const d = w->value.GetInt(); | ||||||
|  |                                                     if (d != (j+1)) { | ||||||
|  |                                                         qCritical() << "ERROR: misconfigured jsonfile" << d << "!=" << (j+1); | ||||||
|  |                                                     } | ||||||
|  |                                                     TariffPrepaidOption.prepaid[day].day = day; | ||||||
|  |                                                 } | ||||||
|  |                                             } else | ||||||
|  |                                             if (member == "prepaid_duration") { | ||||||
|  |                                                 if (w->value.IsInt()) { | ||||||
|  |                                                     TariffPrepaidOption.prepaid[day].duration = w->value.GetInt(); | ||||||
|  |                                                 } | ||||||
|  |                                             } else | ||||||
|  |                                             if (member == "prepaid_static_start") { | ||||||
|  |                                                 if (w->value.IsString()) { | ||||||
|  |                                                     QTime const &t = QTime::fromString(w->value.GetString(), Qt::ISODate); | ||||||
|  |                                                     TariffPrepaidOption.prepaid[day].static_start = t; | ||||||
|  |                                                 } | ||||||
|  |                                             } else | ||||||
|  |                                             if (member == "prepaid_static_end") { | ||||||
|  |                                                 if (w->value.IsString()) { | ||||||
|  |                                                     QTime const &t = QTime::fromString(w->value.GetString(), Qt::ISODate); | ||||||
|  |                                                     TariffPrepaidOption.prepaid[day].static_end = t; | ||||||
|  |                                                 } | ||||||
|  |                                             } | ||||||
|  |                                         } | ||||||
|  |                                     } | ||||||
|  |                                 } | ||||||
|  |                             } | ||||||
|                         } |                         } | ||||||
|                     } break; |                     } break; | ||||||
|                     case MemberType::InterpolationType: { |                     case MemberType::InterpolationType: { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user