# XQilla Simple API Documentation

- Main Page
- Namespaces
- Classes
- Files
- Examples

- File List
- File Members

# EventHandler.hpp

Go to the documentation of this file.

    00001 /*
    00002  * Copyright (c) 2001, 2008,
    00003  *     DecisionSoft Limited. All rights reserved.
    00004  * Copyright (c) 2004, 2015 Oracle and/or its affiliates. All rights reserved.
    00005  *
    00006  *
    00007  * Licensed under the Apache License, Version 2.0 (the "License");
    00008  * you may not use this file except in compliance with the License.
    00009  * You may obtain a copy of the License at
    00010  *
    00011  *     http://www.apache.org/licenses/LICENSE-2.0
    00012  *
    00013  * Unless required by applicable law or agreed to in writing, software
    00014  * distributed under the License is distributed on an "AS IS" BASIS,
    00015  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    00016  * See the License for the specific language governing permissions and
    00017  * limitations under the License.
    00018  */
    00019
    00020 #ifndef _EVENTHANDLER_HPP
    00021 #define _EVENTHANDLER_HPP
    00022
    00023 #include <xqilla/framework/XQillaExport.hpp>
    00024 #include <xqilla/items/AnyAtomicType.hpp>
    00025 #include <xqilla/ast/LocationInfo.hpp>
    00026
    00027 #include <xercesc/util/XercesDefs.hpp>
    00028
    00029 class XQILLA_API EventHandler
    00030 {
    00031 public:
    00032   virtual ~EventHandler() {};
    00033
    00036   virtual void setLocationInfo(const LocationInfo *location) {}
    00037
    00039   virtual void startDocumentEvent(const XMLCh *documentURI, const XMLCh *encoding) = 0;
    00041   virtual void endDocumentEvent() = 0;
    00043   virtual void startElementEvent(const XMLCh *prefix, const XMLCh *uri, const XMLCh *localname) = 0;
    00045   virtual void endElementEvent(const XMLCh *prefix, const XMLCh *uri, const XMLCh *localname,
    00046                                const XMLCh *typeURI, const XMLCh *typeName) = 0;
    00048   virtual void piEvent(const XMLCh *target, const XMLCh *value) = 0;
    00050   virtual void textEvent(const XMLCh *value) = 0;
    00052   virtual void textEvent(const XMLCh *chars, unsigned int length) = 0;
    00054   virtual void commentEvent(const XMLCh *value) = 0;
    00056   virtual void attributeEvent(const XMLCh *prefix, const XMLCh *uri, const XMLCh *localname, const XMLCh *value,
    00057                               const XMLCh *typeURI, const XMLCh *typeName) = 0;
    00059   virtual void namespaceEvent(const XMLCh *prefix, const XMLCh *uri) = 0;
    00061   virtual void atomicItemEvent(AnyAtomicType::AtomicObjectType type, const XMLCh *value,
    00062                                const XMLCh *typeURI, const XMLCh *typeName) {}
    00064   virtual void endEvent() = 0;
    00065 };
    00066
    00067 class XQILLA_API EventFilter : public EventHandler
    00068 {
    00069 public:
    00070   EventFilter(EventHandler *next)
    00071     : next_(next)
    00072   {
    00073   }
    00074
    00075   void setNextEventHandler(EventHandler *next)
    00076   {
    00077     next_ = next;
    00078   }
    00079
    00080   virtual void setLocationInfo(const LocationInfo *location)
    00081   {
    00082     next_->setLocationInfo(location);
    00083   }
    00084
    00085   virtual void startDocumentEvent(const XMLCh *documentURI, const XMLCh *encoding)
    00086   {
    00087     next_->startDocumentEvent(documentURI, encoding);
    00088   }
    00089
    00090   virtual void endDocumentEvent()
    00091   {
    00092     next_->endDocumentEvent();
    00093   }
    00094
    00095   virtual void startElementEvent(const XMLCh *prefix, const XMLCh *uri, const XMLCh *localname)
    00096   {
    00097     next_->startElementEvent(prefix, uri, localname);
    00098   }
    00099
    00100   virtual void endElementEvent(const XMLCh *prefix, const XMLCh *uri, const XMLCh *localname,
    00101                                const XMLCh *typeURI, const XMLCh *typeName)
    00102   {
    00103     next_->endElementEvent(prefix, uri, localname, typeURI, typeName);
    00104   }
    00105
    00106   virtual void piEvent(const XMLCh *target, const XMLCh *value)
    00107   {
    00108     next_->piEvent(target, value);
    00109   }
    00110
    00111   virtual void textEvent(const XMLCh *value)
    00112   {
    00113     next_->textEvent(value);
    00114   }
    00115
    00116   virtual void textEvent(const XMLCh *chars, unsigned int length)
    00117   {
    00118     next_->textEvent(chars, length);
    00119   }
    00120
    00121   virtual void commentEvent(const XMLCh *value)
    00122   {
    00123     next_->commentEvent(value);
    00124   }
    00125
    00126   virtual void attributeEvent(const XMLCh *prefix, const XMLCh *uri, const XMLCh *localname, const XMLCh *value,
    00127                               const XMLCh *typeURI, const XMLCh *typeName)
    00128   {
    00129     next_->attributeEvent(prefix, uri, localname, value, typeURI, typeName);
    00130   }
    00131
    00132   virtual void namespaceEvent(const XMLCh *prefix, const XMLCh *uri)
    00133   {
    00134     next_->namespaceEvent(prefix, uri);
    00135   }
    00136
    00137   virtual void atomicItemEvent(AnyAtomicType::AtomicObjectType type, const XMLCh *value, const XMLCh *typeURI,
    00138                                const XMLCh *typeName)
    00139   {
    00140     next_->atomicItemEvent(type, value, typeURI, typeName);
    00141   }
    00142
    00143   virtual void endEvent()
    00144   {
    00145     next_->endEvent();
    00146   }
    00147
    00148 protected:
    00149   EventHandler *next_;
    00150 };
    00151
    00152 static inline const XMLCh *emptyToNull(const XMLCh * const in)
    00153 {
    00154   return (in == 0 || *in == 0) ? 0 : in;
    00155 }
    00156
    00157 #endif