52 #ifndef VDOMDOCUMENT_H
53 #define VDOMDOCUMENT_H
55 #include <QCoreApplication>
56 #include <QDomDocument>
57 #include <QDomElement>
60 #include <QLatin1String>
61 #include <QStaticStringData>
63 #include <QStringData>
64 #include <QStringDataPtr>
68 #include "../ifc/ifcdef.h"
69 #include "../vmisc/def.h"
70 #include "../vmisc/diagnostic.h"
71 #include "../vmisc/logging.h"
77 Q_DECLARE_LOGGING_CATEGORY(vXML)
80 QT_WARNING_DISABLE_GCC(
"-Weffc++")
81 QT_WARNING_DISABLE_GCC("-Wnon-virtual-dtor")
121 QDomElement elementById(quint32
id, const QString &tagName = QString());
123 template <typename T>
124 void SetAttribute(QDomElement &domElement, const QString &name, const T &value) const;
126 static quint32 GetParametrUInt(const QDomElement& domElement, const QString &name, const QString &defValue);
127 static
bool getParameterBool(const QDomElement& domElement, const QString &name, const QString &defValue);
129 static
NodeUsage GetParametrUsage(const QDomElement& domElement, const QString &name);
130 static
void SetParametrUsage(QDomElement& domElement, const QString &name, const
NodeUsage &value);
132 static QString GetParametrString(const QDomElement& domElement, const QString &name,
133 const QString &defValue = QString());
134 static QString GetParametrEmptyString(const QDomElement& domElement, const QString &name);
135 static qreal GetParametrDouble(const QDomElement& domElement, const QString &name, const QString &defValue);
136 static quint32 getParameterId(const QDomElement& domElement);
140 static
void ValidateXML(const QString &schema, const QString &fileName);
141 virtual
void setXMLContent(const QString &fileName);
142 static QString UnitsHelpString();
144 virtual
bool SaveDocument(const QString &fileName, QString &error);
145 QString Major() const;
146 QString Minor() const;
147 QString Patch() const;
148 static
void RemoveAllChildren(QDomElement &domElement);
150 QDomNode ParentNodeById(const quint32 &nodeId);
151 QDomElement CloneNodeById(const quint32 &nodeId);
152 QDomElement NodeById(const quint32 &nodeId);
154 static
bool SafeCopy(const QString &source, const QString &destination, QString &error);
160 bool setTagText(const QString &tag, const QString &text);
161 bool setTagText(const QDomElement &domElement, const QString &text);
162 QString UniqueTagText(const QString &tagName, const QString &defVal = QString()) const;
164 void TestUniqueId() const;
165 void CollectId(const QDomElement &node,
QVector<quint32> &vector)const;
172 bool find(const QDomElement &node, quint32
id);
174 bool SaveCanonicalXML(QIODevice *file,
int indent, QString &error) const;
178 template <typename T>
185 inline
void VDomDocument::SetAttribute(QDomElement &domElement, const QString &name, const T &value)
const
188 const QLocale locale = QLocale::c();
189 domElement.setAttribute(name, locale.toString(value).remove(locale.groupSeparator()));
194 inline void VDomDocument::SetAttribute<QString>(QDomElement &domElement,
const QString &name,
195 const QString &value)
const
197 domElement.setAttribute(name, value);
202 inline void VDomDocument::SetAttribute<bool>(QDomElement &domElement,
const QString &name,
const bool &value)
const
209 inline void VDomDocument::SetAttribute<MeasurementsType>(QDomElement &domElement,
const QString &name,
213 QStringLiteral(
"individual"));
The VDomDocument class represents a Seamly2D document (.val file).
static const QString AttrItalic
static const QString AttrBold
static const QString AttrAlignment
static const QString TagVersion
static const QString TagUnit
virtual ~VDomDocument() Q_DECL_EQ_DEFAULT
static const QString AttrId
static const QString TagLine
static const QString AttrText
static const QString AttrFSIncrement