UVariant.h
Go to the documentation of this file.
1 /*
2 * utilite is a cross-platform library with
3 * useful utilities for fast and small developing.
4 * Copyright (C) 2010 Mathieu Labbe
5 *
6 * utilite is free library: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * utilite is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #ifndef UVARIANT_H
21 #define UVARIANT_H
22 
23 #include "rtabmap/utilite/UtiLiteExp.h" // DLL export/import defines
24 #include <string>
25 #include <vector>
26 
31 {
32 public:
33  enum Type{
44  kUndef
45  };
46 public:
47  UVariant();
48  UVariant(const bool & value);
49  UVariant(const char & value);
50  UVariant(const unsigned char & value);
51  UVariant(const short & value);
52  UVariant(const unsigned short & value);
53  UVariant(const int & value);
54  UVariant(const unsigned int & value);
55  UVariant(const float & value);
56  UVariant(const double & value);
57  UVariant(const char * value);
58  UVariant(const std::string & value);
59 
60  Type type() const {return type_;}
61 
62  bool isUndef() const {return type_ == kUndef;}
63  bool isBool() const {return type_ == kBool;}
64  bool isChar() const {return type_ == kChar;}
65  bool isUChar() const {return type_ == kUChar;}
66  bool isShort() const {return type_ == kShort;}
67  bool isUShort() const {return type_ == kUShort;}
68  bool isInt() const {return type_ == kInt;}
69  bool isUInt() const {return type_ == kUInt;}
70  bool isFloat() const {return type_ == kFloat;}
71  bool isDouble() const {return type_ == kDouble;}
72  bool isStr() const {return type_ == kStr;}
73 
74  bool toBool() const;
75  char toChar(bool * ok = 0) const;
76  unsigned char toUChar(bool * ok = 0) const;
77  short toShort(bool * ok = 0) const;
78  unsigned short toUShort(bool * ok = 0) const;
79  int toInt(bool * ok = 0) const;
80  unsigned int toUInt(bool * ok = 0) const;
81  float toFloat(bool * ok = 0) const;
82  double toDouble(bool * ok = 0) const;
83  std::string toStr(bool * ok = 0) const;
84 
85  virtual ~UVariant() {}
86 
87 private:
89  std::vector<unsigned char> data_;
90 };
91 
92 #endif /* UVARIANT_H */
bool isShort() const
Definition: UVariant.h:66
bool isBool() const
Definition: UVariant.h:63
#define UTILITE_EXP
Definition: UtiLiteExp.h:33
bool isUShort() const
Definition: UVariant.h:67
virtual ~UVariant()
Definition: UVariant.h:85
bool isFloat() const
Definition: UVariant.h:70
std::vector< unsigned char > data_
Definition: UVariant.h:89
bool isInt() const
Definition: UVariant.h:68
bool isStr() const
Definition: UVariant.h:72
bool isDouble() const
Definition: UVariant.h:71
bool isUInt() const
Definition: UVariant.h:69
bool isUChar() const
Definition: UVariant.h:65
bool isChar() const
Definition: UVariant.h:64
Type type_
Definition: UVariant.h:88
bool isUndef() const
Definition: UVariant.h:62
Type type() const
Definition: UVariant.h:60


rtabmap
Author(s): Mathieu Labbe
autogenerated on Wed Jun 5 2019 22:43:41