📄 wtfield.cpp
字号:
/*
* 文件名: WTField.cpp
*
* 作者: 施立虹
*
* 描述: 用来保存从 oracle 中读取到的表的字段和字段的信息
*
* 全局变量:
* 无
* 修订记录:
* 日期 修订者 修订描述
* 2004-06-16 施立虹 创建本文件
*/
// WTField.cpp: implementation of the CWTField class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "WTField.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CWTField::CWTField()
{
}
CWTField::CWTField(CWTValue::ValType valType)
{
SetValueType(valType);
}
CWTField::~CWTField()
{
}
CWTField& CWTField::operator=(const int &nValue)
{
m_dlVal = m_nVal = nValue;
return *this;
}
CWTField& CWTField::operator=(const long &lValue)
{
m_dlVal = m_lVal = lValue;
return *this;
}
CWTField& CWTField::operator=(const float &flValue)
{
m_dlVal = m_flVal = flValue;
return *this;
}
CWTField& CWTField::operator=(const double &dlValue)
{
m_dlVal = dlValue;
return *this;
}
CWTField& CWTField::operator=(const char* pszValue)
{
m_strVal.Format("%s",pszValue);
return *this;
}
CWTField& CWTField::operator=(const CString &strValue)
{
m_strVal = strValue;
return *this;
}
CWTField& CWTField::operator = (const CGeometry &Geometry)
{
m_CGeotry = Geometry;
return *this;
}
//Class CWTValue
CWTValue::CWTValue()
{
m_nVal = 0;
m_lVal = 0;
m_flVal = 0;
m_dlVal = 0;
m_strVal = _T("");
m_nValPrecision = 0;
m_nValSize = 0;
}
CWTValue::~CWTValue()
{
}
CWTValue& CWTValue::operator=(const int &nValue)
{
m_dlVal = m_nVal = nValue;
return *this;
}
CWTValue& CWTValue::operator=(const long &lValue)
{
m_dlVal = m_lVal = lValue;
return *this;
}
CWTValue& CWTValue::operator=(const double &dbValue)
{
m_dlVal = m_dlVal = dbValue;
return *this;
}
CWTValue& CWTValue::operator=(const char* pszValue)
{
m_strVal.Format("%s",pszValue);
return *this;
}
CWTValue& CWTValue::operator=(const CString &strValue)
{
m_strVal = strValue;
return *this;
}
void CWTValue::SetPrecision(unsigned short nPrecision)
{
m_nValPrecision = nPrecision;
}
unsigned short CWTValue::GetPrecision()
{
return m_nValPrecision;
}
void CWTValue::SetSize(unsigned short nSize)
{
m_nValSize = nSize;
}
unsigned short CWTValue::GetSize()
{
return m_nValSize;
}
/*
* 函数名称: SetValueFromString
* 编写者: 施立虹
* 功能: 设置变量值
* 输入参数: strValue
* 输出参数:
* 返回值:
* 注意事项:
* 修订记录:
* 日期 修订者 修订描述
* 2004-06-16 施立虹 创建
*/
void CWTValue::SetValueFromString(CString strValue)
{
switch(m_valType)
{
case WTINT:
case WTLONG:
case WTFLOAT:
case WTDOUBLE:
{
double dlVal = (double)atof(strValue);
*this = dlVal;
}
break;
case WTDATE:
case WTCSTRING:
{
*this = strValue;
}
break;
case WTOBJECT:
{
AfxMessageBox("不能把字符串转换成空间数据!");
}
break;
default:
{
}
break;
}
}
/*
* 函数名称: GetValueAsString
* 编写者: 施立虹
* 功能: 读取数据
* 输入参数:
* 输出参数:
* 返回值: (CString )m_strBuffer
* 注意事项:
* 修订记录:
* 日期 修订者 修订描述
* 2004-06-16 施立虹 创建
*/
CString CWTValue::GetValueAsString()
{
switch(m_valType)
{
case WTINT:
{
m_strBuffer.Format("%d",m_nVal);
}
break;
case WTLONG:
{
m_strBuffer.Format("%ld",m_lVal);
}
break;
case WTFLOAT:
{
m_strBuffer.Format("%f",m_flVal);
}
case WTDOUBLE:
{
m_strBuffer.Format("%lf",m_dlVal);
}
break;
case WTDATE:
case WTCSTRING:
{
m_strBuffer = m_strVal;
}
break;
case WTOBJECT:
{
m_strBuffer = _T("空间数据无法以字符串形式显示");
}
break;
default:
{
}
break;
}
return m_strBuffer;
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -