GammaLib  2.1.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GXmlDocument Class Reference

XML document node class. More...

#include <GXmlDocument.hpp>

Inheritance diagram for GXmlDocument:
GXmlNode GContainer GBase

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...
 
GXmlDocumentoperator= (const GXmlDocument &node)
 Assignment operator. More...
 
virtual void clear (void)
 Clear XML document. More...
 
virtual GXmlDocumentclone (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 GFilenamefilename (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...
 
GXmlNodeoperator= (const GXmlNode &node)
 Assignment operator. More...
 
GXmlNodeoperator[] (const int &index)
 Return pointer to XML child node. More...
 
const GXmlNodeoperator[] (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 GXmlNodeset (const int &index, const GXmlNode &node)
 Set XML child node. More...
 
virtual GXmlNodeappend (const GXmlNode &node)
 Append XML child node. More...
 
virtual GXmlElementappend (const std::string &segment)
 Append XML element child node. More...
 
virtual GXmlNodeinsert (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...
 
GXmlNodeparent (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 GXmlElementelement (const int &index)
 Return pointer to GXMLElement child. More...
 
virtual const GXmlElementelement (const int &index) const
 Return pointer to GXMLElement child (const variant) More...
 
virtual GXmlElementelement (const std::string &name)
 Return pointer on child walking down a hierarchy of tags. More...
 
virtual const GXmlElementelement (const std::string &name) const
 Return pointer on child walking down a hierarchy of tags (const version) More...
 
virtual GXmlElementelement (const std::string &name, const int &index)
 Return pointer on GXMLElement child of a given name. More...
 
virtual const GXmlElementelement (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
GXmlNodem_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
}
 

Detailed Description

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.

Constructor & Destructor Documentation

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.

Parameters
[in]filenameFilename.
[in]versionVersion string.
[in]encodingEncoding string.
[in]standaloneStandalone string.

Definition at line 70 of file GXmlDocument.cpp.

References encoding(), filename(), init_members(), standalone(), and version().

GXmlDocument::GXmlDocument ( const GXmlDocument node)

Copy constructor.

Parameters
[in]nodeXML document.

Definition at line 94 of file GXmlDocument.cpp.

References copy_members(), and init_members().

GXmlDocument::~GXmlDocument ( void  )
virtual

Destructor.

Definition at line 110 of file GXmlDocument.cpp.

References free_members().

Member Function Documentation

std::string GXmlDocument::classname ( void  ) const
inlinevirtual

Return class name.

Returns
String containing the class name ("GXmlDocument").

Implements GXmlNode.

Definition at line 105 of file GXmlDocument.hpp.

void GXmlDocument::clear ( void  )
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().

GXmlDocument * GXmlDocument::clone ( void  ) const
virtual

Clone XML document.

Returns
Pointer to deep copy of XML document.

Implements GXmlNode.

Definition at line 187 of file GXmlDocument.cpp.

References GXmlDocument().

void GXmlDocument::copy_members ( const GXmlDocument node)
protected

Copy class members.

Parameters
[in]nodeObject 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=().

std::string GXmlDocument::encoding ( void  ) const
inline

Return encoding.

Returns
Encoding string.

Definition at line 141 of file GXmlDocument.hpp.

References m_encoding, and GXmlAttribute::value().

Referenced by GXmlDocument(), print(), and GXml::process_markup().

void GXmlDocument::encoding ( const std::string &  encoding)
inline

Set encoding.

Parameters
[in]encodingEncoding string.

Definition at line 191 of file GXmlDocument.hpp.

References m_encoding, and GXmlAttribute::value().

const GFilename & GXmlDocument::filename ( void  ) const
inline

Return filename.

Returns
Filename of XML document.

Definition at line 117 of file GXmlDocument.hpp.

References m_filename.

Referenced by filename(), GXmlNode::filename(), GXmlDocument(), and GXml::load().

void GXmlDocument::filename ( const GFilename filename)
inline

Set filename.

Parameters
[in]filenameFilename of XML document.

Definition at line 165 of file GXmlDocument.hpp.

References filename(), and m_filename.

void GXmlDocument::free_members ( void  )
protected

Delete class members.

Definition at line 307 of file GXmlDocument.cpp.

Referenced by clear(), operator=(), and ~GXmlDocument().

void GXmlDocument::init_members ( void  )
protected
GXmlDocument & GXmlDocument::operator= ( const GXmlDocument node)

Assignment operator.

Parameters
[in]nodeXML document.
Returns
XML document.

Definition at line 132 of file GXmlDocument.cpp.

References copy_members(), free_members(), init_members(), and GXmlNode::operator=().

std::string GXmlDocument::print ( const GChatter chatter = NORMAL,
const int &  indent = 0 
) const
virtual

Print XML document.

Parameters
[in]chatterChattiness (defaults to NORMAL).
[in]indentText indentation (default to 0).
Returns
String containing XML document.

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().

std::string GXmlDocument::standalone ( void  ) const
inline

Return standalone.

Returns
Standalone value string.

Definition at line 153 of file GXmlDocument.hpp.

References m_standalone, and GXmlAttribute::value().

Referenced by GXmlDocument(), print(), and GXml::process_markup().

void GXmlDocument::standalone ( const std::string &  standalone)
inline

Set standalone.

Parameters
[in]standaloneStandalone value string.

Definition at line 204 of file GXmlDocument.hpp.

References m_standalone, and GXmlAttribute::value().

GXmlNode::NodeType GXmlDocument::type ( void  ) const
inlinevirtual

Return XML node type.

Returns
XML node type (NT_DOCUMENT).

Implements GXmlNode.

Definition at line 217 of file GXmlDocument.hpp.

References GXmlNode::NT_DOCUMENT.

std::string GXmlDocument::version ( void  ) const
inline

Return version.

Returns
Version string.

Definition at line 129 of file GXmlDocument.hpp.

References m_version, and GXmlAttribute::value().

Referenced by GXmlDocument(), print(), and GXml::process_markup().

void GXmlDocument::version ( const std::string &  version)
inline

Set version.

Parameters
[in]versionVersion string.

Definition at line 178 of file GXmlDocument.hpp.

References m_version, and GXmlAttribute::value().

void GXmlDocument::write ( GUrl url,
const int &  indent = 0 
) const
virtual

Write XML document into URL.

Parameters
[in]urlUnified Resource Locator.
[in]indentText 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().

Member Data Documentation

GXmlAttribute GXmlDocument::m_encoding
protected

Encoding (e.g. "UTF-8")

Definition at line 94 of file GXmlDocument.hpp.

Referenced by copy_members(), encoding(), init_members(), and write().

GFilename GXmlDocument::m_filename
protected

Name of XML file.

Definition at line 92 of file GXmlDocument.hpp.

Referenced by copy_members(), filename(), and init_members().

GXmlAttribute GXmlDocument::m_standalone
protected

Standalone ("yes", "no")

Definition at line 95 of file GXmlDocument.hpp.

Referenced by copy_members(), init_members(), standalone(), and write().

GXmlAttribute GXmlDocument::m_version
protected

XML version ("1.0", "1.1")

Definition at line 93 of file GXmlDocument.hpp.

Referenced by copy_members(), init_members(), version(), and write().


The documentation for this class was generated from the following files: