ReaderHandler.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file ReaderHandler.cpp
22 
23  \brief This class implements Xerces interface for a handler that receives general document events.
24  */
25 
26 // TerraLib
27 #include "ReaderHandler.h"
28 
29 // Xerces-C++
30 #include <xercesc/sax/Locator.hpp>
31 #include <xercesc/sax2/Attributes.hpp>
32 #include <xercesc/util/XMLChar.hpp>
33 #include <xercesc/util/XMLString.hpp>
34 
36  : m_uri(nullptr),
37  m_localname(nullptr),
38  m_qname(nullptr),
39  m_attrs(nullptr),
40  m_value(nullptr),
41  m_len(0),
42  /*m_locator(0),*/
43  m_nodeType(te::xml::UNKNOWN),
44  m_isInContractedForm(false)
45 {
46 }
47 
49 {
51  m_nspaces.clear();
52 }
53 
54 void te::xerces::ReaderHandler::characters(const XMLCh* const chars, const XMLSize_t length)
55 {
56  xercesc_3_1::XMLChar1_0::isAllSpaces(chars, length) ? m_nodeType = te::xml::WHITESPACE : m_nodeType = te::xml::VALUE;
57  m_value = chars;
58  m_len = length;
59 }
60 
62 {
64 }
65 
66 void te::xerces::ReaderHandler::endElement(const XMLCh* const uri, const XMLCh* const localname, const XMLCh* const qname)
67 {
69  {
70  m_isInContractedForm = true;
71  return;
72  }
73 
75  m_uri = uri;
76  m_localname = localname;
77  m_qname = qname;
78 }
79 
80 void te::xerces::ReaderHandler::ignorableWhitespace(const XMLCh* const /*chars*/, const XMLSize_t /*length*/)
81 {
83  //m_value = chars;
84  //m_len = length;
85 }
86 
88  const XMLCh* const /*target*/, const XMLCh* const /*data*/)
89 {
91 }
92 
93 void te::xerces::ReaderHandler::setDocumentLocator(const xercesc::Locator* const /*locator*/)
94 {
95  //m_locator = locator;
96 }
97 
99 {
101 }
102 
103 void te::xerces::ReaderHandler::startElement(const XMLCh* const uri, const XMLCh* const localname, const XMLCh* const qname, const xercesc::Attributes& attrs)
104 {
106  m_uri = uri;
107  m_localname = localname;
108  m_qname = qname;
109  m_attrs = &attrs;
110 }
111 
112 void te::xerces::ReaderHandler::startPrefixMapping(const XMLCh* const prefix, const XMLCh* const uri)
113 {
115 
116  m_nspaces.push_back(std::pair<const XMLCh*, const XMLCh*>(prefix, uri));
117 }
118 
119 void te::xerces::ReaderHandler::endPrefixMapping(const XMLCh* const /*prefix*/)
120 {
122 }
123 
124 void te::xerces::ReaderHandler::skippedEntity(const XMLCh* const /*name*/)
125 {
127 }
128 
130 {
131  return m_nodeType;
132 }
133 
135 {
136  m_nodeType = type;
137 }
138 
140 {
141  return m_isInContractedForm;
142 }
143 
145 {
147 }
void processingInstruction(const XMLCh *const target, const XMLCh *const data)
It receives notification of a processing instruction.
const XMLCh * m_localname
The local part of the current element name.
const XMLCh * m_qname
The QName of the current element.
void endPrefixMapping(const XMLCh *const prefix)
It receives notification of the end of an namespace prefix mapping.
void setNodeType(te::xml::NodeType type)
void setDocumentLocator(const xercesc::Locator *const locator)
It receives an object for locating the origin of SAX document events.
const XMLCh * m_uri
URI of the associated namespace for the current element.
NodeType
The type of node read by XML reader.
const xercesc::Attributes * m_attrs
The attributes attached to the current element, if any.
URI C++ Library.
Definition: Attributes.h:37
void characters(const XMLCh *const chars, const XMLSize_t length)
It receives notification of character data.
static te::dt::DateTime d(2010, 8, 9, 15, 58, 39)
void ignorableWhitespace(const XMLCh *const chars, const XMLSize_t length)
It receives notification of ignorable whitespace in element content.
const XMLCh * m_value
May be characters from the XML document, ignorable white spaces, CDATA or any other string...
This class implements Xerces interface for a handler that receives general document events...
void startDocument()
It receives notification of the beginning of a document.
bool m_isInContractedForm
A flag that indicates if the reader handler is on an contracted form element.
void endDocument()
It receives notification of the end of a document.
te::xml::NodeType getNodeType() const
It return the type of node read by the handler.
ReaderHandler()
Default constructor.
void endElement(const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname)
It receives notification of the end of an element.
void startPrefixMapping(const XMLCh *const prefix, const XMLCh *const uri)
It receives notification of the start of an namespace prefix mapping.
bool isInContractedForm() const
void skippedEntity(const XMLCh *const name)
It receives notification of a skipped entity.
std::vector< std::pair< const XMLCh *, const XMLCh * > > m_nspaces
A vector of namespaces (prefix, uri).
XMLSize_t m_len
The number of characters in the m_value array.
te::xml::NodeType m_nodeType
The type of node read by the parser.
void startElement(const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname, const xercesc::Attributes &attrs)
It receives notification of the beginning of an element.