40 #ifndef __OPENFLUID_THIRDPARTY_XML_HPP__
41 #define __OPENFLUID_THIRDPARTY_XML_HPP__
46 #include <openfluid/thirdparty/tinyxml2-9.0.0/tinyxml2.h>
49 namespace openfluid {
namespace thirdparty {
55 namespace xml = tinyxml2;
58 inline std::string
getXMLAttribute(
const xml::XMLElement*
const Elt,
const std::string& AttrName,
59 const std::string& DefaultValue =
"")
61 if (Elt !=
nullptr && Elt->Attribute(AttrName.c_str()) !=
nullptr)
63 return std::string(Elt->Attribute(AttrName.c_str()));
73 inline std::string
getXMLText(
const xml::XMLElement*
const Elt,
const std::string& DefaultValue =
"")
75 if (Elt !=
nullptr && Elt->GetText() !=
nullptr)
77 return std::string(Elt->GetText());
98 const std::string& FormatVersion)
100 auto Decl = Doc.NewDeclaration();
101 Doc.InsertFirstChild(Decl);
102 auto OFElt = Doc.NewElement(
"openfluid");
103 OFElt->SetAttribute(
"format",FormatVersion.c_str());
104 Doc.InsertEndChild(OFElt);
std::string getOpenFLUIDXMLFormat(const xml::XMLElement *const Elt)
Definition: XML.hpp:87
std::string getXMLAttribute(const xml::XMLElement *const Elt, const std::string &AttrName, const std::string &DefaultValue="")
Definition: XML.hpp:58
openfluid::thirdparty::xml::XMLElement * prepareOpenFLUIDXMLDoc(xml::XMLDocument &Doc, const std::string &FormatVersion)
Definition: XML.hpp:97
std::string getXMLText(const xml::XMLElement *const Elt, const std::string &DefaultValue="")
Definition: XML.hpp:73
Definition: ApplicationException.hpp:47