Hello I am using expat to read an xml file. I want to populate some of my class member variables from the configruation specified in thexml file. I have defined my startelement handler,
void Start(void *data,const XML_Char *el, const XML_Char **attr)
and this will be referenced as following:
XML_SetElementHandler(parser,Start, NULL);
At the moment I am using a global structure, g_stConfigInfo
to store all the values in Start()
For example,
void Start(void *data,const XML_Char *el, const XML_Char **attr)
{
if( _tcscmp(el,_T("blah"))==0 )
{
for (int i=0; attr[i]; i+=2)
{
if(_tcscmp(attr[i],_T("name"))==0)
{
g_stConfigInfo.sInputName = attr[i+1];
}
.........
Then I am doing myclass.sInputName = g_stConfigInfo.sInputname
I would prefer not to use the global variable, instead to be able to make this a member function of the class whose member variables need to be populated. I dont want to have an instance of this class inside Start() either. What's the best way of doing this?