23 #include <QCoreApplication>
25 #include <QJsonParseError>
26 #include <QJsonDocument>
28 #include "Tympan/core/config.h"
34 #define TR(id) OLocalizator::getString("TYSolverParamsWidgetManager", (id))
38 QString test(QCoreApplication::applicationDirPath() +
"/" + SOLVER_PARAMS_JSON);
51 dataModelPath = QDir::toNativeSeparators(dataModelPath);
53 QFile file(dataModelPath);
54 bool opened = file.open(QIODevice::ReadOnly | QIODevice::Text);
60 QJsonParseError JsonParseError;
61 QJsonObject dataModel = QJsonDocument::fromJson(file.readAll(), &JsonParseError).object();
65 for (QString sectionName : dataModel.keys())
67 QJsonObject section = dataModel[sectionName].toObject();
68 for (QString paramName : section.keys())
105 else if (dataModel->
isBool())
135 QStringList lines =
_solverParams.split(QRegExp(
"[\r\n]"), Qt::SkipEmptyParts);
136 for (QString line : lines)
140 QStringList splitted_line = line.split(QRegExp(
"\\s?=\\s?"));
141 if (splitted_line.size() == 2)
143 QString paramName = splitted_line[0];
144 QString value = splitted_line[1];
151 if (value ==
"False")
165 newValue = newValue.replace(
',',
'.');
169 newValue = (newValue ==
"1" ?
"True" :
"False");
171 const QRegExp paramRegex{QRegExp::escape(paramName) +
"\\s?=\\s?([[0-9]*\\.?[0-9]*|(True|False))"};
Objet contenant les informations concernant les parametres du solveur.
static TYSolverParamsDataModel * fromJsonObject(QString paramName, QJsonObject dataModelJson)
Utilities to handle exceptions and to pretty-print value.
#define tympan_source_loc
This macro build a source_loc object to be attached to a tympan::Exception.
The base exception class for errors due to invalid data.