RADLib
RADical C++ application framework
RADCore::RADVariant Class Reference

Small value container used by models, futures, settings, and database rows. More...

#include <RADCore.h>

Public Member Functions

 RADVariant ()
 Creates an invalid variant. More...
 
 RADVariant (bool value)
 Stores a boolean. More...
 
 RADVariant (int value)
 Stores an integer as Int64. More...
 
 RADVariant (int64_t value)
 Stores a signed 64-bit integer. More...
 
 RADVariant (double value)
 Stores a double. More...
 
 RADVariant (const char *value)
 Stores a C string as std::string. More...
 
 RADVariant (std::string value)
 Stores a string. More...
 
 RADVariant (std::vector< uint8_t > value)
 Stores a byte array. More...
 
VariantType type () const
 Returns the current variant type. More...
 
bool isValid () const
 Returns true when the variant stores a non-invalid value. More...
 
bool toBool (bool defaultValue=false) const
 Converts to bool or returns defaultValue. More...
 
int64_t toInt64 (int64_t defaultValue=0) const
 Converts to int64 or returns defaultValue. More...
 
double toDouble (double defaultValue=0.0) const
 Converts to double or returns defaultValue. More...
 
std::string toString (const std::string &defaultValue={}) const
 Converts to string or returns defaultValue. More...
 
std::vector< uint8_t > toByteArray () const
 Converts to a byte array where supported. More...
 

Detailed Description

Small value container used by models, futures, settings, and database rows.

Constructor & Destructor Documentation

◆ RADVariant() [1/8]

RADCore::RADVariant::RADVariant ( )

Creates an invalid variant.

◆ RADVariant() [2/8]

RADCore::RADVariant::RADVariant ( bool  value)

Stores a boolean.

◆ RADVariant() [3/8]

RADCore::RADVariant::RADVariant ( int  value)

Stores an integer as Int64.

◆ RADVariant() [4/8]

RADCore::RADVariant::RADVariant ( int64_t  value)

Stores a signed 64-bit integer.

◆ RADVariant() [5/8]

RADCore::RADVariant::RADVariant ( double  value)

Stores a double.

◆ RADVariant() [6/8]

RADCore::RADVariant::RADVariant ( const char *  value)

Stores a C string as std::string.

◆ RADVariant() [7/8]

RADCore::RADVariant::RADVariant ( std::string  value)

Stores a string.

◆ RADVariant() [8/8]

RADCore::RADVariant::RADVariant ( std::vector< uint8_t >  value)

Stores a byte array.

Member Function Documentation

◆ isValid()

bool RADCore::RADVariant::isValid ( ) const

Returns true when the variant stores a non-invalid value.

◆ toBool()

bool RADCore::RADVariant::toBool ( bool  defaultValue = false) const

Converts to bool or returns defaultValue.

◆ toByteArray()

std::vector<uint8_t> RADCore::RADVariant::toByteArray ( ) const

Converts to a byte array where supported.

◆ toDouble()

double RADCore::RADVariant::toDouble ( double  defaultValue = 0.0) const

Converts to double or returns defaultValue.

◆ toInt64()

int64_t RADCore::RADVariant::toInt64 ( int64_t  defaultValue = 0) const

Converts to int64 or returns defaultValue.

◆ toString()

std::string RADCore::RADVariant::toString ( const std::string &  defaultValue = {}) const

Converts to string or returns defaultValue.

◆ type()

VariantType RADCore::RADVariant::type ( ) const

Returns the current variant type.


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