本文整理汇总了C++中CField::GetWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ CField::GetWidth方法的具体用法?C++ CField::GetWidth怎么用?C++ CField::GetWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CField
的用法示例。
在下文中一共展示了CField::GetWidth方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PasteCol
/*
PasteCol 表名 源列名称 目标列名称
*/
bool TCManager::PasteCol(TCPacket &inP,AnaWord &aw, TCPacket &outP)
{
if (aw.GetWordCount() !=4)
return SetResultState(false,outP,GetLanguage(FormatIsError));
int nUserID = GetUserID(inP);
if (nUserID==0)
return SetResultState(false,outP,GetLanguage(UserIDIsNotFound));
string sTableName = aw.GetAt(1);
string sSrcName = aw.GetAt(2);
string sDstName = aw.GetAt(3);
CDataInterface *pDI = g_system.GetCurData(nUserID,aw.GetAt(1));
if (pDI == NULL)
return SetResultState(false,outP,GetLanguage(UserTableIsNotFound));
CField *pSrcField = pDI->FieldByName(sSrcName.c_str());
if (pSrcField == NULL)
return SetResultState(false,outP,GetLanguage(FieldNameNotFind));
CFieldType ft = pSrcField->GetFieldType();
CField *pDstField = pDI->FieldByName(sDstName.c_str());
if (pDstField == NULL)
{
pDstField = pDI->m_DataAccess.m_pFieldList->CreateField(ft);
pDstField->SetFieldName(sDstName);
pDstField->SetWidth(pSrcField->GetWidth());
pDI->m_DataAccess.m_pFieldList->Add(pDstField);
}
pDI->m_DataAccess.First();
while (!pDI->m_DataAccess.Eof())
{
pDI->m_DataAccess.Edit();
if (pSrcField->IsNull())
{
pDstField->SetNull();
}
else
{
if (ft == fDouble)
pDstField->SetAsDouble(pSrcField->GetAsDouble());
else if (ft == fInt)
pDstField->SetAsInteger(pSrcField->GetAsInteger());
else if (ft == fBoolean)
pDstField->SetAsBool(pSrcField->GetAsBool());
else if (ft == fString)
pDstField->SetAsString(pSrcField->GetAsString());
else
pDstField->SetAsDateTime(&pSrcField->GetAsDateTime());
}
pDI->m_DataAccess.Next();
}
return SetResultState(true,outP);
}
示例2: GetDataInfo
/*
#获取字段和记录信息 文件名没有,则返回当前表信息
>Command
Text
GetDataInfo 表名
<Command
Text
ColInfo 列信息
Fail 错误信息
*/
bool TCManager::GetDataInfo(TCPacket &inP,AnaWord &aw,TCPacket &outP)
{
if (aw.GetWordCount()!=2)
return SetResultState(false,outP,GetLanguage(FormatIsError));
int nUserID = GetUserID(inP);
if (nUserID==0)
return SetResultState(false,outP,GetLanguage(UserIDIsNotFound));
CDataInterface *pDI = g_system.GetCurData(nUserID,aw.GetAt(1));
if (pDI ==NULL)
{
return SetResultState(false,outP,GetLanguage(UserTableIsNotFound));
}
CDataAccess &da = pDI->m_DataAccess;
string strScript ;
int nCnt = da.GetRecordCount();
char buffer[50];
memset(buffer,0,50);
sprintf(buffer,"%d",nCnt);
string sRecordCount = buffer;
for (int i=0;i<da.GetFieldCount();i++)
{
CField *pField = da.FieldByIndex(i);
string ss = (const char*)pField->GetFieldName();
ss = AnaWord::GetUniquely(ss);
CFieldType ft = pField->GetFieldType();
if (ft ==fString )
ss = ss + " s ";
else if (ft == fDate)
ss = ss + " d ";
else if (ft == fInt)
ss = ss + " n ";
else if (ft == fDouble)
ss = ss + " f ";
else if (ft == fBoolean)
ss = ss + " b ";
char buf[10];
sprintf(buf," %d ",pField->GetWidth());
string sWidth = buf;
strScript = strScript+ " "+ ss +sWidth;
}
sRecordCount = "ColInfo "+sRecordCount + strScript;
outP.AddItem("Text",sRecordCount);
return SetResultState(true,outP);
}