Enum from XML to c++



I am using XML in my application for data storage. My question is can you grab a parameter from XML and store it as an enum in c++? My code:



<foo>
<bar topic=that />
</foo>





Class foo
{
public:

enum
getEnum(enum input)
{
...
// do stuff
...

return output;
}
};





enum topic
{
this, that, theOtherThing
}

foo::getEnum(this);
// should return that


In case you can't read my code getEnum should return the value from the XML file. Just to be clear I am not asking for a code snippet on how to do this or a library ( will be using xerces). To summerize:




  1. I am asking if storing the variable in XML as this will be read as an enum versus storing it like "this".




  2. enum getEnum(){} has a syntax error. Is there any proper way to do this other than foo getEnum with foo being an enum that was previously declared.




EDIT: for any down voters please post a reason for down voting so I do better next time ( I am damned if I do and damned if I don't).


No comments:

Post a Comment