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

XML text node class. More...

#include <GXmlText.hpp>

Inheritance diagram for GXmlText:
GXmlNode GContainer GBase

Public Member Functions

 GXmlText (void)
 Void constructor. More...
 
 GXmlText (const GXmlText &node)
 Copy constructor. More...
 
 GXmlText (const std::string &text)
 Text constructor. More...
 
virtual ~GXmlText (void)
 Destructor. More...
 
GXmlTextoperator= (const GXmlText &node)
 Assignment operator. More...
 
virtual void clear (void)
 Clear XML text. More...
 
virtual GXmlTextclone (void) const
 Clone XML text. More...
 
virtual std::string classname (void) const
 Return class name. More...
 
virtual void write (GUrl &url, const int &indent=0) const
 Write XML text 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 text. More...
 
const std::string & text (void) const
 Return text. More...
 
void text (const std::string &text)
 Set text. 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 GXmlText &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

std::string m_text
 Text. 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 text node class.

This class implements a text segment of a XML document.

Definition at line 43 of file GXmlText.hpp.

Constructor & Destructor Documentation

GXmlText::GXmlText ( void  )

Void constructor.

Definition at line 52 of file GXmlText.cpp.

References init_members().

Referenced by clone().

GXmlText::GXmlText ( const GXmlText node)

Copy constructor.

Parameters
[in]nodeXML text.

Definition at line 67 of file GXmlText.cpp.

References copy_members(), and init_members().

GXmlText::GXmlText ( const std::string &  text)
explicit

Text constructor.

Parameters
[in]textText string.

Construct object by attributing a text string. Predefined entities (e.g. ") are automatically converted into normal characters.

Definition at line 88 of file GXmlText.cpp.

References init_members(), m_text, and gammalib::xml2str().

GXmlText::~GXmlText ( void  )
virtual

Destructor.

Definition at line 104 of file GXmlText.cpp.

References free_members().

Member Function Documentation

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

Return class name.

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

Implements GXmlNode.

Definition at line 85 of file GXmlText.hpp.

void GXmlText::clear ( void  )
virtual

Clear XML text.

Resets the XML text to a clean initial state.

Implements GXmlNode.

Definition at line 161 of file GXmlText.cpp.

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

GXmlText * GXmlText::clone ( void  ) const
virtual

Clone XML text.

Returns
Pointer to deep copy of XML text.

Implements GXmlNode.

Definition at line 181 of file GXmlText.cpp.

References GXmlText().

void GXmlText::copy_members ( const GXmlText node)
protected

Copy class members.

Parameters
[in]nodeXML text.

Definition at line 260 of file GXmlText.cpp.

References m_text.

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

void GXmlText::free_members ( void  )
protected

Delete class members.

Definition at line 273 of file GXmlText.cpp.

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

void GXmlText::init_members ( void  )
protected

Initialise class members.

Definition at line 245 of file GXmlText.cpp.

References m_text.

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

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

Assignment operator.

Parameters
[in]nodeXML text.
Returns
XML text.

Definition at line 126 of file GXmlText.cpp.

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

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

Print XML text.

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

Implements GXmlNode.

Definition at line 214 of file GXmlText.cpp.

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

const std::string & GXmlText::text ( void  ) const
inline
void GXmlText::text ( const std::string &  text)
inline

Set text.

Parameters
[in]textText string.

Definition at line 109 of file GXmlText.hpp.

References m_text, and text().

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

Return XML node type.

Returns
XML node type (NT_TEXT).

Implements GXmlNode.

Definition at line 122 of file GXmlText.hpp.

References GXmlNode::NT_TEXT.

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

Write XML text into URL.

Parameters
[in]urlUnified Resource Locator.
[in]indentText indentation (parameter ignored).

Writes the text into the URL. Special characters are automatically transformed into predefined entities (e.g. ").

Implements GXmlNode.

Definition at line 197 of file GXmlText.cpp.

References m_text, GUrl::printf(), and gammalib::str2xml().

Member Data Documentation

std::string GXmlText::m_text
protected

Text.

Definition at line 75 of file GXmlText.hpp.

Referenced by copy_members(), GXmlText(), init_members(), print(), text(), and write().


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