10#include <QXmlStreamReader>
23 std::map<std::string,Lima::LinguisticCode>& outputMap);
26 bool parse(QIODevice *device);
39 std::map<std::string,LinguisticCode>& outputMap) :
41 m_currentPropertyValues(),
42 m_outputMap(outputMap),
43 m_propCodeManager(pcm)
47 std::map<std::string,LinguisticCode>& outputMap) :
58 return m_d->
parse(device);
70 LDEBUG <<
"SymbolicCodeXmlReaderPrivate::parse";
72 if (
m_reader.readNextStartElement()) {
73 if (
m_reader.name() == QLatin1String(
"codes"))
79 m_reader.raiseError(QObject::tr(
"The file is not a LIMA XML symbolic codes file."));
93 Q_ASSERT(
m_reader.isStartElement() &&
m_reader.name() == QLatin1String(
"codes"));
95 while (
m_reader.readNextStartElement()) {
96 if (
m_reader.name() == QLatin1String(
"code"))
99 m_reader.raiseError(QObject::tr(
"Expected a code but got a %1.").arg(
m_reader.name()));
110 Q_ASSERT(
m_reader.isStartElement() &&
m_reader.name() == QLatin1String(
"code"));
115 while (
m_reader.readNextStartElement()) {
116 if (
m_reader.name() == QLatin1String(
"field"))
119 m_reader.raiseError(QObject::tr(
"Expected a field but got a %1.").arg(
m_reader.name()));
135 <<
m_reader.attributes().value(
"key")
136 <<
m_reader.attributes().value(
"value");
138 Q_ASSERT(
m_reader.isStartElement() &&
m_reader.name() == QLatin1String(
"field"));
139 auto key =
m_reader.attributes().value(
"key").toString();
140 auto value =
m_reader.attributes().value(
"value").toString();
151 auto errorStr = QObject::tr(
"%1, Line %2, column %3")
#define PROPERTYCODELOGINIT
#define LIMA_PROPERTYCODE_EXPORT
Provide tools to parse a property file, and deal with the property coding system.
LinguisticCode encode(const std::map< std::string, std::string > &propValues) const
Compute the code corresponding to given the properties/values.
SymbolicCodeXmlReaderPrivate(const Lima::Common::PropertyCode::PropertyCodeManager &pcm, std::map< std::string, Lima::LinguisticCode > &outputMap)
std::map< std::string, Lima::LinguisticCode > & m_outputMap
QXmlStreamReader m_reader
const Lima::Common::PropertyCode::PropertyCodeManager & m_propCodeManager
bool parse(QIODevice *device)
std::map< std::string, std::string > m_currentPropertyValues
~SymbolicCodeXmlReaderPrivate()=default
SymbolicCodeXmlReader(const Lima::Common::PropertyCode::PropertyCodeManager &pcm, std::map< std::string, Lima::LinguisticCode > &outputMap)
bool parse(QIODevice *device)
QString errorString() const