GammaLib  2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GXmlComment Class Reference

XML comment node class. More...

#include <GXmlComment.hpp>

Inheritance diagram for GXmlComment:
GXmlNode GContainer GBase

Public Member Functions

 GXmlComment (void)
 Void constructor. More...
 
 GXmlComment (const GXmlComment &node)
 Copy constructor. More...
 
 GXmlComment (const std::string &segment)
 Segment constructor. More...
 
virtual ~GXmlComment (void)
 Destructor. More...
 
GXmlCommentoperator= (const GXmlComment &node)
 Assignment operator. More...
 
virtual void clear (void)
 Clear XML comment. More...
 
virtual GXmlCommentclone (void) const
 Clone XML comment. More...
 
virtual std::string classname (void) const
 Return class name. More...
 
virtual void write (GUrl &url, const int &indent=0) const
 Write comment 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 comment. More...
 
const std::string & comment (void) const
 Return comment. More...
 
void comment (const std::string &comment)
 Set comment. 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 GXmlComment &node)
 Copy class members. More...
 
void free_members (void)
 Delete class members. More...
 
void parse (const std::string &segment)
 Parse comment segment string. 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

std::string m_comment
 Comment (excluding brackets) 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 comment node class.

This class implements a XML comment. The comment text is stored without the brackets.

Definition at line 44 of file GXmlComment.hpp.

Constructor & Destructor Documentation

GXmlComment::GXmlComment ( void  )

Void constructor.

Definition at line 54 of file GXmlComment.cpp.

References init_members().

Referenced by clone().

GXmlComment::GXmlComment ( const GXmlComment node)

Copy constructor.

Parameters
[in]nodeXML comment.

Definition at line 69 of file GXmlComment.cpp.

References copy_members(), and init_members().

GXmlComment::GXmlComment ( const std::string &  segment)
explicit

Segment constructor.

Parameters
[in]segmentText segement.

Constructs a comment from the text given in segment.

Definition at line 89 of file GXmlComment.cpp.

References init_members(), and parse().

GXmlComment::~GXmlComment ( void  )
virtual

Destructor.

Definition at line 105 of file GXmlComment.cpp.

References free_members().

Member Function Documentation

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

Return class name.

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

Implements GXmlNode.

Definition at line 87 of file GXmlComment.hpp.

void GXmlComment::clear ( void  )
virtual

Clear XML comment.

Resets the XML comment to an clean initial state.

Implements GXmlNode.

Definition at line 162 of file GXmlComment.cpp.

References free_members(), GXmlNode::free_members(), init_members(), and GXmlNode::init_members().

GXmlComment * GXmlComment::clone ( void  ) const
virtual

Clone XML comment.

Returns
Pointer to deep copy of XML comment.

Implements GXmlNode.

Definition at line 182 of file GXmlComment.cpp.

References GXmlComment().

const std::string & GXmlComment::comment ( void  ) const
inline

Return comment.

Returns
Comment string.

Definition at line 99 of file GXmlComment.hpp.

References m_comment.

Referenced by comment().

void GXmlComment::comment ( const std::string &  comment)
inline

Set comment.

Parameters
[in]commentComment string.

Definition at line 111 of file GXmlComment.hpp.

References comment(), and m_comment.

void GXmlComment::copy_members ( const GXmlComment node)
protected

Copy class members.

Parameters
[in]nodeXML comment.

Definition at line 265 of file GXmlComment.cpp.

References m_comment.

Referenced by GXmlComment(), and operator=().

void GXmlComment::free_members ( void  )
protected

Delete class members.

Definition at line 278 of file GXmlComment.cpp.

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

void GXmlComment::init_members ( void  )
protected

Initialise class members.

Definition at line 250 of file GXmlComment.cpp.

References m_comment.

Referenced by clear(), GXmlComment(), and operator=().

GXmlComment & GXmlComment::operator= ( const GXmlComment node)

Assignment operator.

Parameters
[in]nodeXML comment.
Returns
XML comment.

Definition at line 127 of file GXmlComment.cpp.

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

void GXmlComment::parse ( const std::string &  segment)
protected

Parse comment segment string.

Parameters
[in]segmentSegment string.
Exceptions
GException::invalid_valueXML syntax error.

Parse the segment string and extract the comment.

Todo:
Check validity of characters in comment string

Definition at line 297 of file GXmlComment.cpp.

References G_PARSE, and m_comment.

Referenced by GXmlComment().

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

Print XML comment.

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

Implements GXmlNode.

Definition at line 219 of file GXmlComment.cpp.

References gammalib::fill(), m_comment, and SILENT.

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

Return XML node type.

Returns
XML node type (NT_COMMENT).

Implements GXmlNode.

Definition at line 124 of file GXmlComment.hpp.

References GXmlNode::NT_COMMENT.

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

Write comment into URL.

Parameters
[in]urlUnified Resource Locator.
[in]indentText indentation (default = 0).

Writes the XML comment into a url object.

Implements GXmlNode.

Definition at line 197 of file GXmlComment.cpp.

References m_comment, and GUrl::printf().

Member Data Documentation

std::string GXmlComment::m_comment
protected

Comment (excluding brackets)

Definition at line 77 of file GXmlComment.hpp.

Referenced by comment(), copy_members(), init_members(), parse(), print(), and write().


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