GammaLib  2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GXmlText.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GXmlText.hpp - XML text node class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2010-2015 by Juergen Knoedlseder *
5  * ----------------------------------------------------------------------- *
6  * *
7  * This program is free software: you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation, either version 3 of the License, or *
10  * (at your option) any later version. *
11  * *
12  * This program is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU General Public License *
18  * along with this program. If not, see <http://www.gnu.org/licenses/>. *
19  * *
20  ***************************************************************************/
21 /**
22  * @file GXmlText.hpp
23  * @brief XML text node class interface definition
24  * @author Juergen Knoedlseder
25  */
26 
27 #ifndef GXMLTEXT_HPP
28 #define GXMLTEXT_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include <string>
32 #include "GUrl.hpp"
33 #include "GXmlNode.hpp"
34 
35 
36 /***********************************************************************//**
37  * @class GXmlText
38  *
39  * @brief XML text node class
40  *
41  * This class implements a text segment of a XML document.
42  ***************************************************************************/
43 class GXmlText : public GXmlNode {
44 
45 public:
46  // Constructors and destructors
47  GXmlText(void);
48  GXmlText(const GXmlText& node);
49  explicit GXmlText(const std::string& text);
50  virtual ~GXmlText(void);
51 
52  // Operators
53  GXmlText& operator=(const GXmlText& node);
54 
55  // Implemented pure virtual base class methods
56  virtual void clear(void);
57  virtual GXmlText* clone(void) const;
58  virtual std::string classname(void) const;
59  virtual void write(GUrl& url, const int& indent = 0) const;
60  virtual NodeType type(void) const;
61  virtual std::string print(const GChatter& chatter = NORMAL,
62  const int& indent = 0) const;
63 
64  // Other methods
65  const std::string& text(void) const;
66  void text(const std::string& text);
67 
68 protected:
69  // Protected methods
70  void init_members(void);
71  void copy_members(const GXmlText& node);
72  void free_members(void);
73 
74  // Protected data members
75  std::string m_text; //!< Text
76 };
77 
78 
79 /***********************************************************************//**
80  * @brief Return class name
81  *
82  * @return String containing the class name ("GXmlText").
83  ***************************************************************************/
84 inline
85 std::string GXmlText::classname(void) const
86 {
87  return ("GXmlText");
88 }
89 
90 
91 /***********************************************************************//**
92  * @brief Return text
93  *
94  * @return Text string.
95  ***************************************************************************/
96 inline
97 const std::string& GXmlText::text(void) const
98 {
99  return (m_text);
100 }
101 
102 
103 /***********************************************************************//**
104  * @brief Set text
105  *
106  * @param[in] text Text string.
107  ***************************************************************************/
108 inline
109 void GXmlText::text(const std::string& text)
110 {
111  m_text = text;
112  return;
113 }
114 
115 
116 /***********************************************************************//**
117  * @brief Return XML node type
118  *
119  * @return XML node type (NT_TEXT).
120  ***************************************************************************/
121 inline
123 {
124  return (NT_TEXT);
125 }
126 
127 #endif /* GXMLTEXT_HPP */
Abstract XML node base class.
Definition: GXmlNode.hpp:57
virtual void clear(void)
Clear XML text.
Definition: GXmlText.cpp:161
virtual std::string print(const GChatter &chatter=NORMAL, const int &indent=0) const
Print XML text.
Definition: GXmlText.cpp:214
void init_members(void)
Initialise class members.
Definition: GXmlText.cpp:245
virtual ~GXmlText(void)
Destructor.
Definition: GXmlText.cpp:104
std::string m_text
Text.
Definition: GXmlText.hpp:75
virtual std::string classname(void) const
Return class name.
Definition: GXmlText.hpp:85
void free_members(void)
Delete class members.
Definition: GXmlText.cpp:273
Abstract URL base class interface definition.
Abstract URL base class.
Definition: GUrl.hpp:44
GXmlText & operator=(const GXmlText &node)
Assignment operator.
Definition: GXmlText.cpp:126
XML text node class.
Definition: GXmlText.hpp:43
virtual GXmlText * clone(void) const
Clone XML text.
Definition: GXmlText.cpp:181
const std::string & text(void) const
Return text.
Definition: GXmlText.hpp:97
GChatter
Definition: GTypemaps.hpp:33
GXmlText(void)
Void constructor.
Definition: GXmlText.cpp:52
virtual NodeType type(void) const
Return XML node type.
Definition: GXmlText.hpp:122
void copy_members(const GXmlText &node)
Copy class members.
Definition: GXmlText.cpp:260
virtual void write(GUrl &url, const int &indent=0) const
Write XML text into URL.
Definition: GXmlText.cpp:197
Abstract XML node base class interface definition.