Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef UVARIANT_H
00021 #define UVARIANT_H
00022
00023 #include "rtabmap/utilite/UtiLiteExp.h"
00024 #include <string>
00025 #include <vector>
00026
00030 class UTILITE_EXP UVariant
00031 {
00032 public:
00033 enum Type{
00034 kBool,
00035 kChar,
00036 kUChar,
00037 kShort,
00038 kUShort,
00039 kInt,
00040 kUInt,
00041 kFloat,
00042 kDouble,
00043 kStr,
00044 kUndef
00045 };
00046 public:
00047 UVariant();
00048 UVariant(const bool & value);
00049 UVariant(const char & value);
00050 UVariant(const unsigned char & value);
00051 UVariant(const short & value);
00052 UVariant(const unsigned short & value);
00053 UVariant(const int & value);
00054 UVariant(const unsigned int & value);
00055 UVariant(const float & value);
00056 UVariant(const double & value);
00057 UVariant(const char * value);
00058 UVariant(const std::string & value);
00059
00060 Type type() const {return type_;}
00061
00062 bool isUndef() const {return type_ == kUndef;}
00063 bool isBool() const {return type_ == kBool;}
00064 bool isChar() const {return type_ == kChar;}
00065 bool isUChar() const {return type_ == kUChar;}
00066 bool isShort() const {return type_ == kShort;}
00067 bool isUShort() const {return type_ == kUShort;}
00068 bool isInt() const {return type_ == kInt;}
00069 bool isUInt() const {return type_ == kUInt;}
00070 bool isFloat() const {return type_ == kFloat;}
00071 bool isDouble() const {return type_ == kDouble;}
00072 bool isStr() const {return type_ == kStr;}
00073
00074 bool toBool() const;
00075 char toChar(bool * ok = 0) const;
00076 unsigned char toUChar(bool * ok = 0) const;
00077 short toShort(bool * ok = 0) const;
00078 unsigned short toUShort(bool * ok = 0) const;
00079 int toInt(bool * ok = 0) const;
00080 unsigned int toUInt(bool * ok = 0) const;
00081 float toFloat(bool * ok = 0) const;
00082 double toDouble(bool * ok = 0) const;
00083 std::string toStr(bool * ok = 0) const;
00084
00085 virtual ~UVariant() {}
00086
00087 private:
00088 Type type_;
00089 std::vector<unsigned char> data_;
00090 };
00091
00092 #endif