1 | // |
2 | // XMLFilterImpl.h |
3 | // |
4 | // Library: XML |
5 | // Package: SAX |
6 | // Module: SAXFilters |
7 | // |
8 | // SAX2 XMLFilterImpl class. |
9 | // |
10 | // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. |
11 | // and Contributors. |
12 | // |
13 | // SPDX-License-Identifier: BSL-1.0 |
14 | // |
15 | |
16 | |
17 | #ifndef SAX_XMLFilterImpl_INCLUDED |
18 | #define SAX_XMLFilterImpl_INCLUDED |
19 | |
20 | |
21 | #include "Poco/XML/XML.h" |
22 | #include "Poco/SAX/XMLFilter.h" |
23 | #include "Poco/SAX/EntityResolver.h" |
24 | #include "Poco/SAX/DTDHandler.h" |
25 | #include "Poco/SAX/ContentHandler.h" |
26 | #include "Poco/SAX/ErrorHandler.h" |
27 | |
28 | |
29 | namespace Poco { |
30 | namespace XML { |
31 | |
32 | |
33 | class XML_API XMLFilterImpl: public XMLFilter, public EntityResolver, public DTDHandler, public ContentHandler, public ErrorHandler |
34 | /// Base class for deriving an XML filter. |
35 | /// |
36 | /// This class is designed to sit between an XMLReader and the client application's event |
37 | /// handlers. By default, it does nothing but pass requests up to the reader and events on to |
38 | /// the handlers unmodified, but subclasses can override specific methods to modify the event |
39 | /// stream or the configuration requests as they pass through. |
40 | { |
41 | public: |
42 | XMLFilterImpl(); |
43 | /// Construct an empty XML filter, with no parent. |
44 | /// |
45 | /// This filter will have no parent: you must assign a parent before you start a parse or do any |
46 | /// configuration with setFeature or setProperty, unless you use this as a pure event consumer rather |
47 | /// than as an XMLReader. |
48 | |
49 | XMLFilterImpl(XMLReader* pParent); |
50 | /// Construct an XML filter with the specified parent. |
51 | |
52 | ~XMLFilterImpl(); |
53 | /// Destroys the XMLFilterImpl. |
54 | |
55 | // XMLFilter |
56 | XMLReader* getParent() const; |
57 | void setParent(XMLReader* pParent); |
58 | |
59 | // XMLReader |
60 | void setEntityResolver(EntityResolver* pResolver); |
61 | EntityResolver* getEntityResolver() const; |
62 | void setDTDHandler(DTDHandler* pDTDHandler); |
63 | DTDHandler* getDTDHandler() const; |
64 | void setContentHandler(ContentHandler* pContentHandler); |
65 | ContentHandler* getContentHandler() const; |
66 | void setErrorHandler(ErrorHandler* pErrorHandler); |
67 | ErrorHandler* getErrorHandler() const; |
68 | void setFeature(const XMLString& featureId, bool state); |
69 | bool getFeature(const XMLString& featureId) const; |
70 | void setProperty(const XMLString& propertyId, const XMLString& value); |
71 | void setProperty(const XMLString& propertyId, void* value); |
72 | void* getProperty(const XMLString& propertyId) const; |
73 | void parse(InputSource* pSource); |
74 | void parse(const XMLString& systemId); |
75 | void parseMemoryNP(const char* xml, std::size_t size); |
76 | |
77 | // EntityResolver |
78 | InputSource* resolveEntity(const XMLString* publicId, const XMLString& systemId); |
79 | void releaseInputSource(InputSource* pSource); |
80 | |
81 | // DTDHandler |
82 | void notationDecl(const XMLString& name, const XMLString* publicId, const XMLString* systemId); |
83 | void unparsedEntityDecl(const XMLString& name, const XMLString* publicId, const XMLString& systemId, const XMLString& notationName); |
84 | |
85 | // ContentHandler |
86 | void setDocumentLocator(const Locator* loc); |
87 | void startDocument(); |
88 | void endDocument(); |
89 | void startElement(const XMLString& uri, const XMLString& localName, const XMLString& qname, const Attributes& attrList); |
90 | void endElement(const XMLString& uri, const XMLString& localName, const XMLString& qname); |
91 | void characters(const XMLChar ch[], int start, int length); |
92 | void ignorableWhitespace(const XMLChar ch[], int start, int length); |
93 | void processingInstruction(const XMLString& target, const XMLString& data); |
94 | void startPrefixMapping(const XMLString& prefix, const XMLString& uri); |
95 | void endPrefixMapping(const XMLString& prefix); |
96 | void skippedEntity(const XMLString& prefix); |
97 | void warning(const SAXException& e); |
98 | void error(const SAXException& e); |
99 | void fatalError(const SAXException& e); |
100 | |
101 | protected: |
102 | XMLReader* parent() const; |
103 | /// Return a pointer to the parent reader. |
104 | /// Subclasses can use this method instead of |
105 | /// getParent() for better performance - this method |
106 | /// is non-virtual and implemented as inline. |
107 | |
108 | virtual void setupParse(); |
109 | /// Setup the event handlers in the parent reader. |
110 | |
111 | private: |
112 | XMLReader* _pParent; |
113 | EntityResolver* _pEntityResolver; |
114 | DTDHandler* _pDTDHandler; |
115 | ContentHandler* _pContentHandler; |
116 | ErrorHandler* _pErrorHandler; |
117 | }; |
118 | |
119 | |
120 | // |
121 | // inlines |
122 | // |
123 | inline XMLReader* XMLFilterImpl::parent() const |
124 | { |
125 | return _pParent; |
126 | } |
127 | |
128 | |
129 | } } // namespace Poco::XML |
130 | |
131 | |
132 | #endif // SAX_XMLFilterImpl_INCLUDED |
133 | |