SourceForge.net Logo
EventHandler.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2001, 2008,
3  * DecisionSoft Limited. All rights reserved.
4  * Copyright (c) 2004, 2011,
5  * Oracle and/or its affiliates. All rights reserved.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 
20 #ifndef _EVENTHANDLER_HPP
21 #define _EVENTHANDLER_HPP
22 
23 #include <xqilla/framework/XQillaExport.hpp>
26 
27 #include <xercesc/util/XercesDefs.hpp>
28 
29 class XQILLA_API EventHandler
30 {
31 public:
32  virtual ~EventHandler() {};
33 
36  virtual void setLocationInfo(const LocationInfo *location) {
37  (void) location;
38  }
39 
41  virtual void startDocumentEvent(const XMLCh *documentURI, const XMLCh *encoding) = 0;
43  virtual void endDocumentEvent() = 0;
45  virtual void startElementEvent(const XMLCh *prefix, const XMLCh *uri, const XMLCh *localname) = 0;
47  virtual void endElementEvent(const XMLCh *prefix, const XMLCh *uri, const XMLCh *localname,
48  const XMLCh *typeURI, const XMLCh *typeName) = 0;
50  virtual void piEvent(const XMLCh *target, const XMLCh *value) = 0;
52  virtual void textEvent(const XMLCh *value) = 0;
54  virtual void textEvent(const XMLCh *chars, unsigned int length) = 0;
56  virtual void commentEvent(const XMLCh *value) = 0;
58  virtual void attributeEvent(const XMLCh *prefix, const XMLCh *uri, const XMLCh *localname, const XMLCh *value,
59  const XMLCh *typeURI, const XMLCh *typeName) = 0;
61  virtual void namespaceEvent(const XMLCh *prefix, const XMLCh *uri) = 0;
63  virtual void atomicItemEvent(AnyAtomicType::AtomicObjectType type, const XMLCh *value,
64  const XMLCh *typeURI, const XMLCh *typeName) {
65  (void) type;
66  (void) value;
67  (void) typeURI;
68  (void) typeName;
69  }
71  virtual void endEvent() = 0;
72 };
73 
74 class XQILLA_API EventFilter : public EventHandler
75 {
76 public:
78  : next_(next)
79  {
80  }
81 
82  void setNextEventHandler(EventHandler *next)
83  {
84  next_ = next;
85  }
86 
87  virtual void setLocationInfo(const LocationInfo *location)
88  {
89  next_->setLocationInfo(location);
90  }
91 
92  virtual void startDocumentEvent(const XMLCh *documentURI, const XMLCh *encoding)
93  {
94  next_->startDocumentEvent(documentURI, encoding);
95  }
96 
97  virtual void endDocumentEvent()
98  {
99  next_->endDocumentEvent();
100  }
101 
102  virtual void startElementEvent(const XMLCh *prefix, const XMLCh *uri, const XMLCh *localname)
103  {
104  next_->startElementEvent(prefix, uri, localname);
105  }
106 
107  virtual void endElementEvent(const XMLCh *prefix, const XMLCh *uri, const XMLCh *localname,
108  const XMLCh *typeURI, const XMLCh *typeName)
109  {
110  next_->endElementEvent(prefix, uri, localname, typeURI, typeName);
111  }
112 
113  virtual void piEvent(const XMLCh *target, const XMLCh *value)
114  {
115  next_->piEvent(target, value);
116  }
117 
118  virtual void textEvent(const XMLCh *value)
119  {
120  next_->textEvent(value);
121  }
122 
123  virtual void textEvent(const XMLCh *chars, unsigned int length)
124  {
125  next_->textEvent(chars, length);
126  }
127 
128  virtual void commentEvent(const XMLCh *value)
129  {
130  next_->commentEvent(value);
131  }
132 
133  virtual void attributeEvent(const XMLCh *prefix, const XMLCh *uri, const XMLCh *localname, const XMLCh *value,
134  const XMLCh *typeURI, const XMLCh *typeName)
135  {
136  next_->attributeEvent(prefix, uri, localname, value, typeURI, typeName);
137  }
138 
139  virtual void namespaceEvent(const XMLCh *prefix, const XMLCh *uri)
140  {
141  next_->namespaceEvent(prefix, uri);
142  }
143 
144  virtual void atomicItemEvent(AnyAtomicType::AtomicObjectType type, const XMLCh *value, const XMLCh *typeURI,
145  const XMLCh *typeName)
146  {
147  next_->atomicItemEvent(type, value, typeURI, typeName);
148  }
149 
150  virtual void endEvent()
151  {
152  next_->endEvent();
153  }
154 
155 protected:
157 };
158 
159 static inline const XMLCh *emptyToNull(const XMLCh * const in)
160 {
161  return (in == 0 || *in == 0) ? 0 : in;
162 }
163 
164 #endif