GammaLib  2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GXmlComment.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GXmlComment.hpp - XML comment node class definition *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2010-2014 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 GXmlComment.hpp
23  * @brief XML comment node class interface definition
24  * @author Juergen Knodlseder
25  */
26 
27 #ifndef GXMLCOMMENT_HPP
28 #define GXMLCOMMENT_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include <string>
32 #include "GUrl.hpp"
33 #include "GXmlNode.hpp"
34 
35 
36 /***********************************************************************//**
37  * @class GXmlComment
38  *
39  * @brief XML comment node class
40  *
41  * This class implements a XML comment. The comment text is stored without
42  * the <!-- --> brackets.
43  ***************************************************************************/
44 class GXmlComment : public GXmlNode {
45 
46 public:
47  // Constructors and destructors
48  GXmlComment(void);
49  GXmlComment(const GXmlComment& node);
50  explicit GXmlComment(const std::string& segment);
51  virtual ~GXmlComment(void);
52 
53  // Operators
54  GXmlComment& operator=(const GXmlComment& node);
55 
56  // Implemented pure virtual base class methods
57  virtual void clear(void);
58  virtual GXmlComment* clone(void) const;
59  virtual std::string classname(void) const;
60  virtual void write(GUrl& url, const int& indent = 0) const;
61  virtual NodeType type(void) const;
62  virtual std::string print(const GChatter& chatter = NORMAL,
63  const int& indent = 0) const;
64 
65  // Other methods
66  const std::string& comment(void) const;
67  void comment(const std::string& comment);
68 
69 protected:
70  // Protected methods
71  void init_members(void);
72  void copy_members(const GXmlComment& node);
73  void free_members(void);
74  void parse(const std::string& segment);
75 
76  // Protected data members
77  std::string m_comment; //!< Comment (excluding brackets)
78 };
79 
80 
81 /***********************************************************************//**
82  * @brief Return class name
83  *
84  * @return String containing the class name ("GXmlComment").
85  ***************************************************************************/
86 inline
87 std::string GXmlComment::classname(void) const
88 {
89  return ("GXmlComment");
90 }
91 
92 
93 /***********************************************************************//**
94  * @brief Return comment
95  *
96  * @return Comment string.
97  ***************************************************************************/
98 inline
99 const std::string& GXmlComment::comment(void) const
100 {
101  return (m_comment);
102 }
103 
104 
105 /***********************************************************************//**
106  * @brief Set comment
107  *
108  * @param[in] comment Comment string.
109  ***************************************************************************/
110 inline
111 void GXmlComment::comment(const std::string& comment)
112 {
113  m_comment = comment;
114  return;
115 }
116 
117 
118 /***********************************************************************//**
119  * @brief Return XML node type
120  *
121  * @return XML node type (NT_COMMENT).
122  ***************************************************************************/
123 inline
125 {
126  return (NT_COMMENT);
127 }
128 
129 #endif /* GXMLCOMMENT_HPP */
Abstract XML node base class.
Definition: GXmlNode.hpp:57
virtual ~GXmlComment(void)
Destructor.
const std::string & comment(void) const
Return comment.
Definition: GXmlComment.hpp:99
void init_members(void)
Initialise class members.
virtual std::string print(const GChatter &chatter=NORMAL, const int &indent=0) const
Print XML comment.
virtual NodeType type(void) const
Return XML node type.
void copy_members(const GXmlComment &node)
Copy class members.
std::string m_comment
Comment (excluding brackets)
Definition: GXmlComment.hpp:77
void parse(const std::string &segment)
Parse comment segment string.
Abstract URL base class interface definition.
Abstract URL base class.
Definition: GUrl.hpp:44
virtual GXmlComment * clone(void) const
Clone XML comment.
GChatter
Definition: GTypemaps.hpp:33
GXmlComment & operator=(const GXmlComment &node)
Assignment operator.
virtual void write(GUrl &url, const int &indent=0) const
Write comment into URL.
GXmlComment(void)
Void constructor.
Definition: GXmlComment.cpp:54
void free_members(void)
Delete class members.
virtual std::string classname(void) const
Return class name.
Definition: GXmlComment.hpp:87
virtual void clear(void)
Clear XML comment.
XML comment node class.
Definition: GXmlComment.hpp:44
Abstract XML node base class interface definition.