mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 12:40:35 +01:00
Add pugi_xml test branch
This commit is contained in:
@@ -132,6 +132,39 @@ void NamesList::fromXml(const QDomElement &xml_element, const QHash<QString, QSt
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief NamesList::fromXml
|
||||
* Load the list of lang <-> name from an xml description.
|
||||
* @xml_element must be the parent of a child element tagged "names"
|
||||
* If a couple lang <-> name already exist, they will overwrited, else
|
||||
* they will be appened.
|
||||
* @param xml_element : xml element to analyze
|
||||
* @param xml_options : A set of options related to XML parsing.
|
||||
* @see getXmlOptions()
|
||||
*/
|
||||
void NamesList::fromXml(const pugi::xml_node &xml_element, const QHash<QString, QString> &xml_options)
|
||||
{
|
||||
QHash<QString, QString> xml_opt = getXmlOptions(xml_options);
|
||||
|
||||
//Walk the childs "names" of the xml element
|
||||
for (auto names = xml_element.first_child() ; names ; names = names.next_sibling())
|
||||
{
|
||||
if (names.type() != pugi::node_element ||
|
||||
QString(names.name()) != xml_opt["ParentTagName"]) {
|
||||
continue;
|
||||
}
|
||||
for (auto name = names.first_child(); name; name = name.next_sibling()) {
|
||||
if (name.type() != pugi::node_element ||
|
||||
QString(name.name()) != xml_opt["TagName"]) {
|
||||
continue;
|
||||
}
|
||||
QString lang_str(name.attribute(xml_opt["LanguageAttribute"].toStdString().c_str()).as_string());
|
||||
QString name_str(name.text().get());
|
||||
addName(lang_str, name_str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Exporte la liste des noms vers un element XML. Veillez a verifier que la
|
||||
liste de noms n'est pas vide avant de l'exporter.
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#ifndef NAMES_LIST_H
|
||||
#define NAMES_LIST_H
|
||||
#include <QtXml>
|
||||
#include "pugixml.hpp"
|
||||
/**
|
||||
Cette classe represente une liste de noms, utilisee
|
||||
par les elements et categories pour embarquer un meme nom en plusieurs
|
||||
@@ -57,6 +58,7 @@ class NamesList {
|
||||
|
||||
// methods relatives a XML
|
||||
void fromXml(const QDomElement &, const QHash<QString, QString> & = QHash<QString, QString>());
|
||||
void fromXml(const pugi::xml_node &xml_element, const QHash<QString, QString> &xml_options = QHash<QString, QString>());
|
||||
QDomElement toXml(QDomDocument &, const QHash<QString, QString> & = QHash<QString, QString>()) const;
|
||||
|
||||
protected:
|
||||
|
||||
Reference in New Issue
Block a user