18#include <QXmlStreamReader>
24namespace XMLConfigurationFiles
36 bool parse(QIODevice *device);
37 void readConfiguration();
42 void readListItem(
const QString& listName);
44 void readMapEntry(
const QString& mapName);
72 m_moduleName(
""), m_groupName(
""), m_configuration(theConfiguration)
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")
#define LIMA_XMLCONFIGURATIONFILES_EXPORT
The instances of this class hold configuration informations of the modules Its design is currently ve...
void addAttributeForGroupInModule(const std::string &attKey, const std::string &attValue, const std::string &groupName, const std::string &moduleName)
void addListNamedForModuleAndGroup(const std::string &listName, const std::string &moduleName, const std::string &group)
void addEntryInMapNamedForModuleAndGroup(const std::string &entryKey, const std::string &entryValue, const std::string &mapName, const std::string &moduleName, const std::string &groupName)
void addMapNamedForModuleAndGroup(const std::string &mapName, const std::string &moduleName, const std::string &group)
void addGroupNamedForModuleNamed(const std::string &groupName, const std::string &moduleName)
void addItemInListNamedForModuleAndGroup(const std::string &item, const std::string &listName, const std::string &moduleName, const std::string &group)
void addParamValuePairForModuleAndGroup(const std::string ¶m, const std::string &value, const std::string &module, const std::string &group)
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