|
GammaLib 2.2.0.dev
|
XML document node class. More...
#include <GXmlDocument.hpp>
Public Member Functions | |
| GXmlDocument (void) | |
| Void constructor. | |
| GXmlDocument (const GFilename &filename, const std::string &version, const std::string &encoding, const std::string &standalone) | |
| Constructor. | |
| GXmlDocument (const GXmlDocument &node) | |
| Copy constructor. | |
| virtual | ~GXmlDocument (void) |
| Destructor. | |
| GXmlDocument & | operator= (const GXmlDocument &node) |
| Assignment operator. | |
| virtual void | clear (void) |
| Clear XML document. | |
| virtual GXmlDocument * | clone (void) const |
| Clone XML document. | |
| virtual std::string | classname (void) const |
| Return class name. | |
| virtual void | write (GUrl &url, const int &indent=0) const |
| Write XML document into URL. | |
| virtual NodeType | type (void) const |
| Return XML node type. | |
| virtual std::string | print (const GChatter &chatter=NORMAL, const int &indent=0) const |
| Print XML document. | |
| const GFilename & | filename (void) const |
| Return filename. | |
| std::string | version (void) const |
| Return version. | |
| std::string | encoding (void) const |
| Return encoding. | |
| std::string | standalone (void) const |
| Return standalone. | |
| void | filename (const GFilename &filename) |
| Set filename. | |
| void | version (const std::string &version) |
| Set version. | |
| void | encoding (const std::string &encoding) |
| Set encoding. | |
| void | standalone (const std::string &standalone) |
| Set standalone. | |
Public Member Functions inherited from GXmlNode | |
| GXmlNode (void) | |
| Void constructor. | |
| GXmlNode (const GXmlNode &node) | |
| Copy constructor. | |
| virtual | ~GXmlNode (void) |
| Destructor. | |
| GXmlNode & | operator= (const GXmlNode &node) |
| Assignment operator. | |
| GXmlNode * | operator[] (const int &index) |
| Return pointer to XML child node. | |
| const GXmlNode * | operator[] (const int &index) const |
| Return pointer to XML child node (const version) | |
| virtual int | size (void) const |
| Return number of child nodes. | |
| virtual bool | is_empty (void) const |
| Signals if node has no child nodes. | |
| virtual GXmlNode * | set (const int &index, const GXmlNode &node) |
| Set XML child node. | |
| virtual GXmlNode * | append (const GXmlNode &node) |
| Append XML child node. | |
| virtual GXmlElement * | append (const std::string &segment) |
| Append XML element child node. | |
| virtual GXmlNode * | insert (const int &index, const GXmlNode &node) |
| Insert XML child node. | |
| virtual void | remove (const int &index) |
| Remove XML child node. | |
| virtual void | reserve (const int &num) |
| Reserve space for child nodes. | |
| virtual void | extend (const GXmlNode &node) |
| Append all XML child nodes from another XML node. | |
| GXmlNode * | parent (void) const |
| Return parent XML node. | |
| void | parent (GXmlNode *parent) |
| Set parent of XML node. | |
| GFilename | filename (void) const |
| Return filename of XML file. | |
| virtual int | elements (void) const |
| Return number of GXMLElement children of node. | |
| virtual int | elements (const std::string &name) const |
| Return number of GXMLElement children with a given name. | |
| virtual GXmlElement * | element (const int &index) |
| Return pointer to GXMLElement child. | |
| virtual const GXmlElement * | element (const int &index) const |
| Return pointer to GXMLElement child (const variant) | |
| virtual GXmlElement * | element (const std::string &name) |
| Return pointer on child walking down a hierarchy of tags. | |
| virtual const GXmlElement * | element (const std::string &name) const |
| Return pointer on child walking down a hierarchy of tags (const version) | |
| virtual GXmlElement * | element (const std::string &name, const int &index) |
| Return pointer on GXMLElement child of a given name. | |
| virtual const GXmlElement * | element (const std::string &name, const int &index) const |
| Return pointer on GXMLElement child of a given name (const variant) | |
| virtual std::string | print (const GChatter &chatter=NORMAL) const |
| Print XML node in string. | |
Public Member Functions inherited from GContainer | |
| virtual | ~GContainer (void) |
| Destructor. | |
Public Member Functions inherited from GBase | |
| virtual | ~GBase (void) |
| Destructor. | |
Protected Member Functions | |
| void | init_members (void) |
| Initialise class members. | |
| void | copy_members (const GXmlDocument &node) |
| Copy class members. | |
| void | free_members (void) |
| Delete class members. | |
Protected Member Functions inherited from GXmlNode | |
| void | init_members (void) |
| Initialise class members. | |
| void | copy_members (const GXmlNode &node) |
| Copy class members. | |
| void | free_members (void) |
| Delete class members. | |
| int | extract_index (std::string &tag) const |
| Extract index from tag. | |
Protected Attributes | |
| GFilename | m_filename |
| Name of XML file. | |
| GXmlAttribute | m_version |
| XML version ("1.0", "1.1") | |
| GXmlAttribute | m_encoding |
| Encoding (e.g. "UTF-8") | |
| GXmlAttribute | m_standalone |
| Standalone ("yes", "no") | |
Protected Attributes inherited from GXmlNode | |
| GXmlNode * | m_parent |
| Pointer on parent node. | |
| std::vector< GXmlNode * > | m_nodes |
| Pointer to child nodes. | |
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 |
Set encoding.
| [in] | encoding | Encoding string. |
Definition at line 191 of file GXmlDocument.hpp.
References encoding(), m_encoding, and GXmlAttribute::value().
|
inline |
Return encoding.
Definition at line 141 of file GXmlDocument.hpp.
References m_encoding, and GXmlAttribute::value().
Referenced by encoding(), GXmlDocument(), print(), and GXml::process_markup().
|
inline |
Set filename.
| [in] | filename | Filename of XML document. |
Definition at line 165 of file GXmlDocument.hpp.
References filename(), and m_filename.
|
inline |
Return filename.
Definition at line 117 of file GXmlDocument.hpp.
References m_filename.
Referenced by filename(), GXmlNode::filename(), GXmlDocument(), and GXml::load().
|
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 GFilename::clear(), GXmlAttribute::clear(), m_encoding, m_filename, m_standalone, m_version, GXmlAttribute::name(), and GXmlAttribute::value().
Referenced by clear(), GXmlDocument(), GXmlDocument(), 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, print(), SILENT, standalone(), and version().
Referenced by GXml::print(), and print().
|
inline |
Set standalone.
| [in] | standalone | Standalone value string. |
Definition at line 204 of file GXmlDocument.hpp.
References m_standalone, standalone(), and GXmlAttribute::value().
|
inline |
Return standalone.
Definition at line 153 of file GXmlDocument.hpp.
References m_standalone, and GXmlAttribute::value().
Referenced by GXmlDocument(), print(), GXml::process_markup(), and standalone().
|
inlinevirtual |
Return XML node type.
Implements GXmlNode.
Definition at line 217 of file GXmlDocument.hpp.
References GXmlNode::NT_DOCUMENT.
|
inline |
Set version.
| [in] | version | Version string. |
Definition at line 178 of file GXmlDocument.hpp.
References m_version, GXmlAttribute::value(), and version().
|
inline |
Return version.
Definition at line 129 of file GXmlDocument.hpp.
References m_version, and GXmlAttribute::value().
Referenced by GXmlDocument(), print(), GXml::process_markup(), and version().
|
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(), encoding(), init_members(), and write().
|
protected |
Name of XML file.
Definition at line 92 of file GXmlDocument.hpp.
Referenced by copy_members(), filename(), filename(), and init_members().
|
protected |
Standalone ("yes", "no")
Definition at line 95 of file GXmlDocument.hpp.
Referenced by copy_members(), init_members(), standalone(), 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(), version(), and write().