void GuideInfoParser::readFromCsv() { //read csv config file if (m_csvHelper.openAndResolveFile("guide.csv") == false) { return; } for (int i = 0; i < m_csvHelper.getRowLength(); ++i) { const char *type = m_csvHelper.getData(i, 0); if (strcmp(type, "STEP") == 0) { parseStepInfo(i); } if (strcmp(type, "HAND") == 0) { parseHandInfo(i); } if (strcmp(type, "TALK") == 0) { parseTalkInfo(i); } if (strcmp(type, "DIALOG") == 0) { parseDialogInfo(i); } if (strcmp(type, "RECT") == 0) { parseRectInfo(i); } if (strcmp(type, "LIMIT") == 0) { parseLimitInfo(i); } if (strcmp(type, "EVENT") == 0) { parseEventInfo(i); } } }
/* parser for the complete xml file */ GList *parseDoc (char *docname) { xmlDocPtr doc; xmlNodePtr cur; xmlParserCtxtPtr ctxt; eventlist = g_list_alloc (); /* allocates memory for new list */ if (getValidate() == TRUE) { ctxt = xmlCreateFileParserCtxt(docname); if (ctxt == NULL) { exit (1); } ctxt->validate = 1; /* check the XML's DTD */ xmlParseDocument(ctxt); if (!ctxt->valid) { g_print ("Please correct this problem or grootevent isn't able to run.\n" "Hint: You could also disable validating (--help for more infos)\n"); exit (1); } } doc = xmlParseFile (docname); if (doc == NULL) { fprintf (stderr, "Document not parsed successfully. \n"); return NULL; } cur = xmlDocGetRootElement (doc); if (cur == NULL) { fprintf (stderr, "empty document\n"); xmlFreeDoc (doc); return NULL; } if (xmlStrcmp (cur->name, (const xmlChar *) "grootevent")) { fprintf (stderr, "document of the wrong type, root node != grootevent\n"); xmlFreeDoc (doc); return NULL; } cur = cur->xmlChildrenNode; while (cur != NULL) { if ((!xmlStrcmp (cur->name, (const xmlChar *) "eventinfo"))) { parseEventInfo (doc, cur); } cur = cur->next; } xmlFreeDoc (doc); return eventlist; }