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 
40 namespace Pt {
41 
42 namespace Xml {
43 
44 class ElementModel;
45 class ContentModel;
46 class AttributeListModel;
47 class Entity;
48 class Notation;
49 
50 class DocTypeDefinition;
51 
57 class 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 
82  QName& rootName();
83 
85  Entity* declareEntity(const Pt::String& name);
86 
88  const Entity* findEntity(const Pt::String& name) const;
89 
91  void removeEntity(const Pt::String& name);
92 
94  Entity* declareParamEntity(const Pt::String& name);
95 
97  const Entity* findParamEntity(const Pt::String& name) const;
98 
100  void removeParamEntity(const Pt::String& name);
101 
103  Notation* declareNotation(const Pt::String& name);
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
Protects derived classes from being copied.
Definition: NonCopyable.h:54
A qualified XML name.
Definition: QName.h:46
The DocTypeDefinition of an XML document.
Definition: DocTypeDefinition.h:57
An entity declaration in a DTD.
Definition: Entity.h:44
Unicode capable basic_string.
Definition: String.h:42
A notation declaration in a DTD.
Definition: Notation.h:41