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, 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 _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