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{
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 */
bool isInt() const
Definition: UVariant.h:84
bool isUChar() const
Definition: UVariant.h:81
bool isDouble() const
Definition: UVariant.h:87
bool isChar() const
Definition: UVariant.h:80
bool isUShort() const
Definition: UVariant.h:83
bool isUInt() const
Definition: UVariant.h:85
#define UTILITE_EXP
Definition: UtiLiteExp.h:33
bool isUndef() const
Definition: UVariant.h:78
bool isUShortArray() const
Definition: UVariant.h:92
virtual ~UVariant()
Definition: UVariant.h:117
bool isBool() const
Definition: UVariant.h:79
bool isStr() const
Definition: UVariant.h:88
bool isFloatArray() const
Definition: UVariant.h:95
std::vector< unsigned char > data_
Definition: UVariant.h:121
bool isCharArray() const
Definition: UVariant.h:89
bool isFloat() const
Definition: UVariant.h:86
bool isUCharArray() const
Definition: UVariant.h:90
bool isIntArray() const
Definition: UVariant.h:93
bool isDoubleArray() const
Definition: UVariant.h:96
bool isShort() const
Definition: UVariant.h:82
bool isShortArray() const
Definition: UVariant.h:91
bool isUIntArray() const
Definition: UVariant.h:94
Type type_
Definition: UVariant.h:120
Type type() const
Definition: UVariant.h:76


rtabmap
Author(s): Mathieu Labbe
autogenerated on Mon Jan 23 2023 03:38:58