GammaLib
2.1.0.dev
|
XML document node class. More...
#include <GXmlDocument.hpp>
Public Member Functions | |
GXmlDocument (void) | |
Void constructor. More... | |
GXmlDocument (const GFilename &filename, const std::string &version, const std::string &encoding, const std::string &standalone) | |
Constructor. More... | |
GXmlDocument (const GXmlDocument &node) | |
Copy constructor. More... | |
virtual | ~GXmlDocument (void) |
Destructor. More... | |
GXmlDocument & | operator= (const GXmlDocument &node) |
Assignment operator. More... | |
virtual void | clear (void) |
Clear XML document. More... | |
virtual GXmlDocument * | clone (void) const |
Clone XML document. More... | |
virtual std::string | classname (void) const |
Return class name. More... | |
virtual void | write (GUrl &url, const int &indent=0) const |
Write XML document into URL. More... | |
virtual NodeType | type (void) const |
Return XML node type. More... | |
virtual std::string | print (const GChatter &chatter=NORMAL, const int &indent=0) const |
Print XML document. More... | |
const GFilename & | filename (void) const |
Return filename. More... | |
std::string | version (void) const |
Return version. More... | |
std::string | encoding (void) const |
Return encoding. More... | |
std::string | standalone (void) const |
Return standalone. More... | |
void | filename (const GFilename &filename) |
Set filename. More... | |
void | version (const std::string &version) |
Set version. More... | |
void | encoding (const std::string &encoding) |
Set encoding. More... | |
void | standalone (const std::string &standalone) |
Set standalone. More... | |
Public Member Functions inherited from GXmlNode | |
GXmlNode (void) | |
Void constructor. More... | |
GXmlNode (const GXmlNode &node) | |
Copy constructor. More... | |
virtual | ~GXmlNode (void) |
Destructor. More... | |
GXmlNode & | operator= (const GXmlNode &node) |
Assignment operator. More... | |
GXmlNode * | operator[] (const int &index) |
Return pointer to XML child node. More... | |
const GXmlNode * | operator[] (const int &index) const |
Return pointer to XML child node (const version) More... | |
virtual int | size (void) const |
Return number of child nodes. More... | |
virtual bool | is_empty (void) const |
Signals if node has no child nodes. More... | |
virtual GXmlNode * | set (const int &index, const GXmlNode &node) |
Set XML child node. More... | |
virtual GXmlNode * | append (const GXmlNode &node) |
Append XML child node. More... | |
virtual GXmlElement * | append (const std::string &segment) |
Append XML element child node. More... | |
virtual GXmlNode * | insert (const int &index, const GXmlNode &node) |
Insert XML child node. More... | |
virtual void | remove (const int &index) |
Remove XML child node. More... | |
virtual void | reserve (const int &num) |
Reserve space for child nodes. More... | |
virtual void | extend (const GXmlNode &node) |
Append all XML child nodes from another XML node. More... | |
GXmlNode * | parent (void) const |
Return parent XML node. More... | |
void | parent (GXmlNode *parent) |
Set parent of XML node. More... | |
GFilename | filename (void) const |
Return filename of XML file. More... | |
virtual int | elements (void) const |
Return number of GXMLElement children of node. More... | |
virtual int | elements (const std::string &name) const |
Return number of GXMLElement children with a given name. More... | |
virtual GXmlElement * | element (const int &index) |
Return pointer to GXMLElement child. More... | |
virtual const GXmlElement * | element (const int &index) const |
Return pointer to GXMLElement child (const variant) More... | |
virtual GXmlElement * | element (const std::string &name) |
Return pointer on child walking down a hierarchy of tags. More... | |
virtual const GXmlElement * | element (const std::string &name) const |
Return pointer on child walking down a hierarchy of tags (const version) More... | |
virtual GXmlElement * | element (const std::string &name, const int &index) |
Return pointer on GXMLElement child of a given name. More... | |
virtual const GXmlElement * | element (const std::string &name, const int &index) const |
Return pointer on GXMLElement child of a given name (const variant) More... | |
virtual std::string | print (const GChatter &chatter=NORMAL) const |
Print XML node in string. More... | |
Public Member Functions inherited from GContainer | |
virtual | ~GContainer (void) |
Destructor. More... | |
Public Member Functions inherited from GBase | |
virtual | ~GBase (void) |
Destructor. More... | |
Protected Member Functions | |
void | init_members (void) |
Initialise class members. More... | |
void | copy_members (const GXmlDocument &node) |
Copy class members. More... | |
void | free_members (void) |
Delete class members. More... | |
Protected Member Functions inherited from GXmlNode | |
void | init_members (void) |
Initialise class members. More... | |
void | copy_members (const GXmlNode &node) |
Copy class members. More... | |
void | free_members (void) |
Delete class members. More... | |
int | extract_index (std::string &tag) const |
Extract index from tag. More... | |
Protected Attributes | |
GFilename | m_filename |
Name of XML file. More... | |
GXmlAttribute | m_version |
XML version ("1.0", "1.1") More... | |
GXmlAttribute | m_encoding |
Encoding (e.g. "UTF-8") More... | |
GXmlAttribute | m_standalone |
Standalone ("yes", "no") More... | |
Protected Attributes inherited from GXmlNode | |
GXmlNode * | m_parent |
Pointer on parent node. More... | |
std::vector< GXmlNode * > | m_nodes |
Pointer to child nodes. More... | |
Additional Inherited Members | |
Public Types inherited from GXmlNode | |
enum | NodeType { NT_DOCUMENT, NT_ELEMENT, NT_COMMENT, NT_UNKNOWN, NT_TEXT, NT_DECLARATION, NT_PI, NT_TYPECOUNT } |
XML document node class.
This class implements the root node of an XML document. The root node is a Processing Instruction which contains the following attributes:
version
encoding
standalone
All three attributes are systematically written.
Definition at line 51 of file GXmlDocument.hpp.
GXmlDocument::GXmlDocument | ( | void | ) |
Void constructor.
Definition at line 52 of file GXmlDocument.cpp.
References init_members().
Referenced by clone().
GXmlDocument::GXmlDocument | ( | const GFilename & | filename, |
const std::string & | version, | ||
const std::string & | encoding, | ||
const std::string & | standalone | ||
) |
Constructor.
[in] | filename | Filename. |
[in] | version | Version string. |
[in] | encoding | Encoding string. |
[in] | standalone | Standalone string. |
Definition at line 70 of file GXmlDocument.cpp.
References encoding(), filename(), init_members(), standalone(), and version().
GXmlDocument::GXmlDocument | ( | const GXmlDocument & | node | ) |
Copy constructor.
[in] | node | XML document. |
Definition at line 94 of file GXmlDocument.cpp.
References copy_members(), and init_members().
|
virtual |
|
inlinevirtual |
Return class name.
Implements GXmlNode.
Definition at line 105 of file GXmlDocument.hpp.
|
virtual |
Clear XML document.
Resets the XML document to a clean initial state.
Implements GXmlNode.
Definition at line 167 of file GXmlDocument.cpp.
References free_members(), GXmlNode::free_members(), init_members(), and GXmlNode::init_members().
Referenced by GXml::init_members().
|
virtual |
Clone XML document.
Implements GXmlNode.
Definition at line 187 of file GXmlDocument.cpp.
References GXmlDocument().
|
protected |
Copy class members.
[in] | node | Object from which members which should be copied. |
Definition at line 291 of file GXmlDocument.cpp.
References m_encoding, m_filename, m_standalone, and m_version.
Referenced by GXmlDocument(), and operator=().
|
inline |
Return encoding.
Definition at line 141 of file GXmlDocument.hpp.
References m_encoding, and GXmlAttribute::value().
Referenced by GXmlDocument(), print(), and GXml::process_markup().
|
inline |
Set encoding.
[in] | encoding | Encoding string. |
Definition at line 191 of file GXmlDocument.hpp.
References m_encoding, and GXmlAttribute::value().
|
inline |
Return filename.
Definition at line 117 of file GXmlDocument.hpp.
References m_filename.
Referenced by filename(), GXmlNode::filename(), GXmlDocument(), and GXml::load().
|
inline |
Set filename.
[in] | filename | Filename of XML document. |
Definition at line 165 of file GXmlDocument.hpp.
References filename(), and m_filename.
|
protected |
Delete class members.
Definition at line 307 of file GXmlDocument.cpp.
Referenced by clear(), operator=(), and ~GXmlDocument().
|
protected |
Initialise class members.
Definition at line 267 of file GXmlDocument.cpp.
References GXmlAttribute::clear(), GFilename::clear(), m_encoding, m_filename, m_standalone, m_version, GXmlAttribute::name(), and GXmlAttribute::value().
Referenced by clear(), GXmlDocument(), and operator=().
GXmlDocument & GXmlDocument::operator= | ( | const GXmlDocument & | node | ) |
Assignment operator.
[in] | node | XML document. |
Definition at line 132 of file GXmlDocument.cpp.
References copy_members(), free_members(), init_members(), and GXmlNode::operator=().
|
virtual |
Print XML document.
[in] | chatter | Chattiness (defaults to NORMAL). |
[in] | indent | Text indentation (default to 0). |
Implements GXmlNode.
Definition at line 228 of file GXmlDocument.cpp.
References encoding(), gammalib::fill(), GXmlNode::m_nodes, SILENT, standalone(), and version().
Referenced by GXml::print().
|
inline |
Return standalone.
Definition at line 153 of file GXmlDocument.hpp.
References m_standalone, and GXmlAttribute::value().
Referenced by GXmlDocument(), print(), and GXml::process_markup().
|
inline |
Set standalone.
[in] | standalone | Standalone value string. |
Definition at line 204 of file GXmlDocument.hpp.
References m_standalone, and GXmlAttribute::value().
|
inlinevirtual |
Return XML node type.
Implements GXmlNode.
Definition at line 217 of file GXmlDocument.hpp.
References GXmlNode::NT_DOCUMENT.
|
inline |
Return version.
Definition at line 129 of file GXmlDocument.hpp.
References m_version, and GXmlAttribute::value().
Referenced by GXmlDocument(), print(), and GXml::process_markup().
|
inline |
Set version.
[in] | version | Version string. |
Definition at line 178 of file GXmlDocument.hpp.
References m_version, and GXmlAttribute::value().
|
virtual |
Write XML document into URL.
[in] | url | Unified Resource Locator. |
[in] | indent | Text indentation (default = 0). |
Writes the XML document into a url
object.
Implements GXmlNode.
Definition at line 202 of file GXmlDocument.cpp.
References m_encoding, GXmlNode::m_nodes, m_standalone, m_version, GUrl::printf(), and GXmlAttribute::write().
Referenced by GXml::write().
|
protected |
Encoding (e.g. "UTF-8")
Definition at line 94 of file GXmlDocument.hpp.
Referenced by copy_members(), encoding(), init_members(), and write().
|
protected |
Name of XML file.
Definition at line 92 of file GXmlDocument.hpp.
Referenced by copy_members(), filename(), and init_members().
|
protected |
Standalone ("yes", "no")
Definition at line 95 of file GXmlDocument.hpp.
Referenced by copy_members(), init_members(), standalone(), and write().
|
protected |
XML version ("1.0", "1.1")
Definition at line 93 of file GXmlDocument.hpp.
Referenced by copy_members(), init_members(), version(), and write().