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/utilite_export.h" // DLL export/import defines
24 #include <string>
25 #include <vector>
26 
30 class UTILITE_EXPORT UVariant
31 {
32 public:
33  enum Type{
52  kUndef
53  };
54 public:
55  UVariant();
56  UVariant(const bool & value);
57  UVariant(const char & value);
58  UVariant(const unsigned char & value);
59  UVariant(const short & value);
60  UVariant(const unsigned short & value);
61  UVariant(const int & value);
62  UVariant(const unsigned int & value);
63  UVariant(const float & value);
64  UVariant(const double & value);
65  UVariant(const char * value);
66  UVariant(const std::string & value);
67  UVariant(const std::vector<char> & value);
68  UVariant(const std::vector<unsigned char> & value);
69  UVariant(const std::vector<short> & value);
70  UVariant(const std::vector<unsigned short> & value);
71  UVariant(const std::vector<int> & value);
72  UVariant(const std::vector<unsigned int> & value);
73  UVariant(const std::vector<float> & value);
74  UVariant(const std::vector<double> & value);
75 
76  Type type() const {return type_;}
77 
78  bool isUndef() const {return type_ == kUndef;}
79  bool isBool() const {return type_ == kBool;}
80  bool isChar() const {return type_ == kChar;}
81  bool isUChar() const {return type_ == kUChar;}
82  bool isShort() const {return type_ == kShort;}
83  bool isUShort() const {return type_ == kUShort;}
84  bool isInt() const {return type_ == kInt;}
85  bool isUInt() const {return type_ == kUInt;}
86  bool isFloat() const {return type_ == kFloat;}
87  bool isDouble() const {return type_ == kDouble;}
88  bool isStr() const {return type_ == kStr;}
89  bool isCharArray() const {return type_ == kCharArray;}
90  bool isUCharArray() const {return type_ == kUCharArray;}
91  bool isShortArray() const {return type_ == kShortArray;}
92  bool isUShortArray() const {return type_ == kUShortArray;}
93  bool isIntArray() const {return type_ == kIntArray;}
94  bool isUIntArray() const {return type_ == kUIntArray;}
95  bool isFloatArray() const {return type_ == kFloatArray;}
96  bool isDoubleArray() const {return type_ == kDoubleArray;}
97 
98  bool toBool() const;
99  char toChar(bool * ok = 0) const;
100  unsigned char toUChar(bool * ok = 0) const;
101  short toShort(bool * ok = 0) const;
102  unsigned short toUShort(bool * ok = 0) const;
103  int toInt(bool * ok = 0) const;
104  unsigned int toUInt(bool * ok = 0) const;
105  float toFloat(bool * ok = 0) const;
106  double toDouble(bool * ok = 0) const;
107  std::string toStr(bool * ok = 0) const;
108  std::vector<char> toCharArray(bool * ok = 0) const;
109  std::vector<unsigned char> toUCharArray(bool * ok = 0) const;
110  std::vector<short> toShortArray(bool * ok = 0) const;
111  std::vector<unsigned short> toUShortArray(bool * ok = 0) const;
112  std::vector<int> toIntArray(bool * ok = 0) const;
113  std::vector<unsigned int> toUIntArray(bool * ok = 0) const;
114  std::vector<float> toFloatArray(bool * ok = 0) const;
115  std::vector<double> toDoubleArray(bool * ok = 0) const;
116 
117  virtual ~UVariant() {}
118 
119 private:
121  std::vector<unsigned char> data_;
122 };
123 
124 #endif /* UVARIANT_H */
UVariant::kUShortArray
@ kUShortArray
Definition: UVariant.h:47
UVariant::kDoubleArray
@ kDoubleArray
Definition: UVariant.h:51
UVariant::isInt
bool isInt() const
Definition: UVariant.h:84
UVariant::isUIntArray
bool isUIntArray() const
Definition: UVariant.h:94
UVariant::kStr
@ kStr
Definition: UVariant.h:43
UVariant::isDouble
bool isDouble() const
Definition: UVariant.h:87
UVariant::isUCharArray
bool isUCharArray() const
Definition: UVariant.h:90
UVariant::~UVariant
virtual ~UVariant()
Definition: UVariant.h:117
UVariant::kUIntArray
@ kUIntArray
Definition: UVariant.h:49
UVariant::kDouble
@ kDouble
Definition: UVariant.h:42
UVariant::kFloatArray
@ kFloatArray
Definition: UVariant.h:50
UVariant::isChar
bool isChar() const
Definition: UVariant.h:80
UVariant::isIntArray
bool isIntArray() const
Definition: UVariant.h:93
UVariant::isFloat
bool isFloat() const
Definition: UVariant.h:86
UVariant::kBool
@ kBool
Definition: UVariant.h:34
UVariant::isFloatArray
bool isFloatArray() const
Definition: UVariant.h:95
UVariant::kIntArray
@ kIntArray
Definition: UVariant.h:48
UVariant::isUInt
bool isUInt() const
Definition: UVariant.h:85
UVariant::kUChar
@ kUChar
Definition: UVariant.h:36
Type
UVariant::kInt
@ kInt
Definition: UVariant.h:39
UVariant::isBool
bool isBool() const
Definition: UVariant.h:79
UVariant::kCharArray
@ kCharArray
Definition: UVariant.h:44
UVariant::isCharArray
bool isCharArray() const
Definition: UVariant.h:89
UVariant::isUShortArray
bool isUShortArray() const
Definition: UVariant.h:92
UVariant::isStr
bool isStr() const
Definition: UVariant.h:88
UVariant::isShort
bool isShort() const
Definition: UVariant.h:82
UVariant::kChar
@ kChar
Definition: UVariant.h:35
UVariant::kFloat
@ kFloat
Definition: UVariant.h:41
UVariant::kShortArray
@ kShortArray
Definition: UVariant.h:46
UVariant::kUCharArray
@ kUCharArray
Definition: UVariant.h:45
UVariant
Definition: UVariant.h:30
UVariant::kUShort
@ kUShort
Definition: UVariant.h:38
UVariant::kShort
@ kShort
Definition: UVariant.h:37
UVariant::isShortArray
bool isShortArray() const
Definition: UVariant.h:91
UVariant::kUInt
@ kUInt
Definition: UVariant.h:40
UVariant::type
Type type() const
Definition: UVariant.h:76
UVariant::isUndef
bool isUndef() const
Definition: UVariant.h:78
UVariant::isDoubleArray
bool isDoubleArray() const
Definition: UVariant.h:96
UVariant::type_
Type type_
Definition: UVariant.h:120
UVariant::isUChar
bool isUChar() const
Definition: UVariant.h:81
UVariant::isUShort
bool isUShort() const
Definition: UVariant.h:83
UVariant::data_
std::vector< unsigned char > data_
Definition: UVariant.h:121


rtabmap
Author(s): Mathieu Labbe
autogenerated on Thu Jul 25 2024 02:50:24