root / trunk / Linux / libs / poco / include / Poco / SAX / XMLFilterImpl.h @ 58

View | Annotate | Download (5.6 KB)

1
//
2
// XMLFilterImpl.h
3
//
4
// $Id: //poco/1.3/XML/include/Poco/SAX/XMLFilterImpl.h#2 $
5
//
6
// Library: XML
7
// Package: SAX
8
// Module:  SAXFilters
9
//
10
// SAX2 XMLFilterImpl class.
11
//
12
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
13
// and Contributors.
14
//
15
// Permission is hereby granted, free of charge, to any person or organization
16
// obtaining a copy of the software and accompanying documentation covered by
17
// this license (the "Software") to use, reproduce, display, distribute,
18
// execute, and transmit the Software, and to prepare derivative works of the
19
// Software, and to permit third-parties to whom the Software is furnished to
20
// do so, all subject to the following:
21
// 
22
// The copyright notices in the Software and this entire statement, including
23
// the above license grant, this restriction and the following disclaimer,
24
// must be included in all copies of the Software, in whole or in part, and
25
// all derivative works of the Software, unless such copies or derivative
26
// works are solely in the form of machine-executable object code generated by
27
// a source language processor.
28
// 
29
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
32
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
33
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
34
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
35
// DEALINGS IN THE SOFTWARE.
36
//
37
38
39
#ifndef SAX_XMLFilterImpl_INCLUDED
40
#define SAX_XMLFilterImpl_INCLUDED
41
42
43
#include "Poco/XML/XML.h"
44
#include "Poco/SAX/XMLFilter.h"
45
#include "Poco/SAX/EntityResolver.h"
46
#include "Poco/SAX/DTDHandler.h"
47
#include "Poco/SAX/ContentHandler.h"
48
#include "Poco/SAX/ErrorHandler.h"
49
50
51
namespace Poco {
52
namespace XML {
53
54
55
class XML_API XMLFilterImpl: public XMLFilter, public EntityResolver, public DTDHandler, public ContentHandler, public ErrorHandler
56
        /// Base class for deriving an XML filter.
57
        ///
58
        /// This class is designed to sit between an XMLReader and the client application's event 
59
        /// handlers. By default, it does nothing but pass requests up to the reader and events on to 
60
        /// the handlers unmodified, but subclasses can override specific methods to modify the event 
61
        /// stream or the configuration requests as they pass through.
62
{
63
public:
64
        XMLFilterImpl();
65
                /// Construct an empty XML filter, with no parent.
66
                ///
67
                /// This filter will have no parent: you must assign a parent before you start a parse or do any 
68
                /// configuration with setFeature or setProperty, unless you use this as a pure event consumer rather 
69
                /// than as an XMLReader.
70
                
71
        XMLFilterImpl(XMLReader* pParent);
72
                /// Construct an XML filter with the specified parent.
73
                
74
        ~XMLFilterImpl();
75
                /// Destroys the XMLFilterImpl.
76
        
77
        // XMLFilter
78
        XMLReader* getParent() const;
79
        void setParent(XMLReader* pParent);
80
81
        // XMLReader
82
        void setEntityResolver(EntityResolver* pResolver);
83
        EntityResolver* getEntityResolver() const;
84
        void setDTDHandler(DTDHandler* pDTDHandler);
85
        DTDHandler* getDTDHandler() const;
86
        void setContentHandler(ContentHandler* pContentHandler);
87
        ContentHandler* getContentHandler() const;
88
        void setErrorHandler(ErrorHandler* pErrorHandler);
89
        ErrorHandler* getErrorHandler() const;
90
        void setFeature(const XMLString& featureId, bool state);
91
        bool getFeature(const XMLString& featureId) const;
92
        void setProperty(const XMLString& propertyId, const XMLString& value);
93
        void setProperty(const XMLString& propertyId, void* value);
94
        void* getProperty(const XMLString& propertyId) const;
95
        void parse(InputSource* pSource);
96
        void parse(const XMLString& systemId);
97
        void parseMemoryNP(const char* xml, std::size_t size);
98
99
        // EntityResolver
100
        InputSource* resolveEntity(const XMLString* publicId, const XMLString& systemId);
101
        void releaseInputSource(InputSource* pSource);
102
        
103
        // DTDHandler
104
        void notationDecl(const XMLString& name, const XMLString* publicId, const XMLString* systemId);
105
        void unparsedEntityDecl(const XMLString& name, const XMLString* publicId, const XMLString& systemId, const XMLString& notationName);
106
107
        // ContentHandler
108
        void setDocumentLocator(const Locator* loc);
109
        void startDocument();
110
        void endDocument();
111
        void startElement(const XMLString& uri, const XMLString& localName, const XMLString& qname, const Attributes& attrList);
112
        void endElement(const XMLString& uri, const XMLString& localName, const XMLString& qname);
113
        void characters(const XMLChar ch[], int start, int length);
114
        void ignorableWhitespace(const XMLChar ch[], int start, int length);
115
        void processingInstruction(const XMLString& target, const XMLString& data);
116
        void startPrefixMapping(const XMLString& prefix, const XMLString& uri);
117
        void endPrefixMapping(const XMLString& prefix);
118
        void skippedEntity(const XMLString& prefix);
119
        void warning(const SAXException& e);
120
        void error(const SAXException& e);
121
        void fatalError(const SAXException& e);
122
123
protected:
124
        XMLReader* parent() const;
125
                /// Return a pointer to the parent reader.
126
                /// Subclasses can use this method instead of
127
                /// getParent() for better performance - this method
128
                /// is non-virtual and implemented as inline.
129
        
130
        virtual void setupParse();
131
                /// Setup the event handlers in the parent reader.
132
        
133
private:
134
        XMLReader*      _pParent;
135
        EntityResolver* _pEntityResolver;
136
        DTDHandler*     _pDTDHandler;
137
        ContentHandler* _pContentHandler;
138
        ErrorHandler*   _pErrorHandler;
139
};
140
141
142
//
143
// inlines
144
//
145
inline XMLReader* XMLFilterImpl::parent() const
146
{
147
        return _pParent;
148
}
149
150
151
} } // namespace Poco::XML
152
153
154
#endif // SAX_XMLFilterImpl_INCLUDED