DocType.h
1/*
2 * Copyright (C) 2012 by 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_DocType_h
30#define Pt_Xml_DocType_h
31
32#include <Pt/Xml/Api.h>
33#include <Pt/Xml/Node.h>
34#include <Pt/Xml/QName.h>
35#include <Pt/String.h>
36#include <Pt/Types.h>
37#include <Pt/NonCopyable.h>
38
39namespace Pt {
40
41namespace Xml {
42
44
52class PT_XML_API DocType : public Node
53 , private Pt::NonCopyable
54{
55 public:
58 explicit DocType(DocTypeDefinition& dtd);
59
63
66 void clear();
67
70 bool isExternal() const;
71
74 bool isInternal() const;
75
78 void setInternal(bool hasInternal);
79
82 const QName& rootName() const;
83
86 const Pt::String& publicId() const
87 { return _publicId; }
88
91 void setPublicId(const Pt::String& pubId)
92 { _publicId = pubId; }
93
96 const Pt::String& systemId() const
97 { return _systemId; }
98
101 void setSystemId(const Pt::String& sysId)
102 { _systemId = sysId; }
103
105 inline static Node::Type nodeId()
106 { return Node::DocType; }
107
108 private:
109 DocTypeDefinition* _dtd;
110 Pt::String _publicId;
111 Pt::String _systemId;
112 Pt::varint_t _internal;
113};
114
119inline DocType* toDocType(Node* node)
120{
121 return nodeCast<DocType>(node);
122}
123
128inline const DocType* toDocType(const Node* node)
129{
130 return nodeCast<DocType>(node);
131}
132
137inline DocType& toDocType(Node& node)
138{
139 return nodeCast<DocType>(node);
140}
141
146inline const DocType& toDocType(const Node& node)
147{
148 return nodeCast<DocType>(node);
149}
150
158class PT_XML_API EndDocType : public Node
159 , private Pt::NonCopyable
160{
161 public:
165
169
172 void clear();
173
176 bool isExternal() const;
177
180 bool isInternal() const;
181
184 void setInternal(bool value);
185
187 inline static Node::Type nodeId()
188 { return Node::EndDocType; }
189
190 private:
191 Pt::varint_t _internal;
192};
193
199{
200 return nodeCast<EndDocType>(node);
201}
202
207inline const EndDocType* toEndDocType(const Node* node)
208{
209 return nodeCast<EndDocType>(node);
210}
211
217{
218 return nodeCast<EndDocType>(node);
219}
220
225inline const EndDocType& toEndDocType(const Node& node)
226{
227 return nodeCast<EndDocType>(node);
228}
229
230} // namespace Xml
231
232} // namespace Pt
233
234#endif // Pt_Xml_DocType_h
Base class that disables copy construction and assignment.
Definition NonCopyable.h:59
Unicode capable basic_string.
Definition Api-String.h:67
The DocTypeDefinition of an XML document.
Definition DocTypeDefinition.h:58
const DocType & toDocType(const Node &node)
Casts a generic node to a DocType node.
Definition DocType.h:146
const Pt::String & systemId() const
Returns the system ID of the external subset.
Definition DocType.h:96
DocType & toDocType(Node &node)
Casts a generic node to a DocType node.
Definition DocType.h:137
bool isExternal() const
Returns true if the external DTD subset begins.
void setSystemId(const Pt::String &sysId)
Sets the system ID of the external subset.
Definition DocType.h:101
~DocType()
Destructor.
DocType * toDocType(Node *node)
Casts a generic node to a DocType node.
Definition DocType.h:119
const Pt::String & publicId() const
Returns the public ID of the external subset.
Definition DocType.h:86
void setPublicId(const Pt::String &pubId)
Sets the public ID of the external subset.
Definition DocType.h:91
const DocType * toDocType(const Node *node)
Casts a generic node to a DocType node.
Definition DocType.h:128
void setInternal(bool hasInternal)
Indicates the begin of internal or external DTD subsets.
const QName & rootName() const
Returns the documents root element name.
void clear()
Clears all content.
DocType(DocTypeDefinition &dtd)
Construct an empty DocType node.
bool isInternal() const
Returns true if the internal DTD subset begins.
void setInternal(bool value)
Indicates the end of internal or external DTD subsets.
bool isExternal() const
Returns true if the external DTD subset begins.
~EndDocType()
Destructor.
EndDocType & toEndDocType(Node &node)
Casts a generic node to a EndDocType node.
Definition DocType.h:216
const EndDocType * toEndDocType(const Node *node)
Casts a generic node to a EndDocType node.
Definition DocType.h:207
EndDocType * toEndDocType(Node *node)
Casts a generic node to a EndDocType node.
Definition DocType.h:198
void clear()
Clears all content.
EndDocType()
Construct an empty DocType node.
bool isInternal() const
Returns true if the internal DTD subset begins.
const EndDocType & toEndDocType(const Node &node)
Casts a generic node to a EndDocType node.
Definition DocType.h:225
Node(Type type)
Constructs a new Node object with the specified node type.
Definition Node.h:80
A qualified XML name.
Definition QName.h:47
Read and write XML ducuments.
Core module.
Definition Allocator.h:33