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 #include <xqilla/ast/LocationInfo.hpp>
00028
00029 #include <xercesc/util/XercesDefs.hpp>
00030
00031 class XQILLA_API EventHandler
00032 {
00033 public:
00034 virtual ~EventHandler() {};
00035
00038 virtual void setLocationInfo(const LocationInfo *location) {}
00039
00041 virtual void startDocumentEvent(const XMLCh *documentURI, const XMLCh *encoding) = 0;
00043 virtual void endDocumentEvent() = 0;
00045 virtual void startElementEvent(const XMLCh *prefix, const XMLCh *uri, const XMLCh *localname) = 0;
00047 virtual void endElementEvent(const XMLCh *prefix, const XMLCh *uri, const XMLCh *localname,
00048 const XMLCh *typeURI, const XMLCh *typeName) = 0;
00050 virtual void piEvent(const XMLCh *target, const XMLCh *value) = 0;
00052 virtual void textEvent(const XMLCh *value) = 0;
00054 virtual void textEvent(const XMLCh *chars, unsigned int length) = 0;
00056 virtual void commentEvent(const XMLCh *value) = 0;
00058 virtual void attributeEvent(const XMLCh *prefix, const XMLCh *uri, const XMLCh *localname, const XMLCh *value,
00059 const XMLCh *typeURI, const XMLCh *typeName) = 0;
00061 virtual void namespaceEvent(const XMLCh *prefix, const XMLCh *uri) = 0;
00063 virtual void atomicItemEvent(AnyAtomicType::AtomicObjectType type, const XMLCh *value,
00064 const XMLCh *typeURI, const XMLCh *typeName) {}
00066 virtual void endEvent() = 0;
00067 };
00068
00069 class XQILLA_API EventFilter : public EventHandler
00070 {
00071 public:
00072 EventFilter(EventHandler *next)
00073 : next_(next)
00074 {
00075 }
00076
00077 void setNextEventHandler(EventHandler *next)
00078 {
00079 next_ = next;
00080 }
00081
00082 virtual void setLocationInfo(const LocationInfo *location)
00083 {
00084 next_->setLocationInfo(location);
00085 }
00086
00087 virtual void startDocumentEvent(const XMLCh *documentURI, const XMLCh *encoding)
00088 {
00089 next_->startDocumentEvent(documentURI, encoding);
00090 }
00091
00092 virtual void endDocumentEvent()
00093 {
00094 next_->endDocumentEvent();
00095 }
00096
00097 virtual void startElementEvent(const XMLCh *prefix, const XMLCh *uri, const XMLCh *localname)
00098 {
00099 next_->startElementEvent(prefix, uri, localname);
00100 }
00101
00102 virtual void endElementEvent(const XMLCh *prefix, const XMLCh *uri, const XMLCh *localname,
00103 const XMLCh *typeURI, const XMLCh *typeName)
00104 {
00105 next_->endElementEvent(prefix, uri, localname, typeURI, typeName);
00106 }
00107
00108 virtual void piEvent(const XMLCh *target, const XMLCh *value)
00109 {
00110 next_->piEvent(target, value);
00111 }
00112
00113 virtual void textEvent(const XMLCh *value)
00114 {
00115 next_->textEvent(value);
00116 }
00117
00118 virtual void textEvent(const XMLCh *chars, unsigned int length)
00119 {
00120 next_->textEvent(chars, length);
00121 }
00122
00123 virtual void commentEvent(const XMLCh *value)
00124 {
00125 next_->commentEvent(value);
00126 }
00127
00128 virtual void attributeEvent(const XMLCh *prefix, const XMLCh *uri, const XMLCh *localname, const XMLCh *value,
00129 const XMLCh *typeURI, const XMLCh *typeName)
00130 {
00131 next_->attributeEvent(prefix, uri, localname, value, typeURI, typeName);
00132 }
00133
00134 virtual void namespaceEvent(const XMLCh *prefix, const XMLCh *uri)
00135 {
00136 next_->namespaceEvent(prefix, uri);
00137 }
00138
00139 virtual void atomicItemEvent(AnyAtomicType::AtomicObjectType type, const XMLCh *value, const XMLCh *typeURI,
00140 const XMLCh *typeName)
00141 {
00142 next_->atomicItemEvent(type, value, typeURI, typeName);
00143 }
00144
00145 virtual void endEvent()
00146 {
00147 next_->endEvent();
00148 }
00149
00150 protected:
00151 EventHandler *next_;
00152 };
00153
00154 static inline const XMLCh *emptyToNull(const XMLCh * const in)
00155 {
00156 return (in == 0 || *in == 0) ? 0 : in;
00157 }
00158
00159 #endif