OGS
XmlPrjInterface.h
Go to the documentation of this file.
1
11#pragma once
12
13#include <QString>
14#include <QtXml/QDomNode>
15#include <memory>
16#include <string>
17#include <vector>
18
22#include "BaseLib/IO/Writer.h"
24
25namespace FileIO
26{
32{
33public:
34 explicit XmlPrjInterface(DataHolderLib::Project& project);
35
36 ~XmlPrjInterface() override = default;
37
39 int readFile(const QString& fileName) override;
40
42 bool readFile(std::string const& fname)
43 {
44 return readFile(QString(fname.c_str())) != 0;
45 }
46
48 int writeToFile(const std::string& filename);
49
50protected:
51 bool write() override;
52
53private:
55 QDomNode findParam(QDomNode const& param_root,
56 QString const& param_name) const;
57
59 void readConditions(QDomNode const& pvar_root, QDomNode const& param_root);
60
62 void readBoundaryConditions(QDomNode const& bc_root,
63 QDomNode const& param_root,
65
67 void readSourceTerms(QDomNode const& st_root, QDomNode const& param_root,
69
71 void writeProcessVariables(QDomDocument& doc, QDomElement& root) const;
72
74 std::vector<DataHolderLib::ProcessVariable> getPrimaryVariableVec() const;
75
77 template <typename T>
78 void writeCondition(QDomDocument& doc, QDomElement& tag,
79 DataHolderLib::FemCondition const& cond) const;
80
82 void writeBoundaryConditions(QDomDocument& doc, QDomElement& bc_list_tag,
83 std::string const& name) const;
84
86 void writeSourceTerms(QDomDocument& doc, QDomElement& st_list_tag,
87 std::string const& name) const;
88
90 template <typename T>
91 T* parseCondition(QDomNode const& node, QDomNode const& param_root,
92 DataHolderLib::ProcessVariable const& pvar) const;
93
94 std::string _filename;
96};
97
98} // end namespace FileIO
Definition of the Writer class.
Base class which enables writing an object to string, stringstream or file.
Definition: Writer.h:31
Base class for boundary conditions, initial conditions and source terms.
Definition: FemCondition.h:40
void readBoundaryConditions(QDomNode const &bc_root, QDomNode const &param_root, DataHolderLib::ProcessVariable const &pvar)
Reading all boundary conditions.
T * parseCondition(QDomNode const &node, QDomNode const &param_root, DataHolderLib::ProcessVariable const &pvar) const
Parsing one specific condition.
int writeToFile(const std::string &filename)
Writes a project to the specified file.
std::vector< DataHolderLib::ProcessVariable > getPrimaryVariableVec() const
Compiles a vector of all existing primary variables for writing purposes.
bool write() override
Writes the object to the internal stream. This method must be implemented by a subclass....
void writeSourceTerms(QDomDocument &doc, QDomElement &st_list_tag, std::string const &name) const
Writes a list of source terms.
void readSourceTerms(QDomNode const &st_root, QDomNode const &param_root, DataHolderLib::ProcessVariable const &pvar)
Reading all source terms.
int readFile(const QString &fileName) override
Reads an xml-file containing a project.
void writeProcessVariables(QDomDocument &doc, QDomElement &root) const
Writes information on process variables.
~XmlPrjInterface() override=default
DataHolderLib::Project & _project
void writeCondition(QDomDocument &doc, QDomElement &tag, DataHolderLib::FemCondition const &cond) const
Writes one specific condition.
void writeBoundaryConditions(QDomDocument &doc, QDomElement &bc_list_tag, std::string const &name) const
Writes a list of boundary conditions.
XmlPrjInterface(DataHolderLib::Project &project)
void readConditions(QDomNode const &pvar_root, QDomNode const &param_root)
Manages reading all kinds of conditions.
QDomNode findParam(QDomNode const &param_root, QString const &param_name) const
Tests if a given parameter exists within the file.
bool readFile(std::string const &fname)
Reads an xml-file containing a project.