Robotics Library  0.6.2
Object.h
Go to the documentation of this file.
1 //
2 // Copyright (c) 2009, Markus Rickert
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are met:
7 //
8 // * Redistributions of source code must retain the above copyright notice,
9 // this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright notice,
11 // this list of conditions and the following disclaimer in the documentation
12 // and/or other materials provided with the distribution.
13 //
14 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
18 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24 // POSSIBILITY OF SUCH DAMAGE.
25 //
26 
27 #ifndef _RL_XML_OBJECT_H_
28 #define _RL_XML_OBJECT_H_
29 
30 #include <string>
31 #include <boost/shared_ptr.hpp>
32 #include <libxml/xpath.h>
33 
34 #include "Node.h"
35 
36 namespace rl
37 {
38  namespace xml
39  {
40  class Object
41  {
42  public:
43  Object() :
44  object()
45  {
46  }
47 
48  Object(xmlXPathObjectPtr object) :
49  object(object, xmlXPathFreeObject)
50  {
51  }
52 
53  virtual ~Object()
54  {
55  }
56 
57  bool getBoolval() const
58  {
59  return (1 == this->object->boolval) ? true : false;
60  }
61 
62  double getFloatval() const
63  {
64  return this->object->floatval;
65  }
66 
67  double getFloatval(const double& val) const
68  {
69  return 0 == xmlXPathIsNaN(this->object->floatval) ? this->object->floatval : val;
70  }
71 
72  int getNodeNr() const
73  {
74  return this->object->nodesetval->nodeNr;
75  }
76 
77  Node getNodeTab(const int& i) const
78  {
79  return Node(this->object->nodesetval->nodeTab[i]);
80  }
81 
82  ::std::string getStringval() const
83  {
84  return reinterpret_cast< char* >(this->object->stringval);
85  }
86 
87  xmlXPathObjectType getType() const
88  {
89  return this->object->type;
90  }
91 
92  xmlXPathObjectPtr operator()() const
93  {
94  return this->object.get();
95  }
96 
97  protected:
98 
99  private:
100  ::boost::shared_ptr< xmlXPathObject > object;
101  };
102  }
103 }
104 
105 #endif // _RL_XML_PATH_H_
rl::xml::Object::getType
xmlXPathObjectType getType() const
Definition: Object.h:87
rl::xml::Object::getNodeNr
int getNodeNr() const
Definition: Object.h:72
rl::xml::Object::Object
Object(xmlXPathObjectPtr object)
Definition: Object.h:48
rl::xml::Object::Object
Object()
Definition: Object.h:43
rl::xml::Object::getFloatval
double getFloatval(const double &val) const
Definition: Object.h:67
rl::xml::Object::getNodeTab
Node getNodeTab(const int &i) const
Definition: Object.h:77
rl::xml::Object::getBoolval
bool getBoolval() const
Definition: Object.h:57
rl::xml::Object::getFloatval
double getFloatval() const
Definition: Object.h:62
rl::xml::Object::object
::boost::shared_ptr< xmlXPathObject > object
Definition: Object.h:100
rl::xml::Object
Definition: Object.h:41
rl::xml::Node
Definition: Node.h:45
rl::xml::Object::getStringval
::std::string getStringval() const
Definition: Object.h:82
Node.h
rl::xml::Object::~Object
virtual ~Object()
Definition: Object.h:53
rl::xml::Object::operator()
xmlXPathObjectPtr operator()() const
Definition: Object.h:92
rl
Definition: Ati.cpp:35