DocTypeDefinition.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_DocTypeDefinition_h
30#define Pt_Xml_DocTypeDefinition_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#include <vector>
39
40namespace Pt {
41
42namespace Xml {
43
44class ElementModel;
45class ContentModel;
46class AttributeListModel;
47class Entity;
48class Notation;
49
51
57class PT_XML_API DocTypeDefinition : private NonCopyable
58{
59 public:
63
67
70 void clear();
71
74 bool isDefined() const;
75
78 const QName& rootName() const;
79
83
86
88 const Entity* findEntity(const Pt::String& name) const;
89
91 void removeEntity(const Pt::String& name);
92
95
97 const Entity* findParamEntity(const Pt::String& name) const;
98
100 void removeParamEntity(const Pt::String& name);
101
104
106 const Notation* findNotation(const Pt::String& name) const;
107
109 void removeNotation(const Pt::String& name);
110
111 public:
113 ContentModel& declareContent(const QName& name);
114
116 AttributeListModel& declareAttributeList(const QName& name);
117
119 ElementModel* findElement(const QName& name);
120
122 AttributeListModel* findAttributes(const QName& name);
123
124 private:
125 typedef std::vector<ElementModel*> Elements;
126 typedef std::vector<Notation*> Notations;
127 typedef std::vector<Entity*> Entities;
128
129 QName _rootName;
130 Elements _elements;
131 Entities _entities;
132 Entities _paramEntities;
133 Notations _notations;
134 Pt::varint_t _r1; // allocator
135 Pt::varint_t _r2;
136};
137
138} // namespace Xml
139
140} // namespace Pt
141
142#endif // Pt_Xml_DocTypeDefinition_h
NonCopyable()
Default constructor.
Definition NonCopyable.h:63
Unicode capable basic_string.
Definition Api-String.h:67
The DocTypeDefinition of an XML document.
Definition DocTypeDefinition.h:58
Entity * declareParamEntity(const Pt::String &name)
Returns the entity or a nullptr if already declared.
void removeNotation(const Pt::String &name)
Removes the notation with the given name.
QName & rootName()
Returns the documents root element name.
void removeEntity(const Pt::String &name)
Removes the entity with the given name.
Entity * declareEntity(const Pt::String &name)
Returns the entity or a nullptr if already declared.
Notation * declareNotation(const Pt::String &name)
Returns the notation or a nullptr if already declared.
const Notation * findNotation(const Pt::String &name) const
Returns the notation or a nullptr if not declared.
DocTypeDefinition()
Construct an empty DocType node.
bool isDefined() const
Returns true if a DTD was defined in the document.
const QName & rootName() const
Returns the documents root element name.
const Entity * findEntity(const Pt::String &name) const
Returns the entity or a nullptr if not declared.
void clear()
Clears all content.
void removeParamEntity(const Pt::String &name)
Removes the entity with the given name.
~DocTypeDefinition()
Destructor.
const Entity * findParamEntity(const Pt::String &name) const
Returns the entity or a nullptr if not declared.
An entity declaration in a DTD.
Definition Entity.h:45
A notation declaration in a DTD.
Definition Notation.h:42
A qualified XML name.
Definition QName.h:47
Read and write XML ducuments.
Core module.
Definition Allocator.h:33