21 #include <Base/Common/XMLBase.hh>
26 xmlNodePtr XMLBase::XMLAdd(
const xmlNodePtr Node,
XMLIO& XMLObject)
const {
30 XMLGetClassName(TopLevelName, Version);
35 XMLOut(theNode, XMLObject);
40 int XMLBase::XMLWrite(
const std::string& Filename,
42 bool AutoAddCompressionSuffix,
43 string encoding)
const
49 XMLGetClassName(TopLevelName, Version);
51 rootNode = myXML.
create(TopLevelName);
53 XMLOut(rootNode, myXML);
55 int res = myXML.
write(Filename, AutoAddCompressionSuffix);
61 int XMLBase::XMLWriteToString(
string &str,
string encoding)
const
67 XMLGetClassName(TopLevelName, Version);
69 rootNode = myXML.
create(TopLevelName);
71 XMLOut(rootNode, myXML);
78 int XMLBase::XMLRead(
const std::string& Filename)
85 XMLGetClassName(TopLevelName, Version);
86 rootNode = myXML.
read(Filename);
87 if (rootNode == NULL)
return -3;
90 BIASERR(
"Wrong XML file type (found " << TopLevelName <<
", expected "
96 BIASERR(
"Wrong XML file version (found "
98 <<
"), expected " << Version <<
")!");
104 thereturn = XMLIn(rootNode, myXML);
111 int XMLBase::XMLReadFromString(
const std::string& str)
118 XMLGetClassName(TopLevelName, Version);
121 BIASERR(
"Wrong XML file type (found " << TopLevelName <<
", expected "
127 BIASERR(
"Wrong XML file version (found "
129 <<
"), expected " << Version <<
")!");
132 }
else thereturn = XMLIn(rootNode, myXML);
void addAttribute(const xmlNodePtr Node, const std::string &AttributeName, bool AttributeValue)
Add an attribute to a node.
int write(const std::string &Filename, bool AutoAddCompressionSuffix=true) const
Write the whole tree that was constructed in memory to disk.
xmlNodePtr read(const std::string &Filename)
Read and parse an XML file from disk, DtD validation is not yet implemented.
xmlNodePtr create(const std::string &RootNodeName)
Create the base of a new XML-Tree in memory, already with a one and only root node.
Wrapper class for reading and writing XML files based on the XML library libxml2. ...
xmlNodePtr addChildNode(const xmlNodePtr ParentNode, const std::string &NewNodeName)
Add a child node to an incoming node with the given name.
void SetEncoding(const std::string &encoding)
int WriteToString(std::string &str)
serialize tree to string
xmlNodePtr ReadFromString(const std::string &str)
construct tree from string
double getAttributeValueDouble(const xmlAttrPtr Attribute) const
std::string getNodeName(const xmlNodePtr Node) const
Get the name of a given Node.
int SetCompression(int level=9)
set level of compression, needs zlib