00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef _EVENTHANDLER_HPP
00023 #define _EVENTHANDLER_HPP
00024
00025 #include <xqilla/framework/XQillaExport.hpp>
00026 #include <xqilla/items/AnyAtomicType.hpp>
00027
00028 #include <xercesc/util/XercesDefs.hpp>
00029
00030 class XQILLA_API EventHandler
00031 {
00032 public:
00033 virtual ~EventHandler() {};
00034
00036 virtual void startDocumentEvent(const XMLCh *documentURI, const XMLCh *encoding) = 0;
00038 virtual void endDocumentEvent() = 0;
00040 virtual void startElementEvent(const XMLCh *prefix, const XMLCh *uri, const XMLCh *localname) = 0;
00042 virtual void endElementEvent(const XMLCh *prefix, const XMLCh *uri, const XMLCh *localname,
00043 const XMLCh *typeURI, const XMLCh *typeName) = 0;
00045 virtual void piEvent(const XMLCh *target, const XMLCh *value) = 0;
00047 virtual void textEvent(const XMLCh *value) = 0;
00049 virtual void textEvent(const XMLCh *chars, unsigned int length) = 0;
00051 virtual void commentEvent(const XMLCh *value) = 0;
00053 virtual void attributeEvent(const XMLCh *prefix, const XMLCh *uri, const XMLCh *localname, const XMLCh *value,
00054 const XMLCh *typeURI, const XMLCh *typeName) = 0;
00056 virtual void namespaceEvent(const XMLCh *prefix, const XMLCh *uri) = 0;
00058 virtual void atomicItemEvent(AnyAtomicType::AtomicObjectType type, const XMLCh *value,
00059 const XMLCh *typeURI, const XMLCh *typeName) {}
00061 virtual void endEvent() = 0;
00062 };
00063
00064 class XQILLA_API EventFilter : public EventHandler
00065 {
00066 public:
00067 EventFilter(EventHandler *next)
00068 : next_(next)
00069 {
00070 }
00071
00072 void setNextEventHandler(EventHandler *next)
00073 {
00074 next_ = next;
00075 }
00076
00077 virtual void startDocumentEvent(const XMLCh *documentURI, const XMLCh *encoding)
00078 {
00079 next_->startDocumentEvent(documentURI, encoding);
00080 }
00081
00082 virtual void endDocumentEvent()
00083 {
00084 next_->endDocumentEvent();
00085 }
00086
00087 virtual void startElementEvent(const XMLCh *prefix, const XMLCh *uri, const XMLCh *localname)
00088 {
00089 next_->startElementEvent(prefix, uri, localname);
00090 }
00091
00092 virtual void endElementEvent(const XMLCh *prefix, const XMLCh *uri, const XMLCh *localname,
00093 const XMLCh *typeURI, const XMLCh *typeName)
00094 {
00095 next_->endElementEvent(prefix, uri, localname, typeURI, typeName);
00096 }
00097
00098 virtual void piEvent(const XMLCh *target, const XMLCh *value)
00099 {
00100 next_->piEvent(target, value);
00101 }
00102
00103 virtual void textEvent(const XMLCh *value)
00104 {
00105 next_->textEvent(value);
00106 }
00107
00108 virtual void textEvent(const XMLCh *chars, unsigned int length)
00109 {
00110 next_->textEvent(chars, length);
00111 }
00112
00113 virtual void commentEvent(const XMLCh *value)
00114 {
00115 next_->commentEvent(value);
00116 }
00117
00118 virtual void attributeEvent(const XMLCh *prefix, const XMLCh *uri, const XMLCh *localname, const XMLCh *value,
00119 const XMLCh *typeURI, const XMLCh *typeName)
00120 {
00121 next_->attributeEvent(prefix, uri, localname, value, typeURI, typeName);
00122 }
00123
00124 virtual void namespaceEvent(const XMLCh *prefix, const XMLCh *uri)
00125 {
00126 next_->namespaceEvent(prefix, uri);
00127 }
00128
00129 virtual void atomicItemEvent(AnyAtomicType::AtomicObjectType type, const XMLCh *value, const XMLCh *typeURI,
00130 const XMLCh *typeName)
00131 {
00132 next_->atomicItemEvent(type, value, typeURI, typeName);
00133 }
00134
00135 virtual void endEvent()
00136 {
00137 next_->endEvent();
00138 }
00139
00140 protected:
00141 EventHandler *next_;
00142 };
00143
00144 static inline const XMLCh *emptyToNull(const XMLCh * const in)
00145 {
00146 return (in == 0 || *in == 0) ? 0 : in;
00147 }
00148
00149 #endif