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-2008
5  * Oracle. 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  * $Id$
20  */
21 
22 #ifndef _EVENTSERIALIZER_HPP
23 #define _EVENTSERIALIZER_HPP
24 
26 
28 
29 class XQILLA_API EventSerializer : public EventHandler
30 {
31 public:
32  EventSerializer(const char *encoding, const char *xmlVersion, XERCES_CPP_NAMESPACE_QUALIFIER XMLFormatTarget *target,
33  XERCES_CPP_NAMESPACE_QUALIFIER MemoryManager *mm =
34  XERCES_CPP_NAMESPACE_QUALIFIER XMLPlatformUtils::fgMemoryManager);
35  EventSerializer(XERCES_CPP_NAMESPACE_QUALIFIER XMLFormatTarget *target,
36  XERCES_CPP_NAMESPACE_QUALIFIER MemoryManager *mm =
37  XERCES_CPP_NAMESPACE_QUALIFIER XMLPlatformUtils::fgMemoryManager);
38  ~EventSerializer();
39 
40  virtual void setLocationInfo(const LocationInfo *location) {}
41 
42  virtual void startDocumentEvent(const XMLCh *documentURI, const XMLCh *encoding);
43  virtual void endDocumentEvent();
44  virtual void startElementEvent(const XMLCh *prefix, const XMLCh *uri, const XMLCh *localname);
45  virtual void endElementEvent(const XMLCh *prefix, const XMLCh *uri, const XMLCh *localname,
46  const XMLCh *typeURI, const XMLCh *typeName);
47  virtual void piEvent(const XMLCh *target, const XMLCh *value);
48  virtual void textEvent(const XMLCh *value);
49  virtual void textEvent(const XMLCh *chars, unsigned int length);
50  virtual void commentEvent(const XMLCh *value);
51  virtual void attributeEvent(const XMLCh *prefix, const XMLCh *uri, const XMLCh *localname, const XMLCh *value,
52  const XMLCh *typeURI, const XMLCh *typeName);
53  virtual void namespaceEvent(const XMLCh *prefix, const XMLCh *uri);
54  virtual void atomicItemEvent(AnyAtomicType::AtomicObjectType type, const XMLCh *value,
55  const XMLCh *typeURI, const XMLCh *typeName);
56  virtual void endEvent();
57 
58  void addNewlines(bool add) { addNewlines_ = add; }
59  void useSelfClosingElement(bool value) { selfClosing_ = value; }
60  void addXMLDeclarations(bool value) { xmlDecls_ = value; }
61 
62 private:
63  XERCES_CPP_NAMESPACE_QUALIFIER XMLFormatter formatter_;
64  bool elementStarted_;
65  unsigned int level_;
66  XMLCh *version_, *encoding_;
67  bool addNewlines_, selfClosing_, xmlDecls_;
68  XERCES_CPP_NAMESPACE_QUALIFIER MemoryManager *mm_;
69 };
70 
71 #endif
virtual void piEvent(const XMLCh *target, const XMLCh *value)=0
Handles a processing instruction node as an event.
Definition: EventHandler.hpp:31
virtual void commentEvent(const XMLCh *value)=0
Handles a comment node as an event.
void addXMLDeclarations(bool value)
Definition: EventSerializer.hpp:60
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:36
virtual void namespaceEvent(const XMLCh *prefix, const XMLCh *uri)=0
Handles a namespace binding as an event.
void useSelfClosingElement(bool value)
Definition: EventSerializer.hpp:59
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:63
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:29
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:40
A class that gives records a location in the query.
Definition: LocationInfo.hpp:31
void addNewlines(bool add)
Definition: EventSerializer.hpp:58