All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Reader.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 terralib/xml/Reader.cpp
22 
23  \brief This class models a XML reader object.
24 */
25 
26 // TerraLib
27 #include "Reader.h"
28 
29 // Boost
30 #include <boost/lexical_cast.hpp>
31 
33 {
34  return boost::lexical_cast<boost::int32_t>(getElementValue());
35 }
36 
38 {
39  return boost::lexical_cast<double>(getElementValue());
40 }
41 
43 {
44  std::string value = getElementValue();
45 
46  return (value == "true") || (value == "TRUE");
47 }
48 
49 boost::int32_t te::xml::Reader::getAttrAsInt32(const std::string& name) const
50 {
51  return boost::lexical_cast<boost::int32_t>(getAttr(name));
52 }
53 
54 boost::int32_t te::xml::Reader::getAttrAsInt32(std::size_t i) const
55 {
56  return boost::lexical_cast<boost::int32_t>(getAttr(i));
57 }
58 
59 boost::uint32_t te::xml::Reader::getAttrAsUInt32(std::size_t i) const
60 {
61  return boost::lexical_cast<boost::uint32_t>(getAttr(i));
62 }
63 
64 boost::uint32_t te::xml::Reader::getAttrAsUInt32(const std::string name) const
65 {
66  return boost::lexical_cast<boost::uint32_t>(getAttr(name));
67 }
68 
69 double te::xml::Reader::getAttrAsDouble(const std::string& name) const
70 {
71  return boost::lexical_cast<double>(getAttr(name));
72 }
73 
74 double te::xml::Reader::getAttrAsDouble(std::size_t i) const
75 {
76  return boost::lexical_cast<double>(getAttr(i));
77 }
78 
virtual boost::int32_t getElementValueAsInt32() const
It returns the element data value in the case of VALUE node.
Definition: Reader.cpp:32
This class models a XML reader object.
virtual boost::uint32_t getAttrAsUInt32(std::size_t i) const
It returns the attribute value in the case of an element node with valid attributes.
Definition: Reader.cpp:59
virtual boost::int32_t getAttrAsInt32(const std::string &name) const
It returns the attribute value in the case of an element node with valid attributes.
Definition: Reader.cpp:49
virtual double getElementValueAsDouble() const
It returns the element data value in the case of VALUE node.
Definition: Reader.cpp:37
virtual bool getElementValueAsBoolean() const
It returns the element data value in the case of VALUE node.
Definition: Reader.cpp:42
virtual std::string getElementValue() const =0
It returns the element data value in the case of VALUE node.
virtual double getAttrAsDouble(const std::string &name) const
It returns the attribute value in the case of an element node with valid attributes.
Definition: Reader.cpp:69