本文整理汇总了C++中CEntityProperty::GetStringAttr方法的典型用法代码示例。如果您正苦于以下问题:C++ CEntityProperty::GetStringAttr方法的具体用法?C++ CEntityProperty::GetStringAttr怎么用?C++ CEntityProperty::GetStringAttr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CEntityProperty
的用法示例。
在下文中一共展示了CEntityProperty::GetStringAttr方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetGame
//.........这里部分代码省略.........
//! 生成语句身
attrItr = pObjAttrDef->GetEntityPropertyMap().begin();
for (; attrItr != pObjAttrDef->GetEntityPropertyMap().end(); attrItr++)
{
if(attrItr->second)
{
if(attrItr->second->GetDBTableName() == tableName)
{
// 添加属性字段值
CEntityProperty* ep = (goodsItr->second)->GetDataEntityManager().GetEntityProperty(attrItr->second->GetEPName());
if(ep)
{
if(ep->GetDBTableName() == tableName)
{
switch(ep->GetDataType())
{
case DATA_OBJECT_TIME:
{
char szTimeValue[2048];
DWORD timeValue[6] = {0};
ep->GetBufAttr(0, (void*)&timeValue[0], sizeof(DWORD)*6);
sprintf(szTimeValue, "%d-%d-%d %d:%d:%d", timeValue[0], timeValue[1], timeValue[2],
timeValue[3], timeValue[4], timeValue[5]);
//rs->PutCollect((*epItr).c_str(), szTimeValue);
strcat(sql, "'");
strcat(sql, szTimeValue);
strcat(sql, "',");
}
break;
case DATA_OBJECT_STRING:
{
//rs->PutCollect((*epItr).c_str(), );
strcat(sql, "'");
const char* pStr = ep->GetStringAttr(0);
if(pStr)
strcat(sql, pStr);
else
strcat(sql, "");
strcat(sql, "',");
}
break;
case DATA_OBJECT_BUFFER:
{
//SaveBufferField((*goodsItr), (*epItr).c_str(), rs);
}
break;
case DATA_OBJECT_GUID:
{
CGUID tGUID;
ep->GetGuidAttr(0, tGUID);
char szGuid[128];
tGUID.tostring(szGuid);
//rs->PutCollect((*epItr).c_str(), szGuid);
strcat(sql, "'");
strcat(sql, szGuid);
strcat(sql, "',");
}
break;
case DATA_OBJECT_BOOL:
case DATA_OBJECT_CHAR:
case DATA_OBJECT_BYTE:
{
//rs->PutCollect((*epItr).c_str(), (BYTE)ep->GetLongAttr(0));
char value[32];
memset(value, 0, sizeof(value));
itoa((BYTE)ep->GetLongAttr(0), value, 10);
示例2: AddEntityDataToMsg
void CDBPlayer::AddEntityDataToMsg(DB_OPERATION_TYPE opType, vector<BYTE>& pBA)
{
// 传递来的消息前面已经加入了
// OPEntityID: 4byte, 操作实体的ID值
// DBOP Type: 1byte, 数据库操作类型(枚举值)
// MSG ID: 4byte, 该消息的MSGID
// Entity Num: 2byte, 该实体个数
WORD attrNum = m_mapDirtyAttrData.size();
_AddToByteArray(&pBA, m_GUID); // 实体ID
_AddToByteArray(&pBA, (WORD)attrNum); // 属性种类个数
//--新格式
//变量名字符串长度(long)
//变量名字符串
//变量类型(long)
//变量数据长度(long)
//变量数据
set<string>::iterator itr = m_mapDirtyAttrData.begin();
for(; itr != m_mapDirtyAttrData.end(); itr++)
{
CEntityProperty* ep = GetDataEntityManager().GetEntityProperty(*itr);
if(ep)
{
_AddToByteArray(&pBA, (long)(*itr).size());//变量名字符串长度(long)
_AddToByteArray(&pBA, (*itr).c_str());//变量名字符串
_AddToByteArray(&pBA, (long)ep->GetDataType());//变量类型(long)
_AddToByteArray(&pBA, (long)ep->GetBufSize(0));//变量数据长度(long)
switch(ep->GetDataType())
{
case DATA_OBJECT_TIME:
{
// 6个long值 : 年 月 日 时 分 秒
BYTE timeValue[6*sizeof(DWORD)];
memset(timeValue, 0, 6*sizeof(DWORD));
ep->GetBufAttr(0, (void*)timeValue, 6*sizeof(DWORD));
_AddToByteArray(&pBA, timeValue, 6*sizeof(DWORD));
}
break;
case DATA_OBJECT_STRING:
{
_AddToByteArray(&pBA, ep->GetStringAttr(0));//变量数据
}
break;
case DATA_OBJECT_FLOAT:
case DATA_OBJECT_LONG:
case DATA_OBJECT_SHORT:
case DATA_OBJECT_ULONG:
case DATA_OBJECT_USHORT:
case DATA_OBJECT_BOOL:
case DATA_OBJECT_CHAR:
case DATA_OBJECT_BYTE:
case DATA_OBJECT_WORD:
case DATA_OBJECT_DWORD:
{
_AddToByteArray(&pBA, (long)ep->GetLongAttr(0));//变量数据
}
break;
case DATA_OBJECT_GUID:
{
CGUID tGUID;
ep->GetGuidAttr(0, tGUID);
_AddToByteArray(&pBA, tGUID);//变量数据
}
break;
case DATA_OBJECT_BUFFER:
{
long bufSize = ep->GetBufSize(0);
if(bufSize)
{
BYTE* buf = new BYTE[bufSize];
ep->GetBufAttr(0, (void*)buf, bufSize);
_AddToByteArray(&pBA, buf, bufSize);//变量数据
SAFE_DELETE_ARRAY(buf);
}
}
break;
}
}
}
m_mapDirtyAttrData.clear();
}
示例3: SaveDupRgn
//! 保存个人房屋信息
void CRsDupRgn::SaveDupRgn(CDBDupRgn* dupRgn, _ConnectionPtr& cn)
{
if(cn == NULL)
{
AddLogText(CStringReading::LoadString(IDS_DBS_RSDUPRGN,STR_DBS_DUPRGN_FINDDUPRGNPROPERTYERR));
return;
}
_RecordsetPtr rs;
char sql[1024] = "";
try
{
TESTHR(CreateRs(rs));
char szGUID[128];
dupRgn->GetExID().tostring(szGUID);
sprintf(sql, "select * from dbo.CSL_DUPRGN_PROPERTY where guid='%s'", szGUID);
TESTHR(OpenRs(sql, rs, cn, adOpenDynamic, adLockOptimistic));
bool isNewCreated = false;
if(rs->GetadoEOF()) // 没有记录,创建一个
{
rs->AddNew();
isNewCreated = true;
}
set<string>::iterator epItr = dupRgn->GetDirtyAttrDataMap().begin();
for(; epItr != dupRgn->GetDirtyAttrDataMap().end(); epItr++)
{
CEntityProperty* ep = dupRgn->GetDataEntityManager().GetEntityProperty(*epItr);
if(ep)
{
if(ep->GetDBTableName() == "CSL_DUPRGN_PROPERTY")
{
switch(ep->GetDataType())
{
case DATA_OBJECT_TIME:
{
char szTimeValue[2048];
DWORD timeValue[6] = {0};
ep->GetBufAttr(0, (void*)timeValue, 6*sizeof(DWORD));
if(szTimeValue[0] != 0 && szTimeValue[1] != 0 && szTimeValue[2] != 0
&& szTimeValue[3] != 0 && szTimeValue[4] != 0 && szTimeValue[5] != 0)
{
sprintf(szTimeValue, "%d-%d-%d %d:%d:%d", timeValue[0], timeValue[1], timeValue[2],
timeValue[3], timeValue[4], timeValue[5]);
rs->PutCollect((*epItr).c_str(), szTimeValue);
}
}
break;
case DATA_OBJECT_STRING:
{
const char* pStr = ep->GetStringAttr(0);
if(pStr)
rs->PutCollect((*epItr).c_str(), pStr);
}
break;
case DATA_OBJECT_BUFFER:
{
SaveBufferField((CBaseDBEntity*)dupRgn, (*epItr).c_str(), rs);
}
break;
case DATA_OBJECT_GUID:
{
CGUID tGUID;
ep->GetGuidAttr(0, tGUID);
char szGUID[128];
tGUID.tostring(szGUID);
if( (ep->GetDbFlag() == 0) ) // 0:非主键,1:主键
rs->PutCollect((*epItr).c_str(), szGUID);
else if(isNewCreated) // 是主键但是是刚创建对象
rs->PutCollect((*epItr).c_str(), szGUID);
}
break;
case DATA_OBJECT_BOOL:
case DATA_OBJECT_CHAR:
case DATA_OBJECT_BYTE:
{
rs->PutCollect((*epItr).c_str(), (BYTE)ep->GetLongAttr(0));
}
break;
case DATA_OBJECT_SHORT:
case DATA_OBJECT_WORD:
case DATA_OBJECT_USHORT:
{
rs->PutCollect((*epItr).c_str(), (WORD)ep->GetLongAttr(0));
}
break;
case DATA_OBJECT_FLOAT:
case DATA_OBJECT_LONG:
case DATA_OBJECT_ULONG:
case DATA_OBJECT_DWORD:
{
rs->PutCollect((*epItr).c_str(), (DWORD)ep->GetLongAttr(0));
}
break;
}
}
//.........这里部分代码省略.........
示例4: InsertSysMailToGroup
//! 数据库里添加系统信件
void CRsMail::InsertSysMailToGroup(CDBMail* pMail, MAIL_LEVEL_OPER_FLAG levelOpFlag, long level, long sex, long* countryIDArray, long countryNum, _ConnectionPtr& cn)
{
if(!pMail || cn == NULL || !countryIDArray) return;
// 产生sql语句
char sql[1024];
_RecordsetPtr rs;
_RecordsetPtr mailRs;
try
{
// 记录收信人ID
vector<CGUID> vecRecieverID;
TESTHR(CreateRs(rs));
sprintf(sql, "select * FROM baseproperty WHERE ");
if(level != -1)
{
if(levelOpFlag == MAIL_LEVEL_GREATANDEQUAL)
strcat(sql, "Levels >= ");
else if(levelOpFlag == MAIL_LEVEL_LESSANDEQUAL)
strcat(sql, "Levels <= ");
char szNum[128];
itoa(level, szNum, 10);
strcat(sql, szNum);
}
else if(sex != -1)
{
if( (sex != -1))
strcat(sql, ", AND ");
strcat(sql, "Sex = ");
char szNum[128];
itoa(sex, szNum, 10);
strcat(sql, szNum);
}
else if(countryIDArray != NULL && countryNum != 0)
{
if( (sex != -1) || (level != -1))
strcat(sql, ", AND ");
for(int i=0; i<countryNum; i++)
{
strcat(sql, "(Country = ");
char szNum[128];
itoa(countryIDArray[i], szNum, 10);
strcat(sql, szNum);
strcat(sql, ", OR ");
}
long sqlLen = strlen(sql);
sql[sqlLen-5] = '\0';
strcat(sql, ")");
}
TESTHR(OpenRs(sql, rs, cn));
while(!rs->GetadoEOF())
{
CGUID tGuid((_bstr_t)rs->GetCollect("guid"));
vecRecieverID.push_back(tGuid);
rs->MoveNext();
}
ReleaseRs(rs);
TESTHR(CreateRs(mailRs));
sprintf(sql, "select * FROM CSL_MAIL WHERE PlayerID='{00000000-0000-0000-0000-000000000000}'");
TESTHR(OpenRs(sql, mailRs, cn));
for(int i=0; i<vecRecieverID.size(); i++)
{
rs->AddNew();
CDataEntityManager::EntityPropertyMapItr epItr = pMail->GetDataEntityManager().GetEntityPropertyMap().begin();
for(; epItr != pMail->GetDataEntityManager().GetEntityPropertyMap().end(); epItr++)
{
CEntityProperty* ep = epItr->second;
if(ep)
{
if(ep->GetDBTableName() == "CSL_MAIL")
{
switch(ep->GetDataType())
{
case DATA_OBJECT_TIME:
{
char szTimeValue[2048];
DWORD timeValue[6] = {0};
ep->GetBufAttr(0, (void*)timeValue, 6*sizeof(DWORD));
if(szTimeValue[0] != 0 && szTimeValue[1] != 0 && szTimeValue[2] != 0
&& szTimeValue[3] != 0 && szTimeValue[4] != 0 && szTimeValue[5] != 0)
{
sprintf(szTimeValue, "%d-%d-%d %d:%d:%d", timeValue[0], timeValue[1], timeValue[2],
timeValue[3], timeValue[4], timeValue[5]);
rs->PutCollect(epItr->first.c_str(), szTimeValue);
}
}
break;
case DATA_OBJECT_STRING:
{
rs->PutCollect(epItr->first.c_str(), ep->GetStringAttr(0));
}
break;
case DATA_OBJECT_BUFFER:
//.........这里部分代码省略.........
示例5: sizeof
//! 保存个人房屋内的物品信息
DB_OPERATION_RESULT_TYPE CRsMail::SaveMailGoods(const CGUID& ownerID, set<CDBMailGoods*>& goodsGroup, _ConnectionPtr& cn)
{
if(cn == NULL)
{
AddLogText(CStringReading::LoadString(IDS_DBS_RSDUPRGN,STR_DBS_DUPRGN_CNPTRNULL));
return DB_OPER_RESULT_ERROR;
}
_RecordsetPtr rs;
char sql[1024] = "";
string iniName = "mailgoods";
string tableName = "CSL_MAIL_GOODS";
try
{
TESTHR(CreateRs(rs));
char szGUID[128];
ownerID.tostring(szGUID);
sprintf(sql, "DELETE FROM CSL_MAIL_GOODS WHERE MailID='%s'", szGUID);
// 先删除该个人房屋的成员
if(!ExecuteCn(sql, cn))
{
PrintErr(CStringReading::LoadString(IDS_DBS_RSDUPRGN,STR_DBS_DUPRGN_DELRGNOBJFAIL));
return DB_OPER_RESULT_ERROR;
}
TESTHR(CreateRs(rs));
// 先查找该个人房屋的成员
sprintf(sql, "SELECT * FROM CSL_MAIL_GOODS WHERE MailID='%s'", szGUID);
TESTHR(OpenRs(sql, rs, cn, adOpenForwardOnly, adLockOptimistic));
set<CDBMailGoods*>::iterator goodsItr = goodsGroup.begin();
for(; goodsItr != goodsGroup.end(); goodsItr++)
{
rs->AddNew();
//! 生成语句身
CDataEntityManager::EntityPropertyMapItr attrItr = (*goodsItr)->GetDataEntityManager().GetEntityPropertyMap().begin();
for (; attrItr != (*goodsItr)->GetDataEntityManager().GetEntityPropertyMap().end(); attrItr++)
{
if(attrItr->second)
{
// 添加属性字段值
CEntityProperty* ep = attrItr->second;
if(ep)
{
if(ep->GetDBTableName() == tableName)
{
switch(ep->GetDataType())
{
case DATA_OBJECT_TIME:
{
char szTimeValue[2048];
DWORD timeValue[6] = {0};
ep->GetBufAttr(0, (void*)&timeValue[0], sizeof(DWORD)*6);
sprintf(szTimeValue, "%d-%d-%d %d:%d:%d", timeValue[0], timeValue[1], timeValue[2],
timeValue[3], timeValue[4], timeValue[5]);
rs->PutCollect(attrItr->first.c_str(), szTimeValue);
}
break;
case DATA_OBJECT_STRING:
{
rs->PutCollect(attrItr->first.c_str(), ep->GetStringAttr(0));
}
break;
case DATA_OBJECT_BUFFER:
{
SaveBufferField((*goodsItr), attrItr->first.c_str(), rs);
}
break;
case DATA_OBJECT_GUID:
{
CGUID tGUID;
ep->GetGuidAttr(0, tGUID);
char szGuid[128];
tGUID.tostring(szGuid);
rs->PutCollect(attrItr->first.c_str(), szGuid);
}
break;
case DATA_OBJECT_BOOL:
case DATA_OBJECT_CHAR:
case DATA_OBJECT_BYTE:
{
rs->PutCollect(attrItr->first.c_str(), (BYTE)ep->GetLongAttr(0));
}
break;
case DATA_OBJECT_SHORT:
case DATA_OBJECT_WORD:
case DATA_OBJECT_USHORT:
{
rs->PutCollect(attrItr->first.c_str(), (WORD)ep->GetLongAttr(0));
}
break;
case DATA_OBJECT_FLOAT:
case DATA_OBJECT_LONG:
case DATA_OBJECT_ULONG:
case DATA_OBJECT_DWORD:
{
//.........这里部分代码省略.........
示例6: SaveMail
//! 保存个人房屋信息
void CRsMail::SaveMail(CDBMail* mail, _ConnectionPtr& cn)
{
if(cn == NULL)
{
AddLogText(CStringReading::LoadString(IDS_DBS_RSDUPRGN,STR_DBS_DUPRGN_FINDDUPRGNPROPERTYERR));
return;
}
if(!mail) return;
_RecordsetPtr rs;
char sql[500] = "";
try
{
TESTHR(CreateRs(rs));
char szGUID[128];
mail->GetExID().tostring(szGUID);
TESTHR(OpenRs("CSL_MAIL", rs, cn, adOpenForwardOnly, adLockOptimistic));
if(!rs->GetadoEOF()) // 没有记录,创建一个
{
ReleaseRs(rs);
AddLogText("Create mail[%s] Err,RS is NULL!", szGUID);
}
bool isNewCreated = false;
BYTE phNum = rs->GetRecordCount();
if(phNum == 0xff) // 没有记录,创建一个
{
rs->AddNew();
isNewCreated = true;
}
set<string>::iterator epItr = mail->GetDirtyAttrDataMap().begin();
for(; epItr != mail->GetDirtyAttrDataMap().end(); epItr++)
{
CEntityProperty* ep = mail->GetDataEntityManager().GetEntityProperty(*epItr);
if(ep)
{
if(ep->GetDBTableName() == "CSL_MAIL")
{
switch(ep->GetDataType())
{
case DATA_OBJECT_TIME:
{
char szTimeValue[2048];
DWORD timeValue[6] = {0};
ep->GetBufAttr(0, (void*)timeValue, 6*sizeof(DWORD));
if(szTimeValue[0] != 0 && szTimeValue[1] != 0 && szTimeValue[2] != 0
&& szTimeValue[3] != 0 && szTimeValue[4] != 0 && szTimeValue[5] != 0)
{
sprintf(szTimeValue, "%d-%d-%d %d:%d:%d", timeValue[0], timeValue[1], timeValue[2],
timeValue[3], timeValue[4], timeValue[5]);
rs->PutCollect((*epItr).c_str(), szTimeValue);
}
}
break;
case DATA_OBJECT_STRING:
{
rs->PutCollect((*epItr).c_str(), ep->GetStringAttr(0));
}
break;
case DATA_OBJECT_BUFFER:
{
SaveBufferField((CBaseDBEntity*)mail, (*epItr).c_str(), rs);
}
break;
case DATA_OBJECT_GUID:
{
CGUID tGUID;
ep->GetGuidAttr(0, tGUID);
char szGUID[128];
tGUID.tostring(szGUID);
if( (ep->GetDbFlag() == 0) ) // 0:非主键,1:主键
rs->PutCollect((*epItr).c_str(), szGUID);
else if(isNewCreated) // 是主键但是是刚创建对象
rs->PutCollect((*epItr).c_str(), szGUID);
}
break;
case DATA_OBJECT_BOOL:
case DATA_OBJECT_CHAR:
case DATA_OBJECT_BYTE:
{
rs->PutCollect((*epItr).c_str(), (BYTE)ep->GetLongAttr(0));
}
break;
case DATA_OBJECT_SHORT:
case DATA_OBJECT_WORD:
case DATA_OBJECT_USHORT:
{
rs->PutCollect((*epItr).c_str(), (WORD)ep->GetLongAttr(0));
}
break;
case DATA_OBJECT_FLOAT:
case DATA_OBJECT_LONG:
case DATA_OBJECT_ULONG:
case DATA_OBJECT_DWORD:
//.........这里部分代码省略.........
示例7: SavePlayerMails
DB_OPERATION_RESULT_TYPE CRsMail::SavePlayerMails(CDBMailGroup* mailGroup, _ConnectionPtr& cn)
{
if(cn == NULL)
{
AddLogText(CStringReading::LoadString(IDS_DBS_RSDUPRGN,STR_DBS_DUPRGN_FINDDUPRGNPROPERTYERR));
return DB_OPER_RESULT_ERROR;
}
if(!mailGroup) return DB_OPER_RESULT_OK;
_RecordsetPtr rs;
char sql[1024] = "";
try
{
TESTHR(CreateRs(rs));
char szGUID[128];
mailGroup->GetOwnerGUID().tostring(szGUID);
sprintf(sql, "SELECT * FROM CSL_MAIL WHERE PlayerID='%s'", szGUID);
TESTHR(OpenRs(sql, rs, cn, adOpenForwardOnly, adLockOptimistic));
set<CDBMail*>::iterator itr = mailGroup->GetMailGroupSet().begin();
for(; itr != mailGroup->GetMailGroupSet().end(); itr++)
{
CDBMail* mail = *itr;
rs->AddNew();
set<string>::iterator epItr = mail->GetDirtyAttrDataMap().begin();
for(; epItr != mail->GetDirtyAttrDataMap().end(); epItr++)
{
CEntityProperty* ep = mail->GetDataEntityManager().GetEntityProperty(*epItr);
if(ep)
{
if(ep->GetDBTableName() == "CSL_MAIL")
{
switch(ep->GetDataType())
{
case DATA_OBJECT_TIME:
{
char szTimeValue[2048];
DWORD timeValue[6] = {0};
ep->GetBufAttr(0, (void*)timeValue, 6*sizeof(DWORD));
if(szTimeValue[0] != 0 && szTimeValue[1] != 0 && szTimeValue[2] != 0
&& szTimeValue[3] != 0 && szTimeValue[4] != 0 && szTimeValue[5] != 0)
{
sprintf(szTimeValue, "%d-%d-%d %d:%d:%d", timeValue[0], timeValue[1], timeValue[2],
timeValue[3], timeValue[4], timeValue[5]);
rs->PutCollect((*epItr).c_str(), szTimeValue);
}
}
break;
case DATA_OBJECT_STRING:
{
rs->PutCollect((*epItr).c_str(), ep->GetStringAttr(0));
}
break;
case DATA_OBJECT_BUFFER:
{
SaveBufferField((CBaseDBEntity*)mail, (*epItr).c_str(), rs);
}
break;
case DATA_OBJECT_GUID:
{
CGUID tGUID;
ep->GetGuidAttr(0, tGUID);
char szGUID[128];
tGUID.tostring(szGUID);
rs->PutCollect((*epItr).c_str(), szGUID);
}
break;
case DATA_OBJECT_BOOL:
case DATA_OBJECT_CHAR:
case DATA_OBJECT_BYTE:
{
rs->PutCollect((*epItr).c_str(), (BYTE)ep->GetLongAttr(0));
}
break;
case DATA_OBJECT_SHORT:
case DATA_OBJECT_WORD:
case DATA_OBJECT_USHORT:
{
rs->PutCollect((*epItr).c_str(), (WORD)ep->GetLongAttr(0));
}
break;
case DATA_OBJECT_FLOAT:
case DATA_OBJECT_LONG:
case DATA_OBJECT_ULONG:
case DATA_OBJECT_DWORD:
{
rs->PutCollect((*epItr).c_str(), (DWORD)ep->GetLongAttr(0));
}
break;
}
}
}
}
SaveMailGoods(mail->GetExID(), mail->GetGoodsGroupPtr()->GetGoodsGroupSet(), cn);
}
rs->Update();
ReleaseRs(rs);
return DB_OPER_RESULT_OK;
//.........这里部分代码省略.........