在resetDefautlt函数中增加枚举值的初始化

This commit is contained in:
westonli 2020-09-09 13:31:09 +08:00
parent 465332a9c9
commit ab6df9e4e1

View File

@ -844,6 +844,19 @@ string Tars2Cpp::generateH(const StructPtr& pPtr, const string& namespaceId) con
s << TAB << member[j]->getId() << " = " << member[j]->def() << ";" << endl;
}
}
else
{ //没有提供初始值才会走到这里,提供枚举类型初始化值
EnumPtr ePtr = EnumPtr::dynamicCast(member[j]->getTypePtr());
if (ePtr)
{
vector<TypeIdPtr>& eMember = ePtr->getAllMemberPtr();
if (eMember.size() > 0)
{
string sid = ePtr->getSid();
s << TAB << member[j]->getId() << " = " << sid.substr(0, sid.find_first_of("::")) << "::" << eMember[0]->getId() << ";" << endl;
}
}
}
}
DEL_TAB;