RTAB-Map 0.23.10
Real-Time Appearance-Based Mapping
Loading...
Searching...
No Matches
UVariant Class Reference

A variant type that can hold values of different types. More...

#include <UVariant.h>

Public Types

enum  Type {
  kBool , kChar , kUChar , kShort ,
  kUShort , kInt , kUInt , kFloat ,
  kDouble , kStr , kCharArray , kUCharArray ,
  kShortArray , kUShortArray , kIntArray , kUIntArray ,
  kFloatArray , kDoubleArray , kUndef
}
 Enumeration of supported data types. More...
 

Public Member Functions

 UVariant ()
 Default constructor Creates an undefined variant.
 
 UVariant (const bool &value)
 Constructor from bool.
 
 UVariant (const signed char &value)
 Constructor from signed char.
 
 UVariant (const unsigned char &value)
 Constructor from unsigned char.
 
 UVariant (const short &value)
 Constructor from short.
 
 UVariant (const unsigned short &value)
 Constructor from unsigned short.
 
 UVariant (const int &value)
 Constructor from int.
 
 UVariant (const unsigned int &value)
 Constructor from unsigned int.
 
 UVariant (const float &value)
 Constructor from float.
 
 UVariant (const double &value)
 Constructor from double.
 
 UVariant (const char *value)
 Constructor from C string.
 
 UVariant (const std::string &value)
 Constructor from std::string.
 
 UVariant (const std::vector< signed char > &value)
 Constructor from array of signed char.
 
 UVariant (const std::vector< unsigned char > &value)
 Constructor from array of unsigned char.
 
 UVariant (const std::vector< short > &value)
 Constructor from array of short.
 
 UVariant (const std::vector< unsigned short > &value)
 Constructor from array of unsigned short.
 
 UVariant (const std::vector< int > &value)
 Constructor from array of int.
 
 UVariant (const std::vector< unsigned int > &value)
 Constructor from array of unsigned int.
 
 UVariant (const std::vector< float > &value)
 Constructor from array of float.
 
 UVariant (const std::vector< double > &value)
 Constructor from array of double.
 
Type type () const
 Get the type of the stored value.
 
bool isUndef () const
 Check if the variant is undefined.
 
bool isBool () const
 Check if the variant is a bool.
 
bool isChar () const
 Check if the variant is a signed char.
 
bool isUChar () const
 Check if the variant is an unsigned char.
 
bool isShort () const
 Check if the variant is a short.
 
bool isUShort () const
 Check if the variant is an unsigned short.
 
bool isInt () const
 Check if the variant is an int.
 
bool isUInt () const
 Check if the variant is an unsigned int.
 
bool isFloat () const
 Check if the variant is a float.
 
bool isDouble () const
 Check if the variant is a double.
 
bool isStr () const
 Check if the variant is a string.
 
bool isCharArray () const
 Check if the variant is an array of signed char.
 
bool isUCharArray () const
 Check if the variant is an array of unsigned char.
 
bool isShortArray () const
 Check if the variant is an array of short.
 
bool isUShortArray () const
 Check if the variant is an array of unsigned short.
 
bool isIntArray () const
 Check if the variant is an array of int.
 
bool isUIntArray () const
 Check if the variant is an array of unsigned int.
 
bool isFloatArray () const
 Check if the variant is an array of float.
 
bool isDoubleArray () const
 Check if the variant is an array of double.
 
bool toBool () const
 Convert the variant to bool.
 
signed char toChar (bool *ok=0) const
 Convert the variant to signed char.
 
unsigned char toUChar (bool *ok=0) const
 Convert the variant to unsigned char.
 
short toShort (bool *ok=0) const
 Convert the variant to short.
 
unsigned short toUShort (bool *ok=0) const
 Convert the variant to unsigned short.
 
int toInt (bool *ok=0) const
 Convert the variant to int.
 
unsigned int toUInt (bool *ok=0) const
 Convert the variant to unsigned int.
 
float toFloat (bool *ok=0) const
 Convert the variant to float.
 
double toDouble (bool *ok=0) const
 Convert the variant to double.
 
std::string toStr (bool *ok=0) const
 Convert the variant to string.
 
std::vector< signed char > toCharArray (bool *ok=0) const
 Convert the variant to array of signed char.
 
std::vector< unsigned char > toUCharArray (bool *ok=0) const
 Convert the variant to array of unsigned char.
 
std::vector< short > toShortArray (bool *ok=0) const
 Convert the variant to array of short.
 
std::vector< unsigned short > toUShortArray (bool *ok=0) const
 Convert the variant to array of unsigned short.
 
std::vector< int > toIntArray (bool *ok=0) const
 Convert the variant to array of int.
 
std::vector< unsigned int > toUIntArray (bool *ok=0) const
 Convert the variant to array of unsigned int.
 
std::vector< float > toFloatArray (bool *ok=0) const
 Convert the variant to array of float.
 
std::vector< double > toDoubleArray (bool *ok=0) const
 Convert the variant to array of double.
 
virtual ~UVariant ()
 Virtual destructor.
 

Detailed Description

A variant type that can hold values of different types.

UVariant is a type-safe container that can store values of various types including booleans, integers, floats, strings, and arrays. It provides methods to check the stored type and convert to other types.

Definition at line 53 of file UVariant.h.

Member Enumeration Documentation

◆ Type

Enumeration of supported data types.

Enumerator
kBool 

Boolean type

kChar 

Signed char type

kUChar 

Unsigned char type

kShort 

Short integer type

kUShort 

Unsigned short integer type

kInt 

Integer type

kUInt 

Unsigned integer type

kFloat 

Float type

kDouble 

Double type

kStr 

String type

kCharArray 

Array of signed char

kUCharArray 

Array of unsigned char

kShortArray 

Array of short

kUShortArray 

Array of unsigned short

kIntArray 

Array of int

kUIntArray 

Array of unsigned int

kFloatArray 

Array of float

kDoubleArray 

Array of double

kUndef 

Undefined type (default)

Definition at line 60 of file UVariant.h.

Constructor & Destructor Documentation

◆ UVariant() [1/19]

UVariant::UVariant ( const bool &  value)

Constructor from bool.

Parameters
valuethe boolean value

◆ UVariant() [2/19]

UVariant::UVariant ( const signed char &  value)

Constructor from signed char.

Parameters
valuethe signed char value

◆ UVariant() [3/19]

UVariant::UVariant ( const unsigned char &  value)

Constructor from unsigned char.

Parameters
valuethe unsigned char value

◆ UVariant() [4/19]

UVariant::UVariant ( const short &  value)

Constructor from short.

Parameters
valuethe short value

◆ UVariant() [5/19]

UVariant::UVariant ( const unsigned short &  value)

Constructor from unsigned short.

Parameters
valuethe unsigned short value

◆ UVariant() [6/19]

UVariant::UVariant ( const int &  value)

Constructor from int.

Parameters
valuethe integer value

◆ UVariant() [7/19]

UVariant::UVariant ( const unsigned int &  value)

Constructor from unsigned int.

Parameters
valuethe unsigned integer value

◆ UVariant() [8/19]

UVariant::UVariant ( const float &  value)

Constructor from float.

Parameters
valuethe float value

◆ UVariant() [9/19]

UVariant::UVariant ( const double &  value)

Constructor from double.

Parameters
valuethe double value

◆ UVariant() [10/19]

UVariant::UVariant ( const char *  value)

Constructor from C string.

Parameters
valuethe C string value

◆ UVariant() [11/19]

UVariant::UVariant ( const std::string &  value)

Constructor from std::string.

Parameters
valuethe string value

◆ UVariant() [12/19]

UVariant::UVariant ( const std::vector< signed char > &  value)

Constructor from array of signed char.

Parameters
valuethe array of signed char

◆ UVariant() [13/19]

UVariant::UVariant ( const std::vector< unsigned char > &  value)

Constructor from array of unsigned char.

Parameters
valuethe array of unsigned char

◆ UVariant() [14/19]

UVariant::UVariant ( const std::vector< short > &  value)

Constructor from array of short.

Parameters
valuethe array of short

◆ UVariant() [15/19]

UVariant::UVariant ( const std::vector< unsigned short > &  value)

Constructor from array of unsigned short.

Parameters
valuethe array of unsigned short

◆ UVariant() [16/19]

UVariant::UVariant ( const std::vector< int > &  value)

Constructor from array of int.

Parameters
valuethe array of int

◆ UVariant() [17/19]

UVariant::UVariant ( const std::vector< unsigned int > &  value)

Constructor from array of unsigned int.

Parameters
valuethe array of unsigned int

◆ UVariant() [18/19]

UVariant::UVariant ( const std::vector< float > &  value)

Constructor from array of float.

Parameters
valuethe array of float

◆ UVariant() [19/19]

UVariant::UVariant ( const std::vector< double > &  value)

Constructor from array of double.

Parameters
valuethe array of double

◆ ~UVariant()

virtual UVariant::~UVariant ( )
inlinevirtual

Virtual destructor.

Definition at line 450 of file UVariant.h.

Member Function Documentation

◆ type()

Type UVariant::type ( ) const
inline

Get the type of the stored value.

Returns
the Type enum value

Definition at line 206 of file UVariant.h.

◆ isUndef()

bool UVariant::isUndef ( ) const
inline

Check if the variant is undefined.

Returns
true if type is kUndef

Definition at line 212 of file UVariant.h.

◆ isBool()

bool UVariant::isBool ( ) const
inline

Check if the variant is a bool.

Returns
true if type is kBool

Definition at line 218 of file UVariant.h.

◆ isChar()

bool UVariant::isChar ( ) const
inline

Check if the variant is a signed char.

Returns
true if type is kChar

Definition at line 224 of file UVariant.h.

◆ isUChar()

bool UVariant::isUChar ( ) const
inline

Check if the variant is an unsigned char.

Returns
true if type is kUChar

Definition at line 230 of file UVariant.h.

◆ isShort()

bool UVariant::isShort ( ) const
inline

Check if the variant is a short.

Returns
true if type is kShort

Definition at line 236 of file UVariant.h.

◆ isUShort()

bool UVariant::isUShort ( ) const
inline

Check if the variant is an unsigned short.

Returns
true if type is kUShort

Definition at line 242 of file UVariant.h.

◆ isInt()

bool UVariant::isInt ( ) const
inline

Check if the variant is an int.

Returns
true if type is kInt

Definition at line 248 of file UVariant.h.

◆ isUInt()

bool UVariant::isUInt ( ) const
inline

Check if the variant is an unsigned int.

Returns
true if type is kUInt

Definition at line 254 of file UVariant.h.

◆ isFloat()

bool UVariant::isFloat ( ) const
inline

Check if the variant is a float.

Returns
true if type is kFloat

Definition at line 260 of file UVariant.h.

◆ isDouble()

bool UVariant::isDouble ( ) const
inline

Check if the variant is a double.

Returns
true if type is kDouble

Definition at line 266 of file UVariant.h.

◆ isStr()

bool UVariant::isStr ( ) const
inline

Check if the variant is a string.

Returns
true if type is kStr

Definition at line 272 of file UVariant.h.

◆ isCharArray()

bool UVariant::isCharArray ( ) const
inline

Check if the variant is an array of signed char.

Returns
true if type is kCharArray

Definition at line 278 of file UVariant.h.

◆ isUCharArray()

bool UVariant::isUCharArray ( ) const
inline

Check if the variant is an array of unsigned char.

Returns
true if type is kUCharArray

Definition at line 284 of file UVariant.h.

◆ isShortArray()

bool UVariant::isShortArray ( ) const
inline

Check if the variant is an array of short.

Returns
true if type is kShortArray

Definition at line 290 of file UVariant.h.

◆ isUShortArray()

bool UVariant::isUShortArray ( ) const
inline

Check if the variant is an array of unsigned short.

Returns
true if type is kUShortArray

Definition at line 296 of file UVariant.h.

◆ isIntArray()

bool UVariant::isIntArray ( ) const
inline

Check if the variant is an array of int.

Returns
true if type is kIntArray

Definition at line 302 of file UVariant.h.

◆ isUIntArray()

bool UVariant::isUIntArray ( ) const
inline

Check if the variant is an array of unsigned int.

Returns
true if type is kUIntArray

Definition at line 308 of file UVariant.h.

◆ isFloatArray()

bool UVariant::isFloatArray ( ) const
inline

Check if the variant is an array of float.

Returns
true if type is kFloatArray

Definition at line 314 of file UVariant.h.

◆ isDoubleArray()

bool UVariant::isDoubleArray ( ) const
inline

Check if the variant is an array of double.

Returns
true if type is kDoubleArray

Definition at line 320 of file UVariant.h.

◆ toBool()

bool UVariant::toBool ( ) const

Convert the variant to bool.

Returns
the boolean value

◆ toChar()

signed char UVariant::toChar ( bool *  ok = 0) const

Convert the variant to signed char.

Parameters
okpointer to bool to indicate success (optional)
Returns
the signed char value

◆ toUChar()

unsigned char UVariant::toUChar ( bool *  ok = 0) const

Convert the variant to unsigned char.

Parameters
okpointer to bool to indicate success (optional)
Returns
the unsigned char value

◆ toShort()

short UVariant::toShort ( bool *  ok = 0) const

Convert the variant to short.

Parameters
okpointer to bool to indicate success (optional)
Returns
the short value

◆ toUShort()

unsigned short UVariant::toUShort ( bool *  ok = 0) const

Convert the variant to unsigned short.

Parameters
okpointer to bool to indicate success (optional)
Returns
the unsigned short value

◆ toInt()

int UVariant::toInt ( bool *  ok = 0) const

Convert the variant to int.

Parameters
okpointer to bool to indicate success (optional)
Returns
the integer value

◆ toUInt()

unsigned int UVariant::toUInt ( bool *  ok = 0) const

Convert the variant to unsigned int.

Parameters
okpointer to bool to indicate success (optional)
Returns
the unsigned integer value

◆ toFloat()

float UVariant::toFloat ( bool *  ok = 0) const

Convert the variant to float.

Parameters
okpointer to bool to indicate success (optional)
Returns
the float value

◆ toDouble()

double UVariant::toDouble ( bool *  ok = 0) const

Convert the variant to double.

Parameters
okpointer to bool to indicate success (optional)
Returns
the double value

◆ toStr()

std::string UVariant::toStr ( bool *  ok = 0) const

Convert the variant to string.

Parameters
okpointer to bool to indicate success (optional)
Returns
the string value

◆ toCharArray()

std::vector< signed char > UVariant::toCharArray ( bool *  ok = 0) const

Convert the variant to array of signed char.

Parameters
okpointer to bool to indicate success (optional)
Returns
the array of signed char

◆ toUCharArray()

std::vector< unsigned char > UVariant::toUCharArray ( bool *  ok = 0) const

Convert the variant to array of unsigned char.

Parameters
okpointer to bool to indicate success (optional)
Returns
the array of unsigned char

◆ toShortArray()

std::vector< short > UVariant::toShortArray ( bool *  ok = 0) const

Convert the variant to array of short.

Parameters
okpointer to bool to indicate success (optional)
Returns
the array of short

◆ toUShortArray()

std::vector< unsigned short > UVariant::toUShortArray ( bool *  ok = 0) const

Convert the variant to array of unsigned short.

Parameters
okpointer to bool to indicate success (optional)
Returns
the array of unsigned short

◆ toIntArray()

std::vector< int > UVariant::toIntArray ( bool *  ok = 0) const

Convert the variant to array of int.

Parameters
okpointer to bool to indicate success (optional)
Returns
the array of int

◆ toUIntArray()

std::vector< unsigned int > UVariant::toUIntArray ( bool *  ok = 0) const

Convert the variant to array of unsigned int.

Parameters
okpointer to bool to indicate success (optional)
Returns
the array of unsigned int

◆ toFloatArray()

std::vector< float > UVariant::toFloatArray ( bool *  ok = 0) const

Convert the variant to array of float.

Parameters
okpointer to bool to indicate success (optional)
Returns
the array of float

◆ toDoubleArray()

std::vector< double > UVariant::toDoubleArray ( bool *  ok = 0) const

Convert the variant to array of double.

Parameters
okpointer to bool to indicate success (optional)
Returns
the array of double

The documentation for this class was generated from the following file: