Purpose:
DKAny provides a mechanism to deal with dynamic data types, where the type of data is only known at run-time. DKAny has methods for setting and getting its type and value of the data.
DKAny knows the following types and manages the storage for them:
If the type is not included in this list, then the user is responsible for managing the storage.
For the following object reference types, for example, storage is not managed by DKAny:
Copying operations on DKAny containing the listed types will copy the pointer only, a shallow copy. These operations include assignment, copy and copy constructor. In addition, you will have to provide the destructors for these object reference types.
Class summary:
class DKAny { public: enum TypeCode { tc_null, tc_ushort, tc_short, tc_ulong, tc_long, tc_double, tc_boolean, tc_char, tc_string, tc_decimal, tc_nvpair, tc_date, tc_time, tc_timestamp, tc_objref, tc_collection, tc_dobase, tc_voidptr, tc_bytearray, tc_float, tc_typecode }; DKAny (); DKAny (const DKAny&); DKAny (const short); DKAny (const unsigned short); DKAny (const long); DKAny (const unsigned long); DKAny (const double); DKAny (const DKBoolean); DKAny (const char); DKAny (const DKString&); DKAny (const DKDate&); DKAny (const DKTime&); DKAny (const DKTimestamp&); DKAny (const DKByteArray&); DKAny (const DKDecimal&); DKAny (const dkDataObjectBase*); DKAny (const void *); DKAny (const TypeCode); DKAny(); // assignment to DKAny; for example, DKAny = typeX; DKAny& operator= (const DKAny&); DKAny& operator= (short); DKAny& operator= (unsigned short); DKAny& operator= (long); DKAny& operator= (unsigned long); DKAny& operator= (double); DKAny& operator= (DKBoolean); DKAny& operator= (char); DKAny& operator= (const DKString&); DKAny& operator= (const DKDate&); DKAny& operator= (const DKTime&); DKAny& operator= (const DKTimestamp&); DKAny& operator= (const dkDataObjectBase*); DKAny& operator= (const void *); DKAny& operator= (const TypeCode); DKAny& operator= (const DKByteArray&); DKAny& operator= (const DKDecimal&); // assignment from DKAny; for example, typeX = DKAny; operator short() const; operator unsigned short() const; operator long () const; operator unsigned long() const; operator double() const; operator DKBoolean() const; operator DKString() const; operator DKDate() const; operator DKTime() const; operator DKTimestamp() const; operator DKByteArray() const; operator DKDecimal() const; operator dkDataObjectBase() const; operator void* () const; operator TypeCode() const; DKBoolean operator== (const DKAny&) const; DKBoolean operator!= (const DKAny&) const; friend ostream& operator << (ostream& outStream, const DKAny& src); TypeCode typeCode() const; DKBoolean isNull() const; short getSubType(); void setSubType(short sub_type); void* value() const; void replace(TypeCode newTypeCode, void* newValue, short newSubType = 0); void setNull(); };
Data member:
TypeCode
enum TypeCode { tc_null, tc_short, tc_ushort, tc_long, tc_ulong, tc_double, tc_boolean, tc_char, tc_string, tc_decimal, tc_date, tc_time, tc_timestamp, tc_objref, tc_collection, tc_dobase, tc_voidptr, tc_bytearray, tc_typecode};
Enumerated type code of types known by DKAny.
Members:
DKAny(); DKAny(const DKAny&); DKAny(const <TYPE> var); DKAny();
DKBoolean operator== (const DKAny&);
DKBoolean operator!= (const DKAny&);
Exceptions
DKAny& operator= (const <TYPE> var); <TYPE> operator= (<TYPE>, const DKAny&);
TypeCode typeCode() const;
DKBoolean isNull() const;
void setSubType(short sub_type);
short getSubType() const;
Exceptions:
(c) Copyright International Business Machines Corporation 1996, 2003. IBM Corp. All rights reserved.