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 <string>
35 #include <vector>
36 
37 // Xerces-C++
38 #include <xercesc/util/XercesDefs.hpp>
39 
40 // Forward declaration
41 XERCES_CPP_NAMESPACE_BEGIN
42 class DOMDocument;
43 class DOMElement;
44 class DOMImplementation;
45 XERCES_CPP_NAMESPACE_END
46 
47 namespace te
48 {
49  namespace xerces
50  {
51 // Forward declaration
52 
53  /*!
54  \class AbstractWriter
55 
56  \brief A class that models a XML writer object built on top of Xerces-C++
57  */
59  {
60  public:
61 
62  /*! \brief Default constructor. */
63  Writer();
64 
65  /*! \brief Destructor. */
66  ~Writer();
67 
68  void writeStartDocument(const std::string& encoding, const std::string& standalone);
69 
70  void writeStartElement(const std::string& qName);
71 
72  void writeElement(const std::string& qName, const std::string& value);
73 
74  void writeElement(const std::string& qName, const double& value);
75 
76  void writeElement(const std::string& qName, boost::int32_t value);
77 
78  void writeElement(const std::string& qName, boost::uint32_t value);
79 
80  void writeElement(const std::string& qName, boost::int64_t value);
81 
82  void writeElement(const std::string& qName, boost::uint64_t value);
83 
84  void writeAttribute(const std::string& attName, const std::string& value);
85 
86  void writeAttribute(const std::string& attName, const double& value);
87 
88  void writeAttribute(const std::string& attName, boost::int32_t value);
89 
90  void writeAttribute(const std::string& attName, boost::uint32_t value);
91 
92  void writeAttribute(const std::string& attName, boost::int64_t value);
93 
94  void writeAttribute(const std::string& attName, boost::uint64_t value);
95 
96  void writeValue(const std::string& value);
97 
98  void writeValue(const double& value);
99 
100  void writeValue(boost::int32_t value);
101 
102  void writeValue(boost::uint32_t value);
103 
104  void writeValue(boost::int64_t value);
105 
106  void writeValue(boost::uint64_t value);
107 
108  void writeEndElement(const std::string& qName);
109 
110  void writeToFile();
111 
112  void setRootNamespaceURI(const std::string& uri);
113 
114  private:
115 
116  /*!
117  \brief Adds a XML value to the last inserted element.
118 
119  \param value Element value. (Input)
120  */
121  void addText(const std::string& qValue);
122 
123  private:
124 
125  XERCES_CPP_NAMESPACE_QUALIFIER DOMImplementation* m_impl; //!< DOM element - implementation.
126  XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument* m_doc; //!< DOM element - document.
127 
128  std::vector<XERCES_CPP_NAMESPACE_QUALIFIER DOMElement*> m_elementSet; //!< Vector that contains all the elements (nodes).
129 
130  std::size_t m_indice; //!< Index to build the ElementSet vector.
131  std::size_t m_topIndice; //!< Index of the parent node.
132 
133  std::vector<std::size_t> m_topElementSet; //!< This vector gives the parent node of each element.
134  std::vector<std::string> m_topElementNamesSet; //!< This vector gives the parent node of each element.
135 
136  std::string m_encoding;
138  };
139 
140  } // end namespace xerces
141 } // end namespace te
142 
143 #endif // __TERRALIB_XERCES_INTERNAL_WRITER_H
144 
std::vector< std::string > m_topElementNamesSet
This vector gives the parent node of each element.
Definition: Writer.h:134
std::size_t m_indice
Index to build the ElementSet vector.
Definition: Writer.h:130
void writeStartElement(const std::string &qName)
std::vector< std::size_t > m_topElementSet
This vector gives the parent node of each element.
Definition: Writer.h:133
void addText(const std::string &qValue)
Adds a XML value to the last inserted element.
void writeStartDocument(const std::string &encoding, const std::string &standalone)
This class models a XML writer object.
void writeElement(const std::string &qName, const std::string &value)
URI C++ Library.
~Writer()
Destructor.
std::vector< XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * > m_elementSet
Vector that contains all the elements (nodes).
Definition: Writer.h:128
std::size_t m_topIndice
Index of the parent node.
Definition: Writer.h:131
XERCES_CPP_NAMESPACE_QUALIFIER DOMImplementation * m_impl
DOM element - implementation.
Definition: Writer.h:125
Writer()
Default constructor.
void writeEndElement(const std::string &qName)
std::string m_encoding
Definition: Writer.h:136
void writeValue(const std::string &value)
void writeAttribute(const std::string &attName, const std::string &value)
void setRootNamespaceURI(const std::string &uri)
XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument * m_doc
DOM element - document.
Definition: Writer.h:126