sptk2 logo
SPTK Home Page
Public Member Functions | Protected Member Functions | List of all members
sptk::VariantAdaptors Class Reference

#include <Variant.h>

Inheritance diagram for sptk::VariantAdaptors:
sptk::BaseVariant sptk::Variant sptk::Field sptk::QueryParameter sptk::DatabaseField

Public Member Functions

 VariantAdaptors ()=default
 Default constructor.
 
 VariantAdaptors (const VariantAdaptors &other)=default
 Copy constructor. More...
 
 VariantAdaptors (VariantAdaptors &&other) noexcept=default
 Move constructor. More...
 
 ~VariantAdaptors () override=default
 Default destructor.
 
virtual void setBool (bool value)
 
virtual void setInteger (int32_t value)
 
virtual void setInt64 (int64_t value)
 
virtual void setFloat (double value)
 
virtual void setMoney (int64_t value, unsigned scale)
 
virtual void setString (const String &value)
 
virtual void setBuffer (const uint8_t *value, size_t valueSize, VariantDataType type=VariantDataType::VAR_BUFFER)
 
virtual void setExternalBuffer (uint8_t *value, size_t valueSize, VariantDataType type=VariantDataType::VAR_BUFFER)
 
virtual void setDateTime (DateTime value, bool dateOnly=false)
 
virtual void setImagePtr (const uint8_t *value)
 
virtual void setImageNdx (uint32_t value)
 
virtual void setMoney (const MoneyData &value)
 
virtual void setNull (VariantDataType vtype=VariantDataType::VAR_NONE)
 
int asInteger () const
 
int64_t asInt64 () const
 
bool asBool () const
 
double asFloat () const
 
virtual String asString () const
 
DateTime asDate () const
 
DateTime asDateTime () const
 
const uint8_t * asImagePtr () const
 
- Public Member Functions inherited from sptk::BaseVariant
 BaseVariant ()=default
 Default constructor.
 
 BaseVariant (const BaseVariant &other)=default
 Copy constructor. More...
 
 BaseVariant (BaseVariant &&other) noexcept=default
 Move constructor. More...
 
virtual ~BaseVariant ()=default
 Destructor.
 
VariantDataType dataType () const
 
size_t dataSize () const
 
void dataSize (size_t newDataSize)
 
size_t bufferSize () const
 
bool isNull () const
 
template<typename T >
const T & get () const
 Direct and fast const access to variant data. More...
 
template<typename T >
T & get ()
 Direct and fast access to variant data. More...
 
virtual const MoneyDatagetMoney () const
 
virtual const char * getString () const
 
virtual const uint8_t * getExternalBuffer () const
 
virtual const char * getText () const
 
virtual const uint8_t * getImagePtr () const
 
virtual uint32_t getImageNdx () const
 

Protected Member Functions

void setData (const BaseVariant &other)
 
const char * getBufferPtr () const
 
- Protected Member Functions inherited from sptk::BaseVariant
void dataType (VariantType newDataType)
 
void dataType (VariantDataType newDataType)
 
bool isExternalBuffer () const
 
virtual String moneyDataToString () const
 

Additional Inherited Members

- Static Public Member Functions inherited from sptk::BaseVariant
static String typeName (VariantDataType type)
 
static VariantDataType nameType (const char *name)
 
- Protected Attributes inherited from sptk::BaseVariant
VariantData m_data
 Internal variant data storage.
 

Detailed Description

Variant set methods and adaptors 22 methods

Constructor & Destructor Documentation

◆ VariantAdaptors() [1/2]

sptk::VariantAdaptors::VariantAdaptors ( const VariantAdaptors other)
default

Copy constructor.

Parameters
otherThe other object

◆ VariantAdaptors() [2/2]

sptk::VariantAdaptors::VariantAdaptors ( VariantAdaptors &&  other)
defaultnoexcept

Move constructor.

Parameters
otherThe other object

Member Function Documentation

◆ asBool()

bool sptk::VariantAdaptors::asBool ( ) const

Conversion to bool

Converts variant string value with first char one of 'Y','y','T','t' to true, and one of 'N','n','F','f' to false. For the integer and float values, the value <=0 is false, and > 0 is true.

◆ asDate()

DateTime sptk::VariantAdaptors::asDate ( ) const

Conversion method

Converts variant value to DateTime. The time part of CDdatetime is empty.

◆ asDateTime()

DateTime sptk::VariantAdaptors::asDateTime ( ) const

Conversion method

Converts variant value to DateTime.

◆ asFloat()

double sptk::VariantAdaptors::asFloat ( ) const

Conversion to double

Converts variant value to double.

◆ asImagePtr()

const uint8_t * sptk::VariantAdaptors::asImagePtr ( ) const

Conversion method

Simply returns the internal data pointer for string/text/blob types. For incompatible types throws an exception.

◆ asInt64()

int64_t sptk::VariantAdaptors::asInt64 ( ) const

Conversion method

Converts variant value to double.

◆ asInteger()

int sptk::VariantAdaptors::asInteger ( ) const

Conversion method

Converts variant value to double.

◆ asString()

virtual String sptk::VariantAdaptors::asString ( ) const
virtual

Conversion to string

Converts variant value to string.

Reimplemented in sptk::Field.

Referenced by sptk::CFileDialog::fileName().

◆ setBool()

virtual void sptk::VariantAdaptors::setBool ( bool  value)
virtual

Assignment method

◆ setBuffer()

virtual void sptk::VariantAdaptors::setBuffer ( const uint8_t *  value,
size_t  valueSize,
VariantDataType  type = VariantDataType::VAR_BUFFER 
)
virtual

Assignment method

◆ setData()

void sptk::VariantAdaptors::setData ( const BaseVariant other)
protected

Copies data from another CVariant

◆ setDateTime()

virtual void sptk::VariantAdaptors::setDateTime ( DateTime  value,
bool  dateOnly = false 
)
virtual

Assignment method

◆ setExternalBuffer()

virtual void sptk::VariantAdaptors::setExternalBuffer ( uint8_t *  value,
size_t  valueSize,
VariantDataType  type = VariantDataType::VAR_BUFFER 
)
virtual

Assignment method

◆ setFloat()

virtual void sptk::VariantAdaptors::setFloat ( double  value)
virtual

Assignment method

◆ setImageNdx()

virtual void sptk::VariantAdaptors::setImageNdx ( uint32_t  value)
virtual

Assignment method

◆ setImagePtr()

virtual void sptk::VariantAdaptors::setImagePtr ( const uint8_t *  value)
virtual

Assignment method

◆ setInt64()

virtual void sptk::VariantAdaptors::setInt64 ( int64_t  value)
virtual

Assignment method

◆ setInteger()

virtual void sptk::VariantAdaptors::setInteger ( int32_t  value)
virtual

Assignment method

◆ setMoney() [1/2]

virtual void sptk::VariantAdaptors::setMoney ( const MoneyData value)
virtual

Assignment method

◆ setMoney() [2/2]

virtual void sptk::VariantAdaptors::setMoney ( int64_t  value,
unsigned  scale 
)
virtual

Assignment method

◆ setNull()

virtual void sptk::VariantAdaptors::setNull ( VariantDataType  vtype = VariantDataType::VAR_NONE)
virtual

Sets the NULL state

Useful for the database operations. Releases the memory allocated for string/text/blob types. Sets the data to zero(s).

Parameters
vtypeOptional variant type to enforce

◆ setString()

virtual void sptk::VariantAdaptors::setString ( const String value)
virtual

Assignment method

Reimplemented in sptk::QueryParameter.


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

Fri Oct 14 2022 09:58:47: SPTK 5.4.1