PTLib Version 2.12.9

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Public Types | Protected Member Functions | Protected Attributes | List of all members
PVarType Class Reference

A wrapper around a Variable Type class. More...

`#include <vartype.h>`

Inheritance diagram for PVarType:
[legend]
Collaboration diagram for PVarType:
[legend]

## Classes
union | Variant

## Public Types
enum | BasicType { VarNULL, VarBoolean, VarChar, VarInt8, VarInt16, VarInt32, VarInt64, VarUInt8, VarUInt16, VarUInt32, VarUInt64, VarFloatSingle, VarFloatDouble, VarFloatExtended, VarGUID, VarTime, VarStaticString, VarFixedString, VarDynamicString, VarStaticBinary, VarDynamicBinary }
| Type of the parameter in Paramater structure. More...
Public Types inherited from PObject
enum | Comparison { LessThan = -1, EqualTo = 0, GreaterThan = 1 }
| Result of the comparison operation performed by the `Compare()` function. More...

## Public Member Functions
Construction
| PVarType ()
| Create a NULL type object. More...
| PVarType (bool value)
| Create a boolean type object. More...
| PVarType (char value)
| Create a 8 bit integer type object. More...
| PVarType (int16_t value)
| Create a 16 bit integer type object. More...
| PVarType (int32_t value)
| Create a 32 bit integer type object. More...
| PVarType (int64_t value)
| Create a 64 bit integertype object. More...
| PVarType (uint8_t value)
| Create a 8 bit unsigned integer type object. More...
| PVarType (uint16_t value)
| Create a 16 bit unsigned integer type object. More...
| PVarType (uint32_t value)
| Create a 32 bit unsigned integer type object. More...
| PVarType (uint64_t value)
| Create a 64 bit unsigned integer type object. More...
| PVarType (float value)
| Create a single precision floating point type object. More...
| PVarType (double value)
| Create a double precision floating point type object. More...
| PVarType (long double value)
| Create a extended (long double) precision floating point type object. More...
| PVarType (const PGloballyUniqueID &value)
| Create a time of day type object. More...
| PVarType (const PTime &value)
| Create a time of day type object. More...
| PVarType (const char *value, bool dynamic=false)
| Create a string type object. More...
| PVarType (const PString &value, bool dynamic=true)
| Create a string type object. More...
| PVarType (const void *value, PINDEX len, bool dynamic=false)
| Create a data (memory block) type object. More...
| PVarType (const PBYTEArray &value, bool dynamic=true)
| Create a data (memory block) type object. More...
| PVarType (const PVarType &other)
| Copy constructor. More...
PVarType & | operator= (bool value)
| Assign a boolean type object. More...
PVarType & | operator= (char value)
| Assign a 8 bit integer type object. More...
PVarType & | operator= (int16_t value)
| Assign a 16 bit integer type object. More...
PVarType & | operator= (int32_t value)
| Assign a 32 bit integer type object. More...
PVarType & | operator= (int64_t value)
| Assign a 64 bit integertype object. More...
PVarType & | operator= (uint8_t value)
| Assign a 8 bit unsigned integer type object. More...
PVarType & | operator= (uint16_t value)
| Assign a 16 bit unsigned integer type object. More...
PVarType & | operator= (uint32_t value)
| Assign a 32 bit unsigned integer type object. More...
PVarType & | operator= (uint64_t value)
| Assign a 64 bit unsigned integer type object. More...
PVarType & | operator= (float value)
| Assign a single precision floating point type object. More...
PVarType & | operator= (double value)
| Assign a double precision floating point type object. More...
PVarType & | operator= (long double value)
| Assign a extended (long double) precision floating point type object. More...
PVarType & | operator= (const PGloballyUniqueID &value)
| Assign a time of day type object. More...
PVarType & | operator= (const PTime &value)
| Assign a time of day type object. More...
PVarType & | operator= (const char *str)
| Assignment operator for strings. More...
PVarType & | operator= (const PString &str)
| Assignment operator for strings. More...
PVarType & | operator= (const PVarType &other)
| Assignment operator. More...
| ~PVarType ()
| Destroy the variable type object. More...
Overrides from PObject
virtual void | PrintOn (ostream &strm) const
virtual void | ReadFrom (istream &strm)
virtual PObject * | Clone () const
| Create a copy of the class on the heap. More...
member variable access
BasicType | GetType () const
| Get the basic type of this instance. More...
virtual bool | SetType (BasicType type, PINDEX option=0)
| Set the basic type. More...
bool | AsBoolean () const
int | AsInteger () const
unsigned | AsUnsigned () const
int64_t | AsInteger64 () const
uint64_t | AsUnsigned64 () const
double | AsFloat () const
PGloballyUniqueID | AsGUID () const
PTime | AsTime () const
PString | AsString () const
const void * | GetPointer () const
PINDEX | GetSize () const
virtual PVarType & | SetValue (const PString &value)
| Set the instances value without changing it's type. More...
virtual PVarType & | SetString (const char *value, bool dynamic)
PVarType & | SetStaticString (const char *value)
PVarType & | SetDynamicString (const char *value)
virtual PVarType & | SetBinary (const void *data, PINDEX len, bool dynamic)
PVarType & | SetBinary (const PBYTEArray &value, bool dynamic)
PVarType & | SetStaticBinary (const void *data, PINDEX len)
PVarType & | SetStaticBinary (const PBYTEArray &value)
PVarType & | SetDynamicBinary (const void *data, PINDEX len)
PVarType & | SetDynamicBinary (const PBYTEArray &value)
Public Member Functions inherited from PObject
unsigned | GetTraceContextIdentifier () const
| Get PTRACE context identifier. More...
void | SetTraceContextIdentifier (unsigned id)
void | GetTraceContextIdentifier (PObject &obj)
void | GetTraceContextIdentifier (PObject *obj)
void | SetTraceContextIdentifier (const PObject &obj)
void | SetTraceContextIdentifier (const PObject *obj)
virtual | ~PObject ()
template<class CLS >
CLS * | CloneAs () const
| As for Clone() but converts to specified type. More...
virtual PINDEX | HashFunction () const
| This function yields a hash value required by the `PDictionary` class. More...
virtual const char * | GetClass (unsigned ancestor=0) const
| Get the current dynamic type of the object instance. More...
PBoolean | IsClass (const char *cls) const
virtual PBoolean | InternalIsDescendant (const char *clsName) const
| Determine if the dynamic type of the current instance is a descendent of the specified class. More...
__inline const PObject * | PTraceObjectInstance () const
virtual Comparison | Compare (const PObject &obj) const
| Compare the two objects and return their relative rank. More...
virtual Comparison | CompareObjectMemoryDirect (const PObject &obj) const
| Determine the byte wise comparison of two objects. More...
bool | operator== (const PObject &obj) const
| Compare the two objects. More...
bool | operator!= (const PObject &obj) const
| Compare the two objects. More...
bool | operator< (const PObject &obj) const
| Compare the two objects. More...
bool | operator> (const PObject &obj) const
| Compare the two objects. More...
bool | operator<= (const PObject &obj) const
| Compare the two objects. More...
bool | operator>= (const PObject &obj) const
| Compare the two objects. More...
virtual void | PrintOn (ostream &strm) const
| Output the contents of the object to the stream. More...
virtual void | ReadFrom (istream &strm)
| Input the contents of the object from the stream. More...

## Protected Member Functions
virtual void | OnGetValue ()
| Called before all the AsXXX() functions execute. More...
virtual void | OnValueChanged ()
| Called after SetValue() has (possibly) changed the value. More...
virtual void | InternalCopy (const PVarType &other)
void | InternalDestroy ()
Protected Member Functions inherited from PObject
| PObject ()
| Constructor for PObject, made protected so cannot ever create one on its own. More...

## Protected Attributes
BasicType | m_type
| Type of parameter. More...
union PVarType::Variant | m_
Protected Attributes inherited from PObject
unsigned | m_traceContextIdentifier

## Additional Inherited Members
Static Public Member Functions inherited from PObject
static const char * | Class ()
| Get the name of the class as a C string. More...
static __inline const PObject * | PTraceObjectInstance (const char *)
static __inline const PObject * | PTraceObjectInstance (const PObject *obj)
static Comparison | InternalCompareObjectMemoryDirect (const PObject *obj1, const PObject *obj2, PINDEX size)
| Internal function caled from CompareObjectMemoryDirect() More...
Friends inherited from PObject

## Detailed Description

A wrapper around a Variable Type class.

This allows run time variable type objects to be passed to various sub-systems.

## Member Enumeration Documentation

enum PVarType::BasicType

Type of the parameter in Paramater structure.

Enumerator
VarNULL |
VarBoolean |
VarChar |
VarInt8 |
VarInt16 |
VarInt32 |
VarInt64 |
VarUInt8 |
VarUInt16 |
VarUInt32 |
VarUInt64 |
VarFloatSingle |
VarFloatDouble |
VarFloatExtended |
VarGUID |
VarTime |
VarStaticString |
VarFixedString |
VarDynamicString |
VarStaticBinary |
VarDynamicBinary |

## Constructor & Destructor Documentation

PVarType::PVarType | ( |  | ) |
| inline

Create a NULL type object.

PVarType::PVarType | ( | bool | value | ) |
| inline

Create a boolean type object.

References PVarType::Variant::boolean, and m_.

PVarType::PVarType | ( | char | value | ) |
| inline

Create a 8 bit integer type object.

References PVarType::Variant::character, and m_.

PVarType::PVarType | ( | int16_t | value | ) |
| inline

Create a 16 bit integer type object.

References PVarType::Variant::int16, and m_.

PVarType::PVarType | ( | int32_t | value | ) |
| inline

Create a 32 bit integer type object.

References PVarType::Variant::int32, and m_.

PVarType::PVarType | ( | int64_t | value | ) |
| inline

Create a 64 bit integertype object.

References PVarType::Variant::int64, and m_.

PVarType::PVarType | ( | uint8_t | value | ) |
| inline

Create a 8 bit unsigned integer type object.

References m_, and PVarType::Variant::uint8.

PVarType::PVarType | ( | uint16_t | value | ) |
| inline

Create a 16 bit unsigned integer type object.

References m_, and PVarType::Variant::uint16.

PVarType::PVarType | ( | uint32_t | value | ) |
| inline

Create a 32 bit unsigned integer type object.

References m_, and PVarType::Variant::uint32.

PVarType::PVarType | ( | uint64_t | value | ) |
| inline

Create a 64 bit unsigned integer type object.

References m_, and PVarType::Variant::uint64.

PVarType::PVarType | ( | float | value | ) |
| inline

Create a single precision floating point type object.

References PVarType::Variant::floatSingle, and m_.

PVarType::PVarType | ( | double | value | ) |
| inline

Create a double precision floating point type object.

References PVarType::Variant::floatDouble, and m_.

PVarType::PVarType | ( | long double | value | ) |
| inline

Create a extended (long double) precision floating point type object.

References PVarType::Variant::floatExtended, and m_.

PVarType::PVarType | ( | const PGloballyUniqueID & | value | ) |
| inline

Create a time of day type object.

References PContainer::GetSize(), PVarType::Variant::guid, and m_.

PVarType::PVarType | ( | const PTime & | value | ) |
| inline

Create a time of day type object.

References PTime::GetTimeInSeconds(), m_, PVarType::Variant::seconds, and PVarType::Variant::time.

PVarType::PVarType | ( | const char * | value,
|  | bool | dynamic = `false`
| ) |  |
| inline

Create a string type object.

References SetString().

PVarType::PVarType | ( | const PString & | value,
|  | bool | dynamic = `true`
| ) |  |
| inline

Create a string type object.

References SetString().

PVarType::PVarType | ( | const void * | value,
|  | PINDEX | len,
|  | bool | dynamic = `false`
| ) |  |
| inline

Create a data (memory block) type object.

References SetBinary().

PVarType::PVarType | ( | const PBYTEArray & | value,
|  | bool | dynamic = `true`
| ) |  |
| inline

Create a data (memory block) type object.

References SetBinary().

PVarType::PVarType | ( | const PVarType & | other | ) |
| inline

Copy constructor.

Not for "dynamic" types this is not very efficient as it will make a duplicate of the memory used.

References InternalCopy().

PVarType::~PVarType | ( |  | ) |
| inline

Destroy the variable type object.

References InternalDestroy().

## Member Function Documentation

bool PVarType::AsBoolean | ( |  | ) | const

double PVarType::AsFloat | ( |  | ) | const

PGloballyUniqueID PVarType::AsGUID | ( |  | ) | const

int PVarType::AsInteger | ( |  | ) | const

int64_t PVarType::AsInteger64 | ( |  | ) | const

PString PVarType::AsString | ( |  | ) | const

PTime PVarType::AsTime | ( |  | ) | const

unsigned PVarType::AsUnsigned | ( |  | ) | const

uint64_t PVarType::AsUnsigned64 | ( |  | ) | const

virtual PObject* PVarType::Clone | ( |  | ) | const
| virtual

Create a copy of the class on the heap.

The exact semantics of the descendent class determine what is required to make a duplicate of the instance. Not all classes can even do a clone operation.

The main user of the clone function is the `PDictionary` class as it requires copies of the dictionary keys.

The default behaviour is for this function to assert.

Returns
  pointer to new copy of the class instance.

Reimplemented from PObject.

const void* PVarType::GetPointer | ( |  | ) | const

PINDEX PVarType::GetSize | ( |  | ) | const

Referenced by PODBC::Row::ColumnSize().

BasicType PVarType::GetType | ( |  | ) | const
| inline

Get the basic type of this instance.

References m_type.

virtual void PVarType::InternalCopy | ( | const PVarType & | other | ) |
| protected virtual

Reimplemented in PODBC::Field.

Referenced by operator=(), and PVarType().

void PVarType::InternalDestroy | ( |  | ) |
| protected

Referenced by ~PVarType().

virtual void PVarType::OnGetValue | ( |  | ) |
| protected virtual

Called before all the AsXXX() functions execute.

Reimplemented in PODBC::Field.

virtual void PVarType::OnValueChanged | ( |  | ) |
| protected virtual

Called after SetValue() has (possibly) changed the value.

Reimplemented in PODBC::Field.

PVarType& PVarType::operator= | ( | bool | value | ) |
| inline

Assign a boolean type object.

References PVarType::Variant::boolean, m_, SetType(), and VarBoolean.

Referenced by PODBC::Field::operator=().

PVarType& PVarType::operator= | ( | char | value | ) |
| inline

Assign a 8 bit integer type object.

References PVarType::Variant::character, m_, SetType(), and VarChar.

PVarType& PVarType::operator= | ( | int16_t | value | ) |
| inline

Assign a 16 bit integer type object.

References PVarType::Variant::int16, m_, SetType(), and VarInt16.

PVarType& PVarType::operator= | ( | int32_t | value | ) |
| inline

Assign a 32 bit integer type object.

References PVarType::Variant::int32, m_, SetType(), and VarInt32.

PVarType& PVarType::operator= | ( | int64_t | value | ) |
| inline

Assign a 64 bit integertype object.

References PVarType::Variant::int64, m_, SetType(), and VarInt64.

PVarType& PVarType::operator= | ( | uint8_t | value | ) |
| inline

Assign a 8 bit unsigned integer type object.

References m_, SetType(), PVarType::Variant::uint8, and VarUInt8.

PVarType& PVarType::operator= | ( | uint16_t | value | ) |
| inline

Assign a 16 bit unsigned integer type object.

References m_, SetType(), PVarType::Variant::uint16, and VarUInt16.

PVarType& PVarType::operator= | ( | uint32_t | value | ) |
| inline

Assign a 32 bit unsigned integer type object.

References m_, SetType(), PVarType::Variant::uint32, and VarUInt32.

PVarType& PVarType::operator= | ( | uint64_t | value | ) |
| inline

Assign a 64 bit unsigned integer type object.

References m_, SetType(), PVarType::Variant::uint64, and VarUInt64.

PVarType& PVarType::operator= | ( | float | value | ) |
| inline

Assign a single precision floating point type object.

References PVarType::Variant::floatSingle, m_, SetType(), and VarFloatSingle.

PVarType& PVarType::operator= | ( | double | value | ) |
| inline

Assign a double precision floating point type object.

References PVarType::Variant::floatDouble, m_, SetType(), and VarFloatDouble.

PVarType& PVarType::operator= | ( | long double | value | ) |
| inline

Assign a extended (long double) precision floating point type object.

References PVarType::Variant::floatExtended, m_, SetType(), and VarFloatExtended.

PVarType& PVarType::operator= | ( | const PGloballyUniqueID & | value | ) |
| inline

Assign a time of day type object.

References PContainer::GetSize(), PVarType::Variant::guid, m_, SetType(), and VarGUID.

PVarType& PVarType::operator= | ( | const PTime & | value | ) |
| inline

Assign a time of day type object.

References PTime::GetTimeInSeconds(), m_, PVarType::Variant::seconds, SetType(), PVarType::Variant::time, and VarTime.

PVarType& PVarType::operator= | ( | const char * | str | ) |
| inline

Assignment operator for strings.

Default to dynamic, not static as is this is much safer.

References SetDynamicString().

PVarType& PVarType::operator= | ( | const PString & | str | ) |
| inline

Assignment operator for strings.

Default to dynamic, not static as is this is much safer.

References SetDynamicString().

PVarType& PVarType::operator= | ( | const PVarType & | other | ) |
| inline

Assignment operator.

Not for "dynamic" types this is not very efficient as it will make a duplicate of the memory used.

References InternalCopy().

virtual void PVarType::PrintOn | ( | ostream & | strm | ) | const
| virtual

virtual void PVarType::ReadFrom | ( | istream & | strm | ) |
| virtual

virtual PVarType& PVarType::SetBinary | ( | const void * | data,
|  | PINDEX | len,
|  | bool | dynamic
| ) |  |
| virtual

Referenced by PVarType(), SetDynamicBinary(), and SetStaticBinary().

PVarType& PVarType::SetBinary | ( | const PBYTEArray & | value,
|  | bool | dynamic
| ) |  |
| inline

References PContainer::GetSize(), and SetBinary().

Referenced by SetBinary().

PVarType& PVarType::SetDynamicBinary | ( | const void * | data,
|  | PINDEX | len
| ) |  |
| inline

References SetBinary().

PVarType& PVarType::SetDynamicBinary | ( | const PBYTEArray & | value | ) |
| inline

References SetBinary().

PVarType& PVarType::SetDynamicString | ( | const char * | value | ) |
| inline

References SetString().

Referenced by operator=().

PVarType& PVarType::SetStaticBinary | ( | const void * | data,
|  | PINDEX | len
| ) |  |
| inline

References SetBinary().

PVarType& PVarType::SetStaticBinary | ( | const PBYTEArray & | value | ) |
| inline

References SetBinary().

PVarType& PVarType::SetStaticString | ( | const char * | value | ) |
| inline

References SetString().

virtual PVarType& PVarType::SetString | ( | const char * | value,
|  | bool | dynamic
| ) |  |
| virtual

Referenced by PVarType(), SetDynamicString(), and SetStaticString().

virtual bool PVarType::SetType | ( | BasicType | type,
|  | PINDEX | option = `0`
| ) |  |
| virtual

Set the basic type.

The `option` argument means different things depending on the type. If VarDynamicString or VarDynamicBinary then this indicates the size of the storage to allocate. If VarTime, then thius is the format to use for AsString().

Reimplemented in PODBC::Field.

Referenced by operator=().

virtual PVarType& PVarType::SetValue | ( | const PString & | value | ) |
| virtual

Set the instances value without changing it's type.

## Member Data Documentation

union PVarType::Variant PVarType::m_
| protected

Referenced by operator=(), and PVarType().

BasicType PVarType::m_type
| protected

Type of parameter.

Referenced by GetType().

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

- vartype.h