I have created this Enum:
I have some XML tags where I input a CivilianUnitType and it does something. The variables in CvInfos are stored as ints. The question is, how do I convert the string to the enum?
I have this code:
Clearly, the == operator doesn't cover it, so what can do this?
Code:
enum CivilianUnitTypes
{
NO_CIVILIAN_UNIT = -1,
CIVILIAN_UNIT_MISSIONARY,
CIVILIAN_UNIT_WORKER,
CIVILIAN_UNIT_SETTLER,
CIVILIAN_UNIT_GREAT_PERSON,
};
I have some XML tags where I input a CivilianUnitType and it does something. The variables in CvInfos are stored as ints. The question is, how do I convert the string to the enum?
I have this code:
Code:
int CvGlobals::getCivilianUnitType(CvString szTextVal) const
{
for (int iI = 0; iI <= NUM_CIVILIAN_UNIT_TYPES; iI++)
{
if ((CivilianUnitTypes)iI == szTextVal)
{
return iI;
}
}
}
Clearly, the == operator doesn't cover it, so what can do this?