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

database field More...

#include <DatabaseField.h>

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

Public Member Functions

 DatabaseField (const String &fieldName, int fieldColumn, int fieldType, VariantDataType dataType, int fieldLength, int fieldScale=4)
 
void checkSize (size_t sz)
 Checks the internal buffer size. More...
 
void setDataSize (size_t sz)
 Sets the internal data size. More...
 
int fieldColumn () const
 
int fieldType () const
 
uint32_t fieldSize () const
 
String displayFormat () const
 
void displayFormat (const String &format)
 
int alignment () const
 
void alignment (int al)
 
- Public Member Functions inherited from sptk::Field
 Field (const String &name)
 
 Field (const Field &other)=default
 
 Field (Field &&other) noexcept=default
 
Viewview ()
 
const StringfieldName () const
 
Fieldoperator= (const Field &other)=default
 
Fieldoperator= (Field &&other) noexcept=default
 
Fieldoperator= (const Variant &C)
 
Fieldoperator= (bool value) override
 
Fieldoperator= (int32_t value) override
 
Fieldoperator= (int64_t value) override
 
Fieldoperator= (double value) override
 
Fieldoperator= (const char *value) override
 
Fieldoperator= (const sptk::String &value) override
 
Fieldoperator= (DateTime value) override
 
Fieldoperator= (const uint8_t *value) override
 
Fieldoperator= (const Buffer &value) override
 
String asString () const override
 
void exportTo (const xdoc::SNode &node, bool compactXmlMode, bool detailedInfo=false, bool nullLargeData=false) const
 
String displayName () const
 
void displayName (const String &name)
 
- Public Member Functions inherited from sptk::Variant
 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
 

Protected Member Functions

void setFieldType (int fieldType, int fieldLength, int fieldScale)
 
String doubleDataToString () const override
 
virtual String doubleDataToString () const
 
- 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
 

Friends

class Query
 

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

database field

A special variation of CField to support database field essentials

Constructor & Destructor Documentation

◆ DatabaseField()

sptk::DatabaseField::DatabaseField ( const String fieldName,
int  fieldColumn,
int  fieldType,
VariantDataType  dataType,
int  fieldLength,
int  fieldScale = 4 
)

Constructor

Parameters
fieldNameField name
fieldColumnField column number
fieldTypeDatabase field type
dataTypeVariant data type
fieldLengthDatabase field length
fieldScaleDatabase field scale

Member Function Documentation

◆ alignment() [1/2]

int sptk::DatabaseField::alignment ( ) const
inline

Column alignment

Returns
Column alignment

◆ alignment() [2/2]

void sptk::DatabaseField::alignment ( int  al)
inline

Set column alignment

◆ checkSize()

void sptk::DatabaseField::checkSize ( size_t  sz)

Checks the internal buffer size.

The internal buffer is automatically extended to fit the required size of data

Parameters
szData size (in bytes)

◆ displayFormat() [1/2]

String sptk::DatabaseField::displayFormat ( ) const
inline

Column display format

Returns
Column display format

◆ displayFormat() [2/2]

void sptk::DatabaseField::displayFormat ( const String format)
inline

Set column display format

◆ doubleDataToString()

String sptk::DatabaseField::doubleDataToString ( ) const
overrideprotectedvirtual

Reimplemented from sptk::Field.

◆ fieldColumn()

int sptk::DatabaseField::fieldColumn ( ) const
inline

Reports field column number

◆ fieldSize()

uint32_t sptk::DatabaseField::fieldSize ( ) const
inline

Reports field size

◆ fieldType()

int sptk::DatabaseField::fieldType ( ) const
inline

Reports database field type

◆ setDataSize()

void sptk::DatabaseField::setDataSize ( size_t  sz)
inline

Sets the internal data size.

The internal buffer is not modified, only the data size is set.

Parameters
szData size (in bytes)

◆ setFieldType()

void sptk::DatabaseField::setFieldType ( int  fieldType,
int  fieldLength,
int  fieldScale 
)
inlineprotected

Set field type

Parameters
fieldTypeField type
fieldLengthField length
fieldScaleField scale

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

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