ProcessingInstruction.h
1 /*
2  * Copyright (C) 2012 Marc Boris Duerner
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * As a special exception, you may use this file as part of a free
10  * software library without restriction. Specifically, if other files
11  * instantiate templates or use macros or inline functions from this
12  * file, or you compile this file and link it with other files to
13  * produce an executable, this file does not by itself cause the
14  * resulting executable to be covered by the GNU General Public
15  * License. This exception does not however invalidate any other
16  * reasons why the executable file might be covered by the GNU Library
17  * General Public License.
18  *
19  * This library is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22  * Lesser General Public License for more details.
23  *
24  * You should have received a copy of the GNU Lesser General Public
25  * License along with this library; if not, write to the Free Software
26  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
27  */
28 
29 #ifndef Pt_Xml_ProcessingInstruction_h
30 #define Pt_Xml_ProcessingInstruction_h
31 
32 #include <Pt/Xml/Api.h>
33 #include <Pt/Xml/Node.h>
34 #include <Pt/String.h>
35 
36 namespace Pt {
37 
38 namespace Xml {
39 
47 class ProcessingInstruction : public Node
48 {
49  public:
54  { }
55 
58  void clear()
59  {
60  _target.clear();
61  _data.clear();
62  }
63 
66  const String& target() const
67  { return _target; }
68 
72  { return _target; }
73 
76  void setTarget(const String& target)
77  { _target = target; }
78 
81  const String& data() const
82  { return _data; }
83 
87  { return _data; }
88 
91  void setData(const String& data)
92  { _data = data; }
93 
95  inline static const Node::Type nodeId()
96  { return Node::ProcessingInstruction; }
97 
98  private:
99  String _target;
100  String _data;
101 };
102 
108 {
109  return nodeCast<ProcessingInstruction>(node);
110 }
111 
117 {
118  return nodeCast<ProcessingInstruction>(node);
119 }
120 
126 {
127  return nodeCast<ProcessingInstruction>(node);
128 }
129 
135 {
136  return nodeCast<ProcessingInstruction>(node);
137 }
138 
139 } // namespace Xml
140 
141 } // namespace Pt
142 
143 #endif // Pt_Xml_ProcessingInstruction_h
void clear()
Clears all content.
Definition: ProcessingInstruction.h:58
const ProcessingInstruction & toProcessingInstruction(const Node &node)
Casts a generic node to a ProcessingInstruction node.
Definition: ProcessingInstruction.h:134
A processing instruction of an XML document.
Definition: ProcessingInstruction.h:47
ProcessingInstruction & toProcessingInstruction(Node &node)
Casts a generic node to a ProcessingInstruction node.
Definition: ProcessingInstruction.h:125
void clear()
Clears the string.
Definition: String.h:367
ProcessingInstruction * toProcessingInstruction(Node *node)
Casts a generic node to a ProcessingInstruction node.
Definition: ProcessingInstruction.h:107
String & data()
Returns the data for the processing instruction.
Definition: ProcessingInstruction.h:86
void setTarget(const String &target)
Sets the target for the processing instruction.
Definition: ProcessingInstruction.h:76
const String & target() const
Returns the target for the processing instruction.
Definition: ProcessingInstruction.h:66
ProcessingInstruction()
Constructs an empty ProcessingInstruction.
Definition: ProcessingInstruction.h:52
Unicode capable basic_string.
Definition: String.h:42
String & target()
Returns the target for the processing instruction.
Definition: ProcessingInstruction.h:71
const ProcessingInstruction * toProcessingInstruction(const Node *node)
Casts a generic node to a ProcessingInstruction node.
Definition: ProcessingInstruction.h:116
XML document node.
Definition: Node.h:50
const String & data() const
Returns the data for the processing instruction.
Definition: ProcessingInstruction.h:81
void setData(const String &data)
Sets the data for the processing instruction.
Definition: ProcessingInstruction.h:91