UVariant.h
Go to the documentation of this file.
00001 /*
00002 *  utilite is a cross-platform library with
00003 *  useful utilities for fast and small developing.
00004 *  Copyright (C) 2010  Mathieu Labbe
00005 *
00006 *  utilite is free library: you can redistribute it and/or modify
00007 *  it under the terms of the GNU Lesser General Public License as published by
00008 *  the Free Software Foundation, either version 3 of the License, or
00009 *  (at your option) any later version.
00010 *
00011 *  utilite is distributed in the hope that it will be useful,
00012 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 *  GNU Lesser General Public License for more details.
00015 *
00016 *  You should have received a copy of the GNU Lesser General Public License
00017 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
00018 */
00019 
00020 #ifndef UVARIANT_H
00021 #define UVARIANT_H
00022 
00023 #include "rtabmap/utilite/UtiLiteExp.h" // DLL export/import defines
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 /* UVARIANT_H */


rtabmap
Author(s): Mathieu Labbe
autogenerated on Sat Jul 23 2016 11:44:28