int main() { IrrXMLReader* xml = createIrrXMLReader("config.xml"); // strings for storing the data we want to get out of the file std::string modelFile; std::string messageText; std::string caption; // parse the file until end reached while(xml && xml->read()) { switch(xml->getNodeType()) { case EXN_TEXT: // in this xml file, the only text which occurs is the messageText messageText = xml->getNodeData(); break; case EXN_ELEMENT: { if (!strcmp("startUpModel", xml->getNodeName())) modelFile = xml->getAttributeValue("file"); else if (!strcmp("messageText", xml->getNodeName())) caption = xml->getAttributeValue("caption"); } break; } } // delete the xml parser after usage delete xml; return 0; }
int LoadMainStringsFromXML(const char* filename, string *str){ IrrXMLReader* xml = createIrrXMLReader(filename); int i=0; //should be 5 categories. while(xml && xml->read() && i< 5) { switch(xml->getNodeType()) { case EXN_ELEMENT: { if (!strcmp("file", xml->getNodeName())){ str[i] = xml->getAttributeValue("id"); i++; } } break; case EXN_NONE: break; case EXN_ELEMENT_END: break; case EXN_TEXT: break; case EXN_COMMENT: break; case EXN_CDATA: break; case EXN_UNKNOWN: break; } } delete xml; return 1; }
int main() { IrrXMLReader*xmlr; // create the reader using one of the factory functions IrrXMLReader* xml = createIrrXMLReader("track.xml"); if (xml == 0) return 0; // file could not be opened // parse the file until end reached while(xml->read()) { // based on xml->getNodeType(), do something. EXML_NODE type=xml->getNodeType(); cout<<"Type:"<<type<<endl; char name[128]; strcpy(name,xml->getNodeName()); cout<<"Name:"<<name<<endl; char data[128]; strcpy(data,xml->getNodeData()); cout<<"Data:"<<data<<endl; } // delete the xml parser after usage delete xml; return 1; }
int LoadStringsFromXML(const char* filename, PSC_Application2 *App){ IrrXMLReader* xml = createIrrXMLReader(filename); int i=-1; while(xml && xml->read()){ switch(xml->getNodeType()) { case EXN_ELEMENT: { if (!strcmp("elements", xml->getNodeName())){ App->n_elem = xml->getAttributeValueAsInt("n"); App->name = new string[App->n_elem+1]; App->version = new string[App->n_elem+1]; App->link = new string[App->n_elem+1]; App->pkg_file = new string[App->n_elem+1]; App->img_file = new string[App->n_elem+1]; App->type_file = new int[App->n_elem+1]; } if (!strcmp("app", xml->getNodeName())) i++; if (!strcmp("NameApp", xml->getNodeName())) App->name[i] = xml->getAttributeValue("name"); if (!strcmp("Version", xml->getNodeName())) App->version[i] = xml->getAttributeValue("v"); if (!strcmp("Link", xml->getNodeName())) App->link[i] = xml->getAttributeValue("link"); if (!strcmp("Pkg", xml->getNodeName())) App->pkg_file[i] = xml->getAttributeValue("file"); if (!strcmp("Image", xml->getNodeName())) App->img_file[i] = xml->getAttributeValue("img"); if (!strcmp("Type", xml->getNodeName())) App->type_file[i] = xml->getAttributeValueAsInt("type"); break; } } if(i == App->n_elem) break; } if(i > App->n_elem) App->n_elem = i; App->name[App->n_elem] = ""; App->version[App->n_elem] = ""; App->link[App->n_elem] = ""; App->pkg_file[App->n_elem] = ""; App->img_file[App->n_elem] = ""; App->type_file[App->n_elem] = -1; delete xml; return 1; }
/** * This method reads the config-file for the JointJointInteraction-module * @param fileName location of the config-file **/ void JointInteraction::readConfig(std::string fileName) { std::string ConcatenatedPath = getConcatenatedPath(fileName, "JointConfiguration"); if(!fileExists(ConcatenatedPath)) { printd(ERROR, "JointInteraction::readConfig(): cannot read from file %s\n", ConcatenatedPath.c_str()); return; } // if IrrXMLReader* xml = createIrrXMLReader(ConcatenatedPath.c_str()); if (!xml) { printd(ERROR, "JointInteraction::readConfig(): ERROR: could not find config-file %s\n", ConcatenatedPath.c_str()); return; } // if printd(INFO, "JointInteraction::readConfig(): loading from file: %s\n", fileName.c_str()); while (xml && xml->read()) { switch (xml->getNodeType()) { case EXN_ELEMENT: if (!strcmp("jointInteraction", xml->getNodeName())) { // Root node } // if else if (!strcmp("config", xml->getNodeName())) { loadConfig(xml); } // else if else if (!strcmp("joints", xml->getNodeName())) { loadJoints(xml); } // else if else { printd(WARNING, "JointInteraction::readConfig(): WARNING: unknown element with name %s found!\n", xml->getNodeName()); } // else break; default: break; } // switch } // while delete xml; } // readConfig
void ConfigurationData::loadFile(std::string fp){ IrrXMLReader* xml = createIrrXMLReader(fp.c_str()); std::string pack_id; while (xml && xml->read()){ switch (xml->getNodeType()){ case EXN_ELEMENT: if (!strcmp(xml->getNodeName(), "Window")){ this->SCREEN_SIZE.x = xml->getAttributeValueAsInt("SIZE_X"); this->SCREEN_SIZE.y = xml->getAttributeValueAsInt("SIZE_Y"); this->WINDOW_TITLE = xml->getAttributeValue("TITLE"); } if (!strcmp(xml->getNodeName(), "Paddle")){ this->PADDLE_SPEED = xml->getAttributeValueAsFloat("SPEED"); this->PADDLE_SPEED_CAP = xml->getAttributeValueAsFloat("SPEED_CAP"); this->PADDLE_VELOCITY_DECAY = xml->getAttributeValueAsFloat("VELOCITY_DECAY"); } if (!strcmp(xml->getNodeName(), "Ball")){ this->BALL_INITIAL_VELOCITY.x = xml->getAttributeValueAsFloat("INITIAL_VELOCITY_X"); this->BALL_INITIAL_VELOCITY.y = xml->getAttributeValueAsFloat("INITIAL_VELOCITY_Y"); this->BALL_VELOCITY_INCREASE = xml->getAttributeValueAsFloat("VELOCITY_INCREASE"); } if (!strcmp(xml->getNodeName(), "Skinpacks")){ pack_id = xml->getAttributeValue("pack_id"); } if (!strcmp(xml->getNodeName(), "Pack")){ if (xml->getAttributeValue("pack_id") == pack_id){ this->background_tex_path = xml->getAttributeValue("BG_TEX_PATH"); this->paddle_tex_path = xml->getAttributeValue("PADDLE_TEX_PATH"); this->ball_tex_path = xml->getAttributeValue("BALL_TEX_PATH"); } } break; } } delete xml; }
//--------------------------------------------------------------------- void Nave::LeAtributos(const char *arquivo) { IrrXMLReader* xml = createIrrXMLReader(arquivo); while(xml && xml->read()) { switch(xml->getNodeType()) { case EXN_ELEMENT: if (!strcmp("atributos", xml->getNodeName())) { Objeto::LeModelo(xml->getAttributeValue("arquivo")); velocidadeMaxima = xml->getAttributeValueAsFloat("velocidadeMaxima"); } else if (!strcmp("tiro", xml->getNodeName())) { if (!strcmp("laser", xml->getAttributeValue("qualBasico"))) tipoTiroBasico = TIPO_LASER; else if (!strcmp("missil", xml->getAttributeValue("qualBasico"))) tipoTiroBasico = TIPO_MISSIL; if (!strcmp("multiplo", xml->getAttributeValue("qualBasico"))) tipoTiroBasico = TIPO_MULTIPLO; } else if (!strcmp("recargaLaser", xml->getNodeName())) { tempoDeRecargaTotal[TIPO_LASER] = xml->getAttributeValueAsInt("tempo"); } else if (!strcmp("recargaMissil", xml->getNodeName())) { tempoDeRecargaTotal[TIPO_MISSIL] = xml->getAttributeValueAsInt("tempo"); } else if (!strcmp("recargaMultiplo", xml->getNodeName())) { tempoDeRecargaTotal[TIPO_MULTIPLO] = xml->getAttributeValueAsInt("tempo"); } break; } } }
bool bCharger(std::string _cCheminFichier = "") { bool bRetour = false; if(_cCheminFichier != "") { cCheminFichier = _cCheminFichier; } if(cCheminFichier != "") { if (bCharge == true) { vNettoyer(); } xml = createIrrXMLReader(cCheminFichier.c_str()); while(xml && xml->read()) { switch(xml->getNodeType()) { case EXN_TEXT: /*if(strcmp("messageText", xml->getNodeName())) { messageText = xml->getNodeData(); }*/ break; case EXN_ELEMENT: { if (!strcmp("antialiazing", xml->getNodeName())) antialiazing = (!strcmp(xml->getAttributeValue("value"),"ON")?true:false); else if (!strcmp("fullscreen", xml->getNodeName())) fullscreen = (!strcmp(xml->getAttributeValue("value"),"ON")?true:false); else if (!strcmp("musicAndFX", xml->getNodeName())) musicAndFX = (!strcmp(xml->getAttributeValue("value"),"ON")?true:false); else if (!strcmp("realTimeShadows", xml->getNodeName())) realTimeShadows = (!strcmp(xml->getAttributeValue("value"),"ON")?true:false); else if (!strcmp("verticalSynch", xml->getNodeName())) verticalSynch = (!strcmp(xml->getAttributeValue("value"),"ON")?true:false); else if (!strcmp("oldHWBlending", xml->getNodeName())) oldHWBlending = (!strcmp(xml->getAttributeValue("value"),"ON")?true:false); else if (!strcmp("driver", xml->getNodeName())) driver = (E_DRIVER_TYPE)atoi(xml->getAttributeValue("value")); else if (!strcmp("windowSize", xml->getNodeName())) { width = atoi(xml->getAttributeValue("width")); height = atoi(xml->getAttributeValue("height")); } } break; } } // delete the xml parser after usage delete xml; xml = NULL; bCharge = true; } return bRetour; }
int main(int argc, char** argv) { CCmdLineInfo cmdLine(argc, argv); IrrXMLReader* pXML = NULL; vector<string> arrStrings; print_title(); if ( cmdLine.GetArgCount() < 2 ) { print_usage(); return 1; } string option; string src_file = cmdLine.GetArg(1); string target_file = cmdLine.GetArg(2); if ( src_file[0] == '-' ) { option = src_file; src_file = cmdLine.GetArg(2); target_file = cmdLine.GetArg(3); if ( option == "-wide" ) { g_ExportWideStrings= true; printf("[CONFIG] Exporting wide strings\n"); } } pXML = createIrrXMLReader( src_file.c_str() ); if ( pXML ) { string elemName, string_id, string_val; while ( pXML->read() ) { switch ( pXML->getNodeType() ) { case EXN_ELEMENT: elemName = pXML->getNodeName(); if ( elemName == "String" ) { string_id = pXML->getAttributeValue( "id" ); arrStrings.push_back(string_id); } break; default: break; } } ofstream fs_target; fs_target.open( target_file.c_str() ); if ( fs_target.is_open() ) { write_h_header(fs_target, src_file); vector<string>::iterator it = arrStrings.begin(); while ( it != arrStrings.end() ) { write_h_stringdef(fs_target, *it); it++; } } fs_target.close(); } printf("%ld string definitions written to %s\n", arrStrings.size(), target_file.c_str()); return 0; }
int updateFinder(const char* TITLE_ID, int env_choose, PSN_Update* game){ const char *env[3] = {"np","sp-int","prod-qa"}; int size = strlen(TITLE_ID)*2+49+strlen(env[env_choose])*2; char *xml_url = (char*) malloc(size); snprintf(xml_url,size,"https://a0.ww.%s.dl.playstation.net/tpl/%s/%s/%s-ver.xml",env[env_choose],env[env_choose],TITLE_ID,TITLE_ID); download_game_update(xml_url,CACHE_PATH2"/game-update.xml", progress, NULL); free((void*)xml_url); size = get_size(CACHE_PATH2"/game-update.xml"); if(size == 16 || size == 241 || size == 0){ //Update not found file_delete(CACHE_PATH2"/game-update.xml"); return 0; } if(get_download_status()==DOWNLOAD_FAILED){ file_delete(CACHE_PATH2"/game-update.xml"); return 0; } IrrXMLReader* xml = createIrrXMLReader(CACHE_PATH2"/game-update.xml"); int i=-1; PSN_Update game_tmp; game_tmp.version = new string [10]; game_tmp.link = new string [10]; game_tmp.size = new uint32_t[10]; game_tmp.min_ver = new float [10]; game_tmp.pkgs = 0; while(xml && xml->read() && i<10){ //printf("debug: %s\n", xml->getNodeData()); switch(xml->getNodeType()) { case EXN_NONE: break; case EXN_ELEMENT: { if (!strcmp("package", xml->getNodeName())){ ++i; char tmp[10]; game_tmp.version[i] = xml->getAttributeValue("version"); game_tmp.size[i] = xml->getAttributeValueAsInt("size"); game_tmp.link[i] = xml->getAttributeValue("url"); game_tmp.min_ver[i] = xml->getAttributeValueAsFloat("ps3_system_ver"); game_tmp.pkgs++; break; }else if (!strcmp("TITLE", xml->getNodeName())){ xml->read(); game_tmp.name = xml->getNodeData(); break; } } case EXN_ELEMENT_END: break; case EXN_TEXT: break; case EXN_COMMENT: break; case EXN_CDATA: break; case EXN_UNKNOWN: break; } } delete xml; game->name = game_tmp.name.c_str(); game->version = new string [game_tmp.pkgs]; game->link = new string [game_tmp.pkgs]; game->size = new uint32_t[game_tmp.pkgs]; game->min_ver = new float [game_tmp.pkgs]; game->pkgs = game_tmp.pkgs; for(u8 j=0; j<game_tmp.pkgs; ++j){ game->version[j] = game_tmp.version[j]; game->link[j] = game_tmp.link[j]; game->size[j] = game_tmp.size[j]; game->min_ver[j] = game_tmp.min_ver[j]; } delete [] game_tmp.version; delete [] game_tmp.link; delete [] game_tmp.size; file_delete(CACHE_PATH2"/game-update.xml"); return 1; }
int BrewologyLoadStringsFromXML(const char* filename, PSC_Application *App){ IrrXMLReader* xml = createIrrXMLReader(filename); App->n_elem = 1014; App->name = new string[1020]; App->version = new string[1020]; App->author = new string[1020]; App->img_file = new string[1020]; App->type_file = new int [1020]; App->pkg = new links [1020]; /* App->link = new string[1020]; App->pkg_file = new string[1020]; App->file_size = new u32 [1020]; */ int i=-1; bool name_app = false; App->downloaded = false; while(xml && xml->read()){ switch(xml->getNodeType()) { case EXN_NONE: break; case EXN_ELEMENT: { if (!strcmp("error", xml->getNodeName())){ xml->read(); xml->read(); update = xml->getNodeData(); return PSC_OLDVERSION; } if (!strcmp("homebrew", xml->getNodeName())){ ++i; App->type_file[i] = PSC_PACKAGE; break; }else if (!strcmp("name", xml->getNodeName())){ //homebrew name xml->read(); App->name[i] = xml->getNodeData(); break; }else if (!strcmp("author", xml->getNodeName())){ xml->read(); App->author[i] = xml->getNodeData(); break; }else if (!strcmp("icon", xml->getNodeName())){ xml->read(); App->img_file[i] = xml->getNodeData(); break; }else if (!strcmp("pkgs", xml->getNodeName())){ string name[50]; string link[50]; u32 size[50]; u8 pkg=0; do{ switch(xml->getNodeType()){ case EXN_ELEMENT: { if (!strcmp("name", xml->getNodeName())){ xml->read(); name[pkg] = xml->getNodeData(); }else if (!strcmp("version", xml->getNodeName())){ xml->read(); App->version[i] = xml->getNodeData(); break; }else if (!strcmp("size", xml->getNodeName())){ xml->read(); size[pkg] = atoi(xml->getNodeData()); }else if (!strcmp("location", xml->getNodeName())){ xml->read(); link[pkg] = xml->getNodeData(); ++pkg; } }break; case EXN_ELEMENT_END: { if(!strcmp("pkgs", xml->getNodeName())) goto back; }break; } }while(pkg<50 && xml->read()); back: App->pkg[i].pkg_num = pkg; App->pkg[i].link = new string [pkg]; App->pkg[i].name = new string [pkg]; App->pkg[i].size = new u32 [pkg]; for(u8 j=0; j<pkg; ++j){ App->pkg[i].link[j] = link[j]; App->pkg[i].size[j] = size[j]; App->pkg[i].name[j] = name[j]; App->pkg[i].name[j] += ".pkg"; } break; } break; } case EXN_ELEMENT_END: break; case EXN_TEXT: break; case EXN_COMMENT: break; case EXN_CDATA: break; case EXN_UNKNOWN: break; } } i++; App->n_elem = i; for(;i < 1020;++i){ App->name[i] = ""; App->author[i] = ""; App->version[i] = ""; // App->link[i] = ""; // App->pkg_file[i] = ""; App->img_file[i] = ""; // App->file_size[i] = 0; App->type_file[i] = -1; App->pkg[i].pkg_num = 0; } delete xml; return 1; }
bool CParser::parseIrrXml(string xmlFile, string method){ IrrXMLReader* xml = createIrrXMLReader(xmlFile.c_str()); if(!xml){ ELOG("CParser", "parseIrrXml", string("Plik XML nie istnieje: ") + xmlFile); return false; } int status = 0; Entity entity; ClearEntity(&entity); while(xml && xml->read()){ switch(xml->getNodeType()){ case EXN_ELEMENT: { string get = xml->getNodeName(); if(get == "node"){ string type = xml->getAttributeValue("type"); if(type == "mesh"){ if(status == 0){ status = 1; //zaczynamy parsowanie modelu (dzieki temu omijamy zbedne poczatkowe znaczniki) //ELOGEX("DEBUG: WYKRYTO MESHA"); }else{ if(!CallLuaFunction(method, &entity)) { break; }else{ //ELOGEX("DEBUG: WYKRYTO MESHA"); } } } }else if(get == "vector3d" && status == 1){ string name = xml->getAttributeValue("name"); if(name == "Position"){ string position = xml->getAttributeValue("value"); entity.position = strToVec(position); }else if(name == "Rotation"){ string rotation = xml->getAttributeValue("value"); entity.rotation = strToVec(rotation); }else if(name == "Scale"){ string scale = xml->getAttributeValue("value"); entity.scale = strToVec(scale); } }else if(get == "string" && status == 1){ string name = xml->getAttributeValue("name"); if(name == "Mesh"){ string model = cutDir(xml->getAttributeValue("value")); entity.mesh = model; }else if(name == "Name"){ string nazwa = xml->getAttributeValue("value"); entity.name = nazwa; } }else if(get == "texture" && status == 1){ string name = xml->getAttributeValue("name"); if(name == "Texture1"){ string filename = cutDir(xml->getAttributeValue("value")); entity.texture = filename; } } } break; } } CallLuaFunction(method, &entity); delete xml; return true; }