int CardMgr::getValue(int nCardId, string strParam)
{
PlayerDbMsg::CardBean* pCardBean = getCard(nCardId);
if(NULL == pCardBean)
return 0;
const google::protobuf::Descriptor* des = pCardBean->GetDescriptor();
const google::protobuf::FieldDescriptor* fdes = des->FindFieldByName(strParam);
if(NULL == fdes)
return 0;
if(fdes->type()!= google::protobuf::FieldDescriptor::TYPE_INT32)
return 0;
const google::protobuf::Reflection* pReflection = pCardBean->GetReflection();
return pReflection->GetInt32(*pCardBean, fdes);
}
bool CardMgr::setValue(int nCardId, string strParam, int nValue)
{
PlayerDbMsg::CardBean* pCardBean = getCard(nCardId);
if(NULL == pCardBean)
return false;
const google::protobuf::Descriptor* des = pCardBean->GetDescriptor();
const google::protobuf::FieldDescriptor* fdes = des->FindFieldByName(strParam);
if(NULL == fdes)
return false;
if(fdes->type()!= google::protobuf::FieldDescriptor::TYPE_INT32)
return false;
const google::protobuf::Reflection* pReflection = pCardBean->GetReflection();
pReflection->SetInt32(pCardBean, fdes, nValue);
return true;
}
08-03
1255
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
09-16
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交