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

#include <Variant.h>

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

Public Member Functions

 Variant ()
 
 Variant (bool value)
 
 Variant (int32_t value)
 
 Variant (int64_t value, unsigned scale=1)
 
 Variant (double value)
 
 Variant (const char *value)
 
 Variant (const String &v)
 
 Variant (const DateTime &v)
 
 Variant (const uint8_t *value, size_t sz)
 
 Variant (const Buffer &value)
 
 Variant (const Variant &other)=default
 
 Variant (Variant &&other) noexcept=default
 
 ~Variant () override
 
Variantoperator= (const Variant &other)
 
Variantoperator= (Variant &&other) noexcept
 
virtual Variantoperator= (bool value)
 
virtual Variantoperator= (int32_t value)
 
virtual Variantoperator= (int64_t value)
 
virtual Variantoperator= (double value)
 
virtual Variantoperator= (const MoneyData &value)
 
virtual Variantoperator= (const char *value)
 
virtual Variantoperator= (const String &value)
 
virtual Variantoperator= (DateTime value)
 
virtual Variantoperator= (const uint8_t *value)
 
virtual Variantoperator= (const Buffer &value)
 
virtual operator bool () const
 
virtual operator int () const
 
virtual operator int64_t () const
 
virtual operator uint64_t () const
 
virtual operator double () const
 
virtual operator String () const
 
virtual operator DateTime () const
 
virtual void load (const std::shared_ptr< xdoc::Node > &element)
 
void save (const std::shared_ptr< xdoc::Node > &node) const
 
- Public Member Functions inherited from sptk::VariantAdaptors
 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
 

Additional Inherited Members

- Static Public Member Functions inherited from sptk::BaseVariant
static String typeName (VariantDataType type)
 
static VariantDataType nameType (const char *name)
 
- Protected Member Functions inherited from sptk::VariantAdaptors
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
 
- Protected Attributes inherited from sptk::BaseVariant
VariantData m_data
 Internal variant data storage.
 

Detailed Description

Universal data storage.

Reasonably compact an fast class what allows storing data of different types. It also allows conversions to and from supported types.

Constructor & Destructor Documentation

◆ Variant() [1/12]

sptk::Variant::Variant ( )

Constructor

◆ Variant() [2/12]

sptk::Variant::Variant ( bool  value)

Constructor

◆ Variant() [3/12]

sptk::Variant::Variant ( int32_t  value)

Constructor

◆ Variant() [4/12]

sptk::Variant::Variant ( int64_t  value,
unsigned  scale = 1 
)

Constructor

◆ Variant() [5/12]

sptk::Variant::Variant ( double  value)

Constructor

◆ Variant() [6/12]

sptk::Variant::Variant ( const char *  value)

Constructor

◆ Variant() [7/12]

sptk::Variant::Variant ( const String v)

Constructor

◆ Variant() [8/12]

sptk::Variant::Variant ( const DateTime v)

Constructor

◆ Variant() [9/12]

sptk::Variant::Variant ( const uint8_t *  value,
size_t  sz 
)

Constructor

Parameters
valueBuffer to copy from
szBuffer size

◆ Variant() [10/12]

sptk::Variant::Variant ( const Buffer value)

Constructor

Parameters
valueBuffer to copy from

◆ Variant() [11/12]

sptk::Variant::Variant ( const Variant other)
explicitdefault

Copy constructor

Parameters
otherOther object

◆ Variant() [12/12]

sptk::Variant::Variant ( Variant &&  other)
defaultnoexcept

Move constructor

Parameters
otherOther object

◆ ~Variant()

sptk::Variant::~Variant ( )
override

Destructor

Member Function Documentation

◆ load()

virtual void sptk::Variant::load ( const std::shared_ptr< xdoc::Node > &  element)
virtual

Loads the data from XML node

Parameters
elementXML node to load data from

◆ operator bool()

virtual sptk::Variant::operator bool ( ) const
explicitvirtual

Conversion operator

◆ operator DateTime()

virtual sptk::Variant::operator DateTime ( ) const
explicitvirtual

Conversion operator

◆ operator double()

virtual sptk::Variant::operator double ( ) const
explicitvirtual

Conversion operator

◆ operator int()

virtual sptk::Variant::operator int ( ) const
explicitvirtual

Conversion operator

◆ operator int64_t()

virtual sptk::Variant::operator int64_t ( ) const
explicitvirtual

Conversion operator

◆ operator String()

virtual sptk::Variant::operator String ( ) const
explicitvirtual

Conversion operator

◆ operator uint64_t()

virtual sptk::Variant::operator uint64_t ( ) const
explicitvirtual

Conversion operator

◆ operator=() [1/12]

virtual Variant & sptk::Variant::operator= ( bool  value)
virtual

Assignment operator

Parameters
valueValue to assign

Reimplemented in sptk::Field.

◆ operator=() [2/12]

virtual Variant & sptk::Variant::operator= ( const Buffer value)
virtual

Assignment operator

Parameters
valueValue to assign

Reimplemented in sptk::QueryParameter, and sptk::Field.

◆ operator=() [3/12]

virtual Variant & sptk::Variant::operator= ( const char *  value)
virtual

Assignment operator

Parameters
valueValue to assign

Reimplemented in sptk::QueryParameter, and sptk::Field.

◆ operator=() [4/12]

virtual Variant & sptk::Variant::operator= ( const MoneyData value)
virtual

Assignment operator

Parameters
valueValue to assign

◆ operator=() [5/12]

virtual Variant & sptk::Variant::operator= ( const String value)
virtual

Assignment operator

Parameters
valueValue to assign

Reimplemented in sptk::Field.

◆ operator=() [6/12]

virtual Variant & sptk::Variant::operator= ( const uint8_t *  value)
virtual

Assignment operator

Parameters
valueValue to assign

Reimplemented in sptk::QueryParameter, and sptk::Field.

◆ operator=() [7/12]

Variant & sptk::Variant::operator= ( const Variant other)

Assignment operator

Parameters
otherOther object

◆ operator=() [8/12]

virtual Variant & sptk::Variant::operator= ( DateTime  value)
virtual

Assignment operator

Parameters
valueValue to assign

Reimplemented in sptk::QueryParameter, and sptk::Field.

◆ operator=() [9/12]

virtual Variant & sptk::Variant::operator= ( double  value)
virtual

Assignment operator

Parameters
valueValue to assign

Reimplemented in sptk::QueryParameter, and sptk::Field.

◆ operator=() [10/12]

virtual Variant & sptk::Variant::operator= ( int32_t  value)
virtual

Assignment operator

Parameters
valueValue to assign

Reimplemented in sptk::QueryParameter, and sptk::Field.

◆ operator=() [11/12]

virtual Variant & sptk::Variant::operator= ( int64_t  value)
virtual

Assignment operator

Parameters
valueValue to assign

Reimplemented in sptk::QueryParameter, and sptk::Field.

◆ operator=() [12/12]

Variant & sptk::Variant::operator= ( Variant &&  other)
noexcept

Assignment operator

Parameters
otherOther object

◆ save()

void sptk::Variant::save ( const std::shared_ptr< xdoc::Node > &  node) const

Saves the data into XML node

Parameters
nodeXML node to save data into

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

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