You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
84 lines
1.6 KiB
C++
84 lines
1.6 KiB
C++
/**
|
|
* @file WVariant.h
|
|
* @brief 封装数据底层数据类型
|
|
* @author
|
|
* @time
|
|
*/
|
|
#pragma once
|
|
|
|
//#include <boost/any.hpp>
|
|
#include <limits>
|
|
|
|
#define WDATATYPE_STRING 0 // 字符串
|
|
#define WDATATYPE_DOUBLE 1 // 浮点型
|
|
#define WDATATYPE_INT 2 // 整型
|
|
#define WDATATYPE_BOOL 3 // bool
|
|
#define WDATATYPE_TIME 4 // 时间
|
|
|
|
#define WDATATYPE_NULL 255 // 空类型
|
|
|
|
#define NULL_FLT FLT_MAX
|
|
#define NULL_INT INT_MAX
|
|
|
|
namespace wuya
|
|
{
|
|
|
|
class AFX_EXT_CLASS WVariant
|
|
{
|
|
public:
|
|
WVariant(void);
|
|
WVariant(double dValue);
|
|
WVariant(bool bValue);
|
|
WVariant(int iValue);
|
|
WVariant(LPCTSTR strValue);
|
|
WVariant(const CString& strValue);
|
|
WVariant(const COleDateTime& time);
|
|
|
|
WVariant(const WVariant& variant);
|
|
|
|
~WVariant(void);
|
|
|
|
WVariant& operator= (const WVariant& varValue);
|
|
|
|
void SetValue(double dValue);
|
|
void SetValue(bool bValue);
|
|
void SetValue(int iValue);
|
|
void SetValue(LPCTSTR strValue);
|
|
void SetValue(const COleDateTime& time);
|
|
|
|
void GetValue(double& dValue);
|
|
void GetValue(bool& bValue);
|
|
void GetValue(int& iValue);
|
|
void GetValue(CString& strValue);
|
|
void GetValue(COleDateTime& time);
|
|
|
|
/** @brief 设置类型为WDATATYPE_NULL */
|
|
void SetNull();
|
|
|
|
/** @brief 判断类型是否为空 */
|
|
BOOL IsNull();
|
|
|
|
void SetType(BYTE type); // 设置为新类型,值设置为空
|
|
|
|
void ChangeType(BYTE type); // 转换为新类型,值保留
|
|
|
|
static BOOL IsNullDblValue(double dValue);
|
|
static BOOL IsNullIntValue(int iValue);
|
|
|
|
static double GetNullDblValue();
|
|
static int GetNullIntValue();
|
|
|
|
private:
|
|
void ChangeToString();
|
|
void ChangeToDbl();
|
|
void ChangeToInt();
|
|
void ChangeToBool();
|
|
void ChangeToTime();
|
|
|
|
private:
|
|
BYTE m_byteType; // 类型
|
|
|
|
//boost::any m_anyValue; // 存储数据
|
|
};
|
|
|
|
}; |