Loading...
Searching...
No Matches
Writer.h
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 Writer.h
22
23 \brief A class that models a XML writer object built on top of Xerces-C++.
24*/
25
26#ifndef __TERRALIB_XERCES_INTERNAL_WRITER_H
27#define __TERRALIB_XERCES_INTERNAL_WRITER_H
28
29// TerraLib
30#include "../xml/AbstractWriter.h"
31#include "Config.h"
32
33// STL
34#include <memory>
35#include <string>
36#include <vector>
37
38// Xerces-C++
39#include <xercesc/util/XercesDefs.hpp>
40#include <xercesc/util/TransService.hpp>
41
42// Forward declaration
43XERCES_CPP_NAMESPACE_BEGIN
44class DOMDocument;
45class DOMElement;
46class DOMImplementation;
47XERCES_CPP_NAMESPACE_END
48
49namespace te
50{
51 namespace xerces
52 {
53// Forward declaration
54
55 /*!
56 \class AbstractWriter
57
58 \brief A class that models a XML writer object built on top of Xerces-C++
59 */
61 {
62 public:
63
64 /*! \brief Default constructor. */
66
67 /*! \brief Destructor. */
69
70 void writeStartDocument(const std::string& encoding, const std::string& standalone);
71
72 void writeStartElement(const std::string& qName);
73
74 void writeElement(const std::string& qName, const std::string& value);
75
76 void writeElement(const std::string& qName, const double& value);
77
78 void writeElement(const std::string& qName, boost::int32_t value);
79
80 void writeElement(const std::string& qName, boost::uint32_t value);
81
82 void writeElement(const std::string& qName, boost::int64_t value);
83
84 void writeElement(const std::string& qName, boost::uint64_t value);
85
86 void writeAttribute(const std::string& attName, const std::string& value);
87
88 void writeAttribute(const std::string& attName, const double& value);
89
90 void writeAttribute(const std::string& attName, boost::int32_t value);
91
92 void writeAttribute(const std::string& attName, boost::uint32_t value);
93
94 void writeAttribute(const std::string& attName, boost::int64_t value);
95
96 void writeAttribute(const std::string& attName, boost::uint64_t value);
97
98 void writeValue(const std::string& value);
99
100 void writeValue(const double& value);
101
102 void writeValue(boost::int32_t value);
103
104 void writeValue(boost::uint32_t value);
105
106 void writeValue(boost::int64_t value);
107
108 void writeValue(boost::uint64_t value);
109
110 void writeEndElement(const std::string& qName);
111
113
114 std::string getContent() override;
115
116 void setRootNamespaceURI(const std::string& uri);
117
118 private:
119
120 /*!
121 \brief Adds a XML value to the last inserted element.
122
123 \param value Element value. (Input)
124 */
125 void addText(const std::string& qValue);
126
127 private:
128
129 XERCES_CPP_NAMESPACE_QUALIFIER DOMImplementation* m_impl; //!< DOM element - implementation.
130 XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument* m_doc; //!< DOM element - document.
131
132 std::vector<XERCES_CPP_NAMESPACE_QUALIFIER DOMElement*> m_elementSet; //!< Vector that contains all the elements (nodes).
133
134 std::size_t m_indice; //!< Index to build the ElementSet vector.
135 std::size_t m_topIndice; //!< Index of the parent node.
136
137 std::vector<std::size_t> m_topElementSet; //!< This vector gives the parent node of each element.
138 std::vector<std::string> m_topElementNamesSet; //!< This vector gives the parent node of each element.
139
140 std::string m_encoding;
142 std::unique_ptr<xercesc::XMLTranscoder> m_transcoder; //!< The transcoder to be used. TerraLib always expect the encoding to be UTF-8, so we must force it
143 };
144
145 } // end namespace xerces
146} // end namespace te
147
148#endif // __TERRALIB_XERCES_INTERNAL_WRITER_H
149
Writer()
Default constructor.
void writeAttribute(const std::string &attName, boost::uint32_t value)
void writeElement(const std::string &qName, const std::string &value)
void writeAttribute(const std::string &attName, boost::int64_t value)
std::unique_ptr< xercesc::XMLTranscoder > m_transcoder
The transcoder to be used. TerraLib always expect the encoding to be UTF-8, so we must force it.
Definition Writer.h:142
void writeValue(const std::string &value)
void writeStartElement(const std::string &qName)
void writeValue(boost::uint32_t value)
void writeElement(const std::string &qName, boost::uint64_t value)
void writeElement(const std::string &qName, boost::uint32_t value)
void writeStartDocument(const std::string &encoding, const std::string &standalone)
std::vector< std::size_t > m_topElementSet
This vector gives the parent node of each element.
Definition Writer.h:137
void writeAttribute(const std::string &attName, const double &value)
void writeElement(const std::string &qName, boost::int32_t value)
std::string getContent() override
Gets the XML content in a std::string format.
void writeAttribute(const std::string &attName, boost::int32_t value)
void addText(const std::string &qValue)
Adds a XML value to the last inserted element.
void writeValue(boost::int32_t value)
void writeValue(boost::int64_t value)
std::size_t m_indice
Index to build the ElementSet vector.
Definition Writer.h:134
void writeElement(const std::string &qName, const double &value)
std::vector< XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * > m_elementSet
Vector that contains all the elements (nodes).
Definition Writer.h:132
~Writer()
Destructor.
void setRootNamespaceURI(const std::string &uri)
void writeValue(boost::uint64_t value)
std::vector< std::string > m_topElementNamesSet
This vector gives the parent node of each element.
Definition Writer.h:138
void writeAttribute(const std::string &attName, const std::string &value)
std::size_t m_topIndice
Index of the parent node.
Definition Writer.h:135
void writeElement(const std::string &qName, boost::int64_t value)
void writeValue(const double &value)
void writeAttribute(const std::string &attName, boost::uint64_t value)
std::string m_encoding
Definition Writer.h:140
void writeEndElement(const std::string &qName)
XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument * m_doc
DOM element - document.
Definition Writer.h:130
XERCES_CPP_NAMESPACE_QUALIFIER DOMImplementation * m_impl
DOM element - implementation.
Definition Writer.h:129
This class models a XML writer object.
TerraLib.
Proxy configuration file for TerraView (see terraview_config.h).