StrToXMLCh.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 StrToXMLCh.h
22 
23  \brief A class for converting a standard string to a Xerces string (XMLCh).
24 */
25 
26 #ifndef __TERRALIB_XERCES_INTERNAL_STRTOXMLCH_H
27 #define __TERRALIB_XERCES_INTERNAL_STRTOXMLCH_H
28 
29 // STL
30 #include <cassert>
31 #include <string>
32 
33 // Xerces-C++
34 #include <xercesc/util/XMLString.hpp>
35 
36 namespace te
37 {
38  namespace xerces
39  {
40  /*!
41  \class StrToXMLCh
42 
43  \brief A class for converting a standard string to a Xerces string (XMLCh).
44 
45  \sa XMLChToStr
46  */
47  class StrToXMLCh
48  {
49  public:
50 
51  /*!
52  \brief It converts the standard string to an internal XML string.
53 
54  \param str A standard string.
55  */
56  StrToXMLCh(const std::string& str);
57 
58  /*! \brief Destructor */
59  ~StrToXMLCh();
60 
61  /*!
62  \brief It return the standard string representation.
63 
64  \return The standard string representation.
65  */
66  const XMLCh* getXMLCh() const;
67 
68  private:
69 
70  XMLCh* m_xmlch; //!< The internal XML string.
71  };
72 
73  inline StrToXMLCh::StrToXMLCh(const std::string& str)
74  : m_xmlch(0)
75  {
76  m_xmlch = xercesc::XMLString::transcode(str.c_str());
77  }
78 
80  {
81  xercesc::XMLString::release(&m_xmlch);
82  }
83 
84  inline const XMLCh* StrToXMLCh::getXMLCh() const
85  {
86  return m_xmlch;
87  }
88 
89  } // end namespace xerces
90 } // end namespace te
91 
92 #endif // __TERRALIB_XERCES_INTERNAL_STRTOXMLCH_H
93 
A class for converting a standard string to a Xerces string (XMLCh).
Definition: StrToXMLCh.h:47
~StrToXMLCh()
Destructor.
Definition: StrToXMLCh.h:79
XMLCh * m_xmlch
The internal XML string.
Definition: StrToXMLCh.h:70
const XMLCh * getXMLCh() const
It return the standard string representation.
Definition: StrToXMLCh.h:84
URI C++ Library.
StrToXMLCh(const std::string &str)
It converts the standard string to an internal XML string.
Definition: StrToXMLCh.h:73