30 #include <libxml/tree.h>
31 #include <libxml/xpath.h>
32 #include <sys/types.h>
38 #define VICI_RELEASE "V0.1"
58 virtual char *
addr() = 0;
59 virtual int len() = 0;
60 virtual void addr(
char *) = 0;
61 virtual void len(
int) = 0;
140 void setProp( xmlNodePtr node,
csr prop,
int val );
149 void setProp( xmlNodePtr node,
csr prop,
double val );
227 xmlNodePtr
getChild( xmlNodePtr node,
csr name )
const;
235 int getChildren( xmlNodePtr node, std::vector< xmlNodePtr > & nodes )
const;
242 xmlNodePtr
newNode( xmlNodePtr node,
csr name );
267 int find(
csr xpath_expression, std::vector< xmlNodePtr > & nodes );
int find(csr xpath_expression, std::vector< xmlNodePtr > &nodes)
Find nodes matching an XPath.
Definition: xml.cpp:368
bool mDirty
true when an update has been made, and saving is required.
Definition: xml.h:118
Path mFilename
the XML file that the object represents
Definition: xml.h:80
void setDirty(bool dt)
Access to dirty flag if we change document outside of this interface.
Definition: xml.h:331
An abstract class defining a buffer object.
Definition: xml.h:54
static xmlNodePtr newTextChild(xmlNodePtr node, csr name, csr text)
Create a new node with text content.
Definition: xml.cpp:347
void setDtd(csr name, const Path &dtd)
Set DTD identifier to dtd, which is just the dtd file name.
Definition: xml.cpp:425
virtual char * addr()=0
Get the address of the data.
xmlNodePtr newNode(xmlNodePtr node, csr name)
Create a new node.
Definition: xml.cpp:336
bool dirty()
Check if the document has been modified.
Definition: xml.h:325
virtual ~XmlBuffer()
Ensure derived classes have a destructor.
Definition: xml.h:57
static bool xpathinit
flag to indicate if xpath has been initialized
Definition: xml.h:88
void unpack(XmlBuffer &)
Create a document from the content of a buffer.
Definition: xml.cpp:125
void registerNamespace(const std::string &prefix, csr uri)
Definition: xml.cpp:54
xmlNodePtr getChild(xmlNodePtr node, csr name) const
Get a child node by name.
Definition: xml.cpp:309
int mCompression
0 is uncompressed, thru 9 for max zlib compression
Definition: xml.h:121
void setProp(xmlNodePtr node, csr prop, csr val)
Set a string property.
Definition: xml.cpp:160
xmlXPathContextPtr mCtx
XML XPath context.
Definition: xml.h:87
void getPropInt(xmlNodePtr node, csr prop, int &val)
Get the property value as an integer.
Definition: xml.cpp:219
void getPropShort(xmlNodePtr node, csr prop, short &val)
Get the property value as a short integer.
Definition: xml.cpp:232
std::string getNodeContent(xmlNodePtr p, int expand=1) const
Get the content of the node.
Definition: xml.cpp:268
bool mIsOpen
true if the file is open
Definition: xml.h:119
xmlNodePtr getRoot()
Get the root node.
Definition: xml.cpp:300
void getPropString(xmlNodePtr node, csr prop, std::string &val)
Get the property value as a string.
Definition: xml.cpp:206
Manipulate path strings.
Definition: stringy.h:74
void getDtdIdentifiers(csr dtdName, std::string &publicId, std::string &systemId)
Get the public identifier for the DTD.
Definition: xml.cpp:493
void create(const Path &fname, csr root_element)
Create a new xml file and document.
Definition: xml.cpp:108
void deleteNode(xmlNodePtr node)
Delete a node and all of its children.
Definition: xml.cpp:356
virtual ~Xml()
Destructor.
Definition: xml.cpp:395
void reload()
Reload the XML file.
Definition: xml.cpp:604
virtual int len()=0
Get the length of the data.
void pack(XmlBuffer &)
Save the document into a buffer.
Definition: xml.cpp:566
void setContent(xmlNodePtr node, csr text)
Set the content for the node.
Definition: xml.cpp:189
void getPropDouble(xmlNodePtr node, csr prop, double &val)
Get the property value as a double.
Definition: xml.cpp:252
struct stat xmlStat
time the file was last accessed by us
Definition: xml.h:81
xmlDocPtr mDoc
pointer to the root document object
Definition: xml.h:82
void setCDATAContent(xmlNodePtr node, csr text)
Set the content for the node using CDATA.
Definition: xml.cpp:197
void open(const Path &fname)
Open an existing XML file.
Definition: xml.cpp:86
static const int UMASK_RW_RW_R
Default umask for xml files created.
Definition: xml.h:78
const std::string & csr
short cut for string constants
Definition: vici.h:80
void save()
Save the document.
Definition: xml.cpp:513
void freeDoc()
release the document from memory
Definition: xml.cpp:146
A C++ wrapper for libxml2.
Definition: xml.h:73
int getChildren(xmlNodePtr node, std::vector< xmlNodePtr > &nodes) const
Get the children of the node.
Definition: xml.cpp:322
std::string getNodeName(xmlNodePtr p) const
Get the name of the node.
Definition: xml.cpp:289
bool safeToSave()
Check if can save without clobbering other input.
Definition: xml.cpp:591
void setCompression(int rate)
Set the compression rate for saving the document.
Definition: xml.cpp:506
void createXPathContext()
Call this whenever mDoc is explicitly updated.
Definition: xml.cpp:41
Xml()
Constructor.
Definition: xml.cpp:66