GammaLib 2.0.0
Loading...
Searching...
No Matches
GXmlDocument.hpp
Go to the documentation of this file.
1/***************************************************************************
2 * GXmlDocument.hpp - XML document node class definition *
3 * ----------------------------------------------------------------------- *
4 * copyright (C) 2010-2018 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 GXmlDocument.hpp
23 * @brief XML document node class interface definition
24 * @author Juergen Knodlseder
25 */
26
27#ifndef GXMLDOCUMENT_HPP
28#define GXMLDOCUMENT_HPP
29
30/* __ Includes ___________________________________________________________ */
31#include <string>
32#include "GUrl.hpp"
33#include "GFilename.hpp"
34#include "GXmlNode.hpp"
35#include "GXmlAttribute.hpp"
36
37
38/***********************************************************************//**
39 * @class GXmlDocument
40 *
41 * @brief XML document node class
42 *
43 * This class implements the root node of an XML document. The root node is
44 * a Processing Instruction which contains the following attributes:
45 * - @p version
46 * - @p encoding
47 * - @p standalone
48 *
49 * All three attributes are systematically written.
50 ***************************************************************************/
51class GXmlDocument : public GXmlNode {
52
53public:
54 // Constructors and destructors
55 GXmlDocument(void);
57 const std::string& version,
58 const std::string& encoding,
59 const std::string& standalone);
60 GXmlDocument(const GXmlDocument& node);
61 virtual ~GXmlDocument(void);
62
63 // Operators
65
66 // Implemented pure virtual base class methods
67 virtual void clear(void);
68 virtual GXmlDocument* clone(void) const;
69 virtual std::string classname(void) const;
70 virtual void write(GUrl& url, const int& indent = 0) const;
71 virtual NodeType type(void) const;
72 virtual std::string print(const GChatter& chatter = NORMAL,
73 const int& indent = 0) const;
74
75 // Methods
76 const GFilename& filename(void) const;
77 std::string version(void) const;
78 std::string encoding(void) const;
79 std::string standalone(void) const;
80 void filename(const GFilename& filename);
81 void version(const std::string& version);
82 void encoding(const std::string& encoding);
83 void standalone(const std::string& standalone);
84
85protected:
86 // Protected methods
87 void init_members(void);
88 void copy_members(const GXmlDocument& node);
89 void free_members(void);
90
91 // Protected data members
92 GFilename m_filename; //!< Name of XML file
93 GXmlAttribute m_version; //!< XML version ("1.0", "1.1")
94 GXmlAttribute m_encoding; //!< Encoding (e.g. "UTF-8")
95 GXmlAttribute m_standalone; //!< Standalone ("yes", "no")
96};
97
98
99/***********************************************************************//**
100 * @brief Return class name
101 *
102 * @return String containing the class name ("GXmlDocument").
103 ***************************************************************************/
104inline
105std::string GXmlDocument::classname(void) const
106{
107 return ("GXmlDocument");
108}
109
110
111/***********************************************************************//**
112 * @brief Return filename
113 *
114 * @return Filename of XML document.
115 ***************************************************************************/
116inline
118{
119 return (m_filename);
120}
121
122
123/***********************************************************************//**
124 * @brief Return version
125 *
126 * @return Version string.
127 ***************************************************************************/
128inline
129std::string GXmlDocument::version(void) const
130{
131 return (m_version.value());
132}
133
134
135/***********************************************************************//**
136 * @brief Return encoding
137 *
138 * @return Encoding string.
139 ***************************************************************************/
140inline
141std::string GXmlDocument::encoding(void) const
142{
143 return (m_encoding.value());
144}
145
146
147/***********************************************************************//**
148 * @brief Return standalone
149 *
150 * @return Standalone value string.
151 ***************************************************************************/
152inline
153std::string GXmlDocument::standalone(void) const
154{
155 return (m_standalone.value());
156}
157
158
159/***********************************************************************//**
160 * @brief Set filename
161 *
162 * @param[in] filename Filename of XML document.
163 ***************************************************************************/
164inline
166{
168 return;
169}
170
171
172/***********************************************************************//**
173 * @brief Set version
174 *
175 * @param[in] version Version string.
176 ***************************************************************************/
177inline
178void GXmlDocument::version(const std::string& version)
179{
181 return;
182}
183
184
185/***********************************************************************//**
186 * @brief Set encoding
187 *
188 * @param[in] encoding Encoding string.
189 ***************************************************************************/
190inline
191void GXmlDocument::encoding(const std::string& encoding)
192{
194 return;
195}
196
197
198/***********************************************************************//**
199 * @brief Set standalone
200 *
201 * @param[in] standalone Standalone value string.
202 ***************************************************************************/
203inline
204void GXmlDocument::standalone(const std::string& standalone)
205{
207 return;
208}
209
210
211/***********************************************************************//**
212 * @brief Return XML node type
213 *
214 * @return XML node type (NT_DOCUMENT).
215 ***************************************************************************/
216inline
218{
219 return (NT_DOCUMENT);
220}
221
222#endif /* GXMLDOCUMENT_HPP */
Filename class interface definition.
GChatter
Definition GTypemaps.hpp:33
@ NORMAL
Definition GTypemaps.hpp:36
Abstract URL base class interface definition.
XML attribute class interface definition.
Abstract XML node base class interface definition.
Filename class.
Definition GFilename.hpp:62
Abstract URL base class.
Definition GUrl.hpp:44
XML attribute class.
const std::string & value(void) const
Return attribute value.
XML document node class.
virtual NodeType type(void) const
Return XML node type.
GFilename m_filename
Name of XML file.
std::string encoding(void) const
Return encoding.
virtual void clear(void)
Clear XML document.
GXmlAttribute m_standalone
Standalone ("yes", "no")
void copy_members(const GXmlDocument &node)
Copy class members.
virtual ~GXmlDocument(void)
Destructor.
virtual std::string print(const GChatter &chatter=NORMAL, const int &indent=0) const
Print XML document.
GXmlAttribute m_encoding
Encoding (e.g. "UTF-8")
std::string version(void) const
Return version.
virtual GXmlDocument * clone(void) const
Clone XML document.
void free_members(void)
Delete class members.
virtual void write(GUrl &url, const int &indent=0) const
Write XML document into URL.
virtual std::string classname(void) const
Return class name.
std::string standalone(void) const
Return standalone.
const GFilename & filename(void) const
Return filename.
void init_members(void)
Initialise class members.
GXmlAttribute m_version
XML version ("1.0", "1.1")
GXmlDocument(void)
Void constructor.
GXmlDocument & operator=(const GXmlDocument &node)
Assignment operator.
Abstract XML node base class.
Definition GXmlNode.hpp:57
@ NT_DOCUMENT
Definition GXmlNode.hpp:72