294 lines
5.0 KiB
C++
294 lines
5.0 KiB
C++
#include "StdAfx.h"
|
|
#include "DataContainer.h"
|
|
|
|
bool CDataContainer::GetData(LPCTSTR pszKey, double &dVal)
|
|
{
|
|
if (pszKey != NULL)
|
|
{
|
|
It it = m_mapDParam.find(pszKey);
|
|
if (it != m_mapDParam.end())
|
|
{
|
|
TParam param = (*it).second;
|
|
if (param.nVt == eDouble)
|
|
{
|
|
dVal = param.dVal[0];
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool CDataContainer::SetData(LPCTSTR pszKey, double dVal)
|
|
{
|
|
if (pszKey != NULL)
|
|
{
|
|
TParam param;
|
|
memset(¶m,0,sizeof(TParam));
|
|
param.nVt = eDouble;
|
|
param.dVal[0] = dVal;
|
|
|
|
It it = m_mapDParam.find(pszKey);
|
|
if (it != m_mapDParam.end())
|
|
{
|
|
(*it).second = param;
|
|
}
|
|
else
|
|
{
|
|
std::pair<CString,TParam> pa(pszKey,param);
|
|
m_mapDParam.insert(pa);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
bool CDataContainer::GetData(LPCTSTR pszKey, int &nVal)
|
|
{
|
|
if (pszKey != NULL)
|
|
{
|
|
It it = m_mapDParam.find(pszKey);
|
|
if (it != m_mapDParam.end())
|
|
{
|
|
TParam param = (*it).second;
|
|
if (param.nVt == eInt)
|
|
{
|
|
nVal = param.nVal;
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool CDataContainer::SetData(LPCTSTR pszKey, int nVal)
|
|
{
|
|
if (pszKey != NULL)
|
|
{
|
|
TParam param;
|
|
memset(¶m,0,sizeof(TParam));
|
|
param.nVt = eInt;
|
|
param.nVal = nVal;
|
|
|
|
It it = m_mapDParam.find(pszKey);
|
|
if (it != m_mapDParam.end())
|
|
{
|
|
(*it).second = param;
|
|
}
|
|
else
|
|
{
|
|
std::pair<CString,TParam> pa(pszKey,param);
|
|
m_mapDParam.insert(pa);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
bool CDataContainer::GetData(LPCTSTR pszKey, CString &strVal)
|
|
{
|
|
if (pszKey != NULL)
|
|
{
|
|
It it = m_mapDParam.find(pszKey);
|
|
if (it != m_mapDParam.end())
|
|
{
|
|
TParam param = (*it).second;
|
|
if (param.nVt == eTchar)
|
|
{
|
|
if (param.pszVal != NULL)
|
|
{
|
|
strVal = param.pszVal;
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool CDataContainer::SetData(LPCTSTR pszKey, const CString &strVal)
|
|
{
|
|
if (pszKey != NULL)
|
|
{
|
|
TParam param;
|
|
memset(¶m,0,sizeof(TParam));
|
|
param.nVt = eTchar;
|
|
int nLen = strVal.GetLength();
|
|
|
|
It it = m_mapDParam.find(pszKey);
|
|
if (it != m_mapDParam.end())
|
|
{
|
|
param.npszLen = nLen + 1;
|
|
if (param.pszVal != NULL)
|
|
{
|
|
delete []param.pszVal;
|
|
param.pszVal = NULL;
|
|
}
|
|
|
|
param.pszVal = new TCHAR[nLen + 1];
|
|
memset(param.pszVal, 0, param.npszLen);
|
|
_tcscpy(param.pszVal, strVal);
|
|
(*it).second = param;
|
|
}
|
|
else
|
|
{
|
|
param.npszLen = nLen + 1;
|
|
if (param.pszVal != NULL)
|
|
{
|
|
delete []param.pszVal;
|
|
param.pszVal = NULL;
|
|
}
|
|
|
|
param.pszVal = new TCHAR[nLen + 1];
|
|
memset(param.pszVal, 0, param.npszLen);
|
|
_tcscpy(param.pszVal, strVal);
|
|
std::pair<CString,TParam> pa(pszKey,param);
|
|
m_mapDParam.insert(pa);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
bool CDataContainer::GetData(LPCTSTR pszKey, AcGePoint3d &pt)
|
|
{
|
|
if (pszKey != NULL)
|
|
{
|
|
It it = m_mapDParam.find(pszKey);
|
|
if (it != m_mapDParam.end())
|
|
{
|
|
TParam param =(*it).second;
|
|
if (param.nVt == ePoint)
|
|
{
|
|
pt.x = param.dVal[0];
|
|
pt.y = param.dVal[1];
|
|
pt.z = param.dVal[2];
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
bool CDataContainer::SetData(LPCTSTR pszKey, const AcGePoint3d &pt)
|
|
{
|
|
if (pszKey != NULL)
|
|
{
|
|
TParam param;
|
|
memset(¶m,0,sizeof(TParam));
|
|
param.nVt = ePoint;
|
|
param.dVal[0] = pt.x;
|
|
param.dVal[1] = pt.y;
|
|
param.dVal[2] = pt.z;
|
|
|
|
It it = m_mapDParam.find(pszKey);
|
|
if (it != m_mapDParam.end())
|
|
{
|
|
(*it).second = param;
|
|
}
|
|
else
|
|
{
|
|
std::pair<CString,TParam> pa(pszKey,param);
|
|
m_mapDParam.insert(pa);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
bool CDataContainer::GetData(LPCTSTR pszKey, AcGeVector3d &vt)
|
|
{
|
|
if (pszKey != NULL)
|
|
{
|
|
It it = m_mapDParam.find(pszKey);
|
|
if (it != m_mapDParam.end())
|
|
{
|
|
TParam param =(*it).second;
|
|
if (param.nVt == eVector)
|
|
{
|
|
vt.x = param.dVal[0];
|
|
vt.y = param.dVal[1];
|
|
vt.z = param.dVal[2];
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
bool CDataContainer::SetData(LPCTSTR pszKey, const AcGeVector3d &vt)
|
|
{
|
|
if (pszKey != NULL)
|
|
{
|
|
TParam param;
|
|
memset(¶m,0,sizeof(TParam));
|
|
param.nVt = eVector;
|
|
param.dVal[0] = vt.x;
|
|
param.dVal[1] = vt.y;
|
|
param.dVal[2] = vt.z;
|
|
|
|
It it = m_mapDParam.find(pszKey);
|
|
if (it != m_mapDParam.end())
|
|
{
|
|
(*it).second = param;
|
|
}
|
|
else
|
|
{
|
|
std::pair<CString,TParam> pa(pszKey,param);
|
|
m_mapDParam.insert(pa);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
bool CDataContainer::GetData(LPCTSTR pszKey, AcDbObjectId &id)
|
|
{
|
|
if (pszKey != NULL)
|
|
{
|
|
It it = m_mapDParam.find(pszKey);
|
|
if (it != m_mapDParam.end())
|
|
{
|
|
TParam param =(*it).second;
|
|
if (param.nVt == eId)
|
|
{
|
|
id.setFromOldId(param.nId);
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
bool CDataContainer::SetData(LPCTSTR pszKey, const AcDbObjectId &id)
|
|
{
|
|
if (pszKey != NULL)
|
|
{
|
|
TParam param;
|
|
memset(¶m,0,sizeof(TParam));
|
|
param.nVt = eId;
|
|
param.nId = id.asOldId();
|
|
|
|
It it = m_mapDParam.find(pszKey);
|
|
if (it != m_mapDParam.end())
|
|
{
|
|
(*it).second = param;
|
|
}
|
|
else
|
|
{
|
|
std::pair<CString,TParam> pa(pszKey,param);
|
|
m_mapDParam.insert(pa);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
} |