18#include <QXmlStreamReader>
36 bool parse(QIODevice *device);
86 return m_d->parse(device);
100 if (
m_reader.name() == QLatin1String(
"modulesConfig"))
106 m_reader.raiseError(QObject::tr(
"The file is not a LIMA XML configuration file."));
121 LTRACE <<
"readConfiguration";
122 Q_ASSERT(
m_reader.isStartElement() &&
m_reader.name() == QLatin1String(
"modulesConfig"));
124 while (
m_reader.readNextStartElement())
126 if (
m_reader.name() == QLatin1String(
"module"))
129 m_reader.raiseError(QObject::tr(
"Expected a module but got a %1.").arg(
m_reader.name()));
148 while (
m_reader.readNextStartElement())
150 if (
m_reader.name() == QLatin1String(
"group"))
174 for (
const auto& attribute:
m_reader.attributes())
180 auto key = attribute.name();
181 auto value = attribute.value();
185 while (
m_reader.readNextStartElement())
187 if (
m_reader.name() == QLatin1String(
"param"))
189 else if (
m_reader.name() == QLatin1String(
"list"))
191 else if (
m_reader.name() == QLatin1String(
"map"))
206 LTRACE <<
"XmlConfigurationFileReader::readParam" << key << value;
219 LTRACE <<
"XmlConfigurationFileReader::readList" << listName;
221 while (
m_reader.readNextStartElement())
223 if (
m_reader.name() == QLatin1String(
"item"))
226 m_reader.raiseError(QObject::tr(
"Expected a list item in list %1 in group %2, in module %3 but got a %4.")
236 LTRACE <<
"XmlConfigurationFileReader::readListItem" << value;
249 LTRACE <<
" XmlConfigurationFileReaderPrivate::readMap" << mapName;
250 LTRACE <<
"XmlConfigurationFileReaderPrivate::readMap add empty map"<< mapName;
252 while (
m_reader.readNextStartElement())
254 if (
m_reader.name() == QLatin1String(
"entry"))
257 m_reader.raiseError(QObject::tr(
"Expected a map entry in map %1 in group %2, in module %3 but got a %4.")
266 LTRACE <<
"XmlConfigurationFileReaderPrivate::readMapEntry";
278 auto errorStr = QObject::tr(
"%1, Line %2, column %3")
279 .arg(m_d->m_reader.errorString())
280 .arg(m_d->m_reader.lineNumber())
281 .arg(m_d->m_reader.columnNumber());
#define LIMA_XMLCONFIGURATIONFILES_EXPORT
The instances of this class hold configuration informations of the modules Its design is currently ve...
static QString mapNameAttribute()
static QString mapEntryKeyAttribute()
void readListItem(const QString &listName)
static QString moduleNameAttribute()
static QString groupNameAttribute()
static QString mapEntryValueAttribute()
~XmlConfigurationFileReaderPrivate()=default
XmlConfigurationFileReaderPrivate(ConfigurationStructure &theConfiguration)
bool parse(QIODevice *device)
static QString paramValueAttribute()
QXmlStreamReader m_reader
static QString listItemValueAttribute()
static QString listNameAttribute()
static QString paramKeyAttribute()
void readMapEntry(const QString &mapName)
ConfigurationStructure & m_configuration
~XmlConfigurationFileReader()
QString errorString() const
XmlConfigurationFileReader(ConfigurationStructure &theConfiguration)
bool parse(QIODevice *device)
launch exception related to the configuration file parsing