SourceForge.net Logo
EventSerializer.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2001, 2008,
3  * DecisionSoft Limited. All rights reserved.
4  * Copyright (c) 2004, 2018 Oracle and/or its affiliates. All rights reserved.
5  *
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 _EVENTSERIALIZER_HPP
21 #define _EVENTSERIALIZER_HPP
22 
24 
26 
27 class XQILLA_API EventSerializer : public EventHandler
28 {
29 public:
30  EventSerializer(const char *encoding, const char *xmlVersion, XERCES_CPP_NAMESPACE_QUALIFIER XMLFormatTarget *target,
31  XERCES_CPP_NAMESPACE_QUALIFIER MemoryManager *mm =
32  XERCES_CPP_NAMESPACE_QUALIFIER XMLPlatformUtils::fgMemoryManager);
33  EventSerializer(XERCES_CPP_NAMESPACE_QUALIFIER XMLFormatTarget *target,
34  XERCES_CPP_NAMESPACE_QUALIFIER MemoryManager *mm =
35  XERCES_CPP_NAMESPACE_QUALIFIER XMLPlatformUtils::fgMemoryManager);
36  ~EventSerializer();
37 
38  virtual void setLocationInfo(const LocationInfo *location) {}
39 
40  virtual void startDocumentEvent(const XMLCh *documentURI, const XMLCh *encoding);
41  virtual void endDocumentEvent();
42  virtual void startElementEvent(const XMLCh *prefix, const XMLCh *uri, const XMLCh *localname);
43  virtual void endElementEvent(const XMLCh *prefix, const XMLCh *uri, const XMLCh *localname,
44  const XMLCh *typeURI, const XMLCh *typeName);
45  virtual void piEvent(const XMLCh *target, const XMLCh *value);
46  virtual void textEvent(const XMLCh *value);
47  virtual void textEvent(const XMLCh *chars, unsigned int length);
48  virtual void commentEvent(const XMLCh *value);
49  virtual void attributeEvent(const XMLCh *prefix, const XMLCh *uri, const XMLCh *localname, const XMLCh *value,
50  const XMLCh *typeURI, const XMLCh *typeName);
51  virtual void namespaceEvent(const XMLCh *prefix, const XMLCh *uri);
52  virtual void atomicItemEvent(AnyAtomicType::AtomicObjectType type, const XMLCh *value,
53  const XMLCh *typeURI, const XMLCh *typeName);
54  virtual void endEvent();
55 
56  void addNewlines(bool add) { addNewlines_ = add; }
57  void useSelfClosingElement(bool value) { selfClosing_ = value; }
58  void addXMLDeclarations(bool value) { xmlDecls_ = value; }
59 
60 private:
61  XERCES_CPP_NAMESPACE_QUALIFIER XMLFormatter formatter_;
62  bool elementStarted_;
63  unsigned int level_;
64  XMLCh *version_, *encoding_;
65  bool addNewlines_, selfClosing_, xmlDecls_;
66  XERCES_CPP_NAMESPACE_QUALIFIER MemoryManager *mm_;
67 };
68 
69 #endif
virtual void piEvent(const XMLCh *target, const XMLCh *value)=0
Handles a processing instruction node as an event.
Definition: EventHandler.hpp:29
virtual void commentEvent(const XMLCh *value)=0
Handles a comment node as an event.
void addXMLDeclarations(bool value)
Definition: EventSerializer.hpp:58
virtual void endElementEvent(const XMLCh *prefix, const XMLCh *uri, const XMLCh *localname, const XMLCh *typeURI, const XMLCh *typeName)=0
Handles the end of an element node as an event.
AtomicObjectType
Definition: AnyAtomicType.hpp:34
virtual void namespaceEvent(const XMLCh *prefix, const XMLCh *uri)=0
Handles a namespace binding as an event.
void useSelfClosingElement(bool value)
Definition: EventSerializer.hpp:57
virtual void textEvent(const XMLCh *value)=0
Handles a text node as an event.
virtual void attributeEvent(const XMLCh *prefix, const XMLCh *uri, const XMLCh *localname, const XMLCh *value, const XMLCh *typeURI, const XMLCh *typeName)=0
Handles an attribute node as an event.
virtual void startDocumentEvent(const XMLCh *documentURI, const XMLCh *encoding)=0
Handles a document node as an event.
virtual void atomicItemEvent(AnyAtomicType::AtomicObjectType type, const XMLCh *value, const XMLCh *typeURI, const XMLCh *typeName)
Handles an atomic item as an event.
Definition: EventHandler.hpp:61
virtual void endDocumentEvent()=0
Handles a document node as an event.
virtual void endEvent()=0
Called when all events have been reported.
virtual void startElementEvent(const XMLCh *prefix, const XMLCh *uri, const XMLCh *localname)=0
Handles the start of an element node as an event.
Definition: EventSerializer.hpp:27
virtual void setLocationInfo(const LocationInfo *location)
Recieves a LocationInfo object that is owned by the caller, and will be updated with the current loca...
Definition: EventSerializer.hpp:38
A class that gives records a location in the query.
Definition: LocationInfo.hpp:29
void addNewlines(bool add)
Definition: EventSerializer.hpp:56