libexpatpp 0.1.8
delegate.hpp
Go to the documentation of this file.
1
9#ifndef xmlpp_delegate_hpp
10#define xmlpp_delegate_hpp
11
12#include <string>
13
14#include "expat.h"
15
16namespace xmlpp {
17
19class Error {
20public:
21 explicit Error (XML_Error error) noexcept;
22 std::string to_string() const;
23 XML_Error errorcode() const;
24private:
25 XML_Error error;
26};
27
31class delegate {
32public:
33 virtual ~delegate()=default;
34
41 virtual void onStartElement(const XML_Char *fullname,
42 const XML_Char **atts) = 0;
48 virtual void onEndElement( const XML_Char *fullname) = 0;
49
59 virtual void onCharacterData(const char * pBuf, int len) = 0;
60
67 virtual void onComment( const XML_Char *data)= 0;
68
73 virtual void onStartCdataSection()= 0;
74
79 virtual void onEndCdataSection()= 0;
80
virtual void onXmlDecl( const XML_Char *version,
88 const XML_Char *encoding,
89 int standalone)= 0;
98 virtual void onParseError(size_t line,
99 size_t column,
100 size_t pos,
101 Error error) = 0;
102
109 virtual void onProcessingInstruction(const XML_Char* target,
110 const XML_Char* data) = 0;
111
118 virtual void onStartNamespace(const XML_Char* prefix,
119 const XML_Char* uri) = 0;
125 virtual void onEndNamespace(const XML_Char* prefix) = 0;
126
128
138 virtual void onStartDoctypeDecl(const XML_Char *doctypeName,
139 const XML_Char *sysid,
140 const XML_Char *pubid,
141 int has_internal_subset) = 0;
145 virtual void onEndDoctypeDecl() = 0;
146
155 virtual void onElementDecl( const XML_Char *name, XML_Content *model) = 0;
156
167 virtual void onAttlistDecl(const XML_Char *elname,
168 const XML_Char *attname,
169 const XML_Char *att_type,
170 const XML_Char *dflt,
171 bool isrequired) = 0;
172
virtual void onEntityDecl(const XML_Char *entityName,
185 int is_parameter_entity,
186 const XML_Char *value,
187 int value_length,
188 const XML_Char *base,
189 const XML_Char *systemId,
190 const XML_Char *publicId,
191 const XML_Char *notationName) = 0;
virtual void onNotationDecl(const XML_Char* notationName,
201 const XML_Char* base,
202 const XML_Char* systemId,
203 const XML_Char* publicId) = 0;
204
205 virtual void onUnparsedEntityDecl(const XML_Char* entityName,
206 const XML_Char* base,
207 const XML_Char* systemId,
208 const XML_Char* publicId,
209 const XML_Char* notationName) = 0;
210 virtual void onSkippedEntity(const XML_Char *entityName,
211 int is_parameter_entity) = 0;
213};
214
218public:
219 abstract_delegate()=default;
220
221 void onStartElement(const XML_Char *fullname, const XML_Char **atts) override;
222 void onEndElement( const XML_Char *fullname) override;
223 void onCharacterData(const char * pBuf, int len) override;
224 void onProcessingInstruction(const XML_Char* target,
225 const XML_Char* data) override;
226 void onUnparsedEntityDecl(const XML_Char* entityName,
227 const XML_Char* base,
228 const XML_Char* systemId,
229 const XML_Char* publicId,
230 const XML_Char* notationName) override;
231 void onNotationDecl(const XML_Char* notationName,
232 const XML_Char* base,
233 const XML_Char* systemId,
234 const XML_Char* publicId) override;
235 void onStartNamespace(const XML_Char* prefix, const XML_Char* uri) override;
236 void onEndNamespace(const XML_Char*) override;
237 void onAttlistDecl(const XML_Char *elname,
238 const XML_Char *attname,
239 const XML_Char *att_type,
240 const XML_Char *dflt,
241 bool isrequired) override;
242 void onStartCdataSection() override;
243 void onEndCdataSection() override;
244
245 void onStartDoctypeDecl(const XML_Char *doctypeName,
246 const XML_Char *sysid,
247 const XML_Char *pubid,
248 int has_internal_subset) override;
249 void onEndDoctypeDecl() override;
250
251 void onComment( const XML_Char *data) override;
252 void onElementDecl( const XML_Char *name, XML_Content *model) override;
253 void onEntityDecl(const XML_Char *entityName,
254 int is_parameter_entity,
255 const XML_Char *value,
256 int value_length,
257 const XML_Char *base,
258 const XML_Char *systemId,
259 const XML_Char *publicId,
260 const XML_Char *notationName) override;
261 void onSkippedEntity(const XML_Char *entityName,
262 int is_parameter_entity) override;
263 void onXmlDecl( const XML_Char *version,
264 const XML_Char *encoding,
265 int standalone) override;
266 void onParseError(size_t line,size_t column, size_t pos, Error error) override;
267};
268}
269#endif // #ifndef xmlpp_delegate_hpp
wrapper class type for expats XML_Error
Definition delegate.hpp:19
default base class for delegates.
Definition delegate.hpp:217
void onStartNamespace(const XML_Char *prefix, const XML_Char *uri) override
delegate function is called when an xml namespace is started/ opened
Definition delegate.cpp:56
void onEndElement(const XML_Char *fullname) override
callback is called after parsing the end tag of an xml element
Definition delegate.cpp:35
void onEndDoctypeDecl() override
delegate function is called if end of DTD is parsed from xml data
Definition delegate.cpp:76
void onParseError(size_t line, size_t column, size_t pos, Error error) override
function is called if on parsing a parse error is detected
Definition delegate.cpp:103
void onProcessingInstruction(const XML_Char *target, const XML_Char *data) override
delegate function is called if an xml processing instruction was found
Definition delegate.cpp:41
void onNotationDecl(const XML_Char *notationName, const XML_Char *base, const XML_Char *systemId, const XML_Char *publicId) override
delegate function is called if an notation declaration was parsed
Definition delegate.cpp:51
void onElementDecl(const XML_Char *name, XML_Content *model) override
delegate function is called if an DTD element declaration is parsed from xml data.
Definition delegate.cpp:81
void onStartDoctypeDecl(const XML_Char *doctypeName, const XML_Char *sysid, const XML_Char *pubid, int has_internal_subset) override
delegate function is called when a DTD (document type definition) xml entry is parsed.
Definition delegate.cpp:71
void onCharacterData(const char *pBuf, int len) override
callback is called with parsed character data inside of an xml element.
Definition delegate.cpp:38
void onAttlistDecl(const XML_Char *elname, const XML_Char *attname, const XML_Char *att_type, const XML_Char *dflt, bool isrequired) override
delegate function is called if an element attribute list declaration is parsed.
Definition delegate.cpp:61
void onXmlDecl(const XML_Char *version, const XML_Char *encoding, int standalone) override
delegate function is called after the (starting) xml declaration is parsed.
Definition delegate.cpp:98
void onEndNamespace(const XML_Char *) override
delegate function is called when an xml namespace is ended
Definition delegate.cpp:60
void onStartCdataSection() override
callback will be called if the begin of a PCDATA section was parsed
Definition delegate.cpp:66
void onStartElement(const XML_Char *fullname, const XML_Char **atts) override
this callback is called after parsing the starting tag of an xml element.
Definition delegate.cpp:32
void onEntityDecl(const XML_Char *entityName, int is_parameter_entity, const XML_Char *value, int value_length, const XML_Char *base, const XML_Char *systemId, const XML_Char *publicId, const XML_Char *notationName) override
delegate function is called if an entity declaration was parsed
Definition delegate.cpp:84
void onComment(const XML_Char *data) override
callback called on parsed xml comment
Definition delegate.cpp:79
void onEndCdataSection() override
callback will be called after the end of a PCDATA section was parsed
Definition delegate.cpp:68
definition of the parser delegate interface.
Definition delegate.hpp:31
virtual void onElementDecl(const XML_Char *name, XML_Content *model)=0
delegate function is called if an DTD element declaration is parsed from xml data.
virtual void onStartElement(const XML_Char *fullname, const XML_Char **atts)=0
this callback is called after parsing the starting tag of an xml element.
virtual void onProcessingInstruction(const XML_Char *target, const XML_Char *data)=0
delegate function is called if an xml processing instruction was found
virtual void onParseError(size_t line, size_t column, size_t pos, Error error)=0
function is called if on parsing a parse error is detected
virtual void onEntityDecl(const XML_Char *entityName, int is_parameter_entity, const XML_Char *value, int value_length, const XML_Char *base, const XML_Char *systemId, const XML_Char *publicId, const XML_Char *notationName)=0
delegate function is called if an entity declaration was parsed
virtual void onEndCdataSection()=0
callback will be called after the end of a PCDATA section was parsed
virtual void onAttlistDecl(const XML_Char *elname, const XML_Char *attname, const XML_Char *att_type, const XML_Char *dflt, bool isrequired)=0
delegate function is called if an element attribute list declaration is parsed.
virtual void onComment(const XML_Char *data)=0
callback called on parsed xml comment
virtual void onCharacterData(const char *pBuf, int len)=0
callback is called with parsed character data inside of an xml element.
virtual void onNotationDecl(const XML_Char *notationName, const XML_Char *base, const XML_Char *systemId, const XML_Char *publicId)=0
delegate function is called if an notation declaration was parsed
virtual void onXmlDecl(const XML_Char *version, const XML_Char *encoding, int standalone)=0
delegate function is called after the (starting) xml declaration is parsed.
virtual void onStartNamespace(const XML_Char *prefix, const XML_Char *uri)=0
delegate function is called when an xml namespace is started/ opened
virtual void onEndDoctypeDecl()=0
delegate function is called if end of DTD is parsed from xml data
virtual void onEndElement(const XML_Char *fullname)=0
callback is called after parsing the end tag of an xml element
virtual void onStartCdataSection()=0
callback will be called if the begin of a PCDATA section was parsed
virtual void onEndNamespace(const XML_Char *prefix)=0
delegate function is called when an xml namespace is ended
virtual void onStartDoctypeDecl(const XML_Char *doctypeName, const XML_Char *sysid, const XML_Char *pubid, int has_internal_subset)=0
delegate function is called when a DTD (document type definition) xml entry is parsed.