VariantEx.h
上传用户:maryhy001
上传日期:2007-05-02
资源大小:2317k
文件大小:2k
- #ifndef _VARIANTEX_H
- #define _VARIANTEX_H
- #include <comdef.h> //_variant_t class defined here
- #include ".TimeEx.h"
- //variant type simple define
- typedef enum VARTYPE_ENUM{
- //empty type
- VTE_EMPTY = 0,
-
- //string type
- VTE_STRING = 1,
-
- //integer type(int/short int/long int)
- VTE_INT = 2,
- VTE_SHORT = 3,
- VTE_LONG = 4,
- //unsigned integer(u_int/u_long)
- VTE_UNSHORT = 5,
- VTE_UNINT = 6,
- VTE_ULINT = 7,
- //real type(%.4f format)
- VTE_FLOAT = 8,
- VTE_DECIMAL = 9,
- //real type(%.8f format)
- VTE_DOUBLE = 10,
-
- //bool type(true/false)
- VTE_BOOL = 11,
- //datetime type
- VTE_DATETIME= 12,
- //"NULL" type
- VTE_NULL = 13,
- VTE_BLOB = 14,
- VTE_BLOB_OBJECT=15,
- VTE_TEXT = 16,
- //unKnown type
- VTE_UNKNOWN = 17
- };
- /*
- * CVariant class --- _variant_t encapsulation class
- */
- /********************************************************
- * Class Name : CVariantEx. *
- * Purpose : _variant_t encapsulation class. *
- * File Name : VariantEx.h / VariantEx.cpp. *
- *------------------------------------------------------*
- * Author : Devia Lee. Date: 2004-04-01 *
- ********************************************************/
- class CVariantEx
- {
- public:
- CVariantEx();
- CVariantEx(_variant_t &vt);
- CVariantEx(CVariantEx &var);
- CVariantEx(const bool bVar);
- CVariantEx(const long nVar);
- CVariantEx(const double dVar);
- CVariantEx(LPCSTR lpszVar);
- CVariantEx& operator=(_variant_t &vt);
- CVariantEx& operator=(CVariantEx &var);
- CVariantEx& operator=(const bool bVar);
- CVariantEx& operator=(const long nVar);
- CVariantEx& operator=(const double dVar);
- CVariantEx& operator=(LPCSTR lpszVar);
- virtual ~CVariantEx();
-
- //###################################################
-
- //determine the var whether is null
- bool IsNull();
- //clear the var value
- bool Clear();
- //get the variant type
- VARTYPE_ENUM getVarType();
-
- //get the variant value
- _variant_t& get_variant_t();
- //##############force convert value to someone type value##########
-
- //convert to string type
- string AsString();
- //convert to boolean type
- bool AsBool();
- //convert to integer type
- int AsInteger();
-
- //convert to real type
- double AsReal();
- //convert to datetime type
- CDateTimeEx AsDateTime();
- protected:
- _variant_t m_var;
- };
- #endif //_VARIANTEX_H