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