int keyset_load(keyset* keys, const char* fname, int verbose) { TiXmlDocument doc(fname); bool loadOkay = doc.LoadFile(); if (!loadOkay) { if (verbose) fprintf(stderr, "Could not load keyset file \"%s\", error: %s.\n", fname, doc.ErrorDesc() ); return 0; } TiXmlHandle root = doc.FirstChild("document"); keyset_load_rsakey2048(root.FirstChild("ncsdrsakey"), &keys->ncsdrsakey); keyset_load_rsakey2048(root.FirstChild("ncchrsakey"), &keys->ncchrsakey); keyset_load_rsakey2048(root.FirstChild("ncchdescrsakey"), &keys->ncchdescrsakey); keyset_load_rsakey2048(root.FirstChild("firmrsakey"), &keys->firmrsakey); /* keyset_load_key128(root.FirstChild("ncchfixedsystemkey"), &keys->ncchfixedsystemkey); keyset_load_key128(root.FirstChild("ncchkeyxold"), &keys->ncchkeyX_old); keyset_load_key128(root.FirstChild("ncchkeyxseven"), &keys->ncchkeyX_seven); keyset_load_key128(root.FirstChild("ncchkeyxninethree"), &keys->ncchkeyX_ninethree); keyset_load_key128(root.FirstChild("ncchkeyxninesix"), &keys->ncchkeyX_ninesix); */ return 1; }
int CCrashDescReader::LoadXmlv10(TiXmlHandle hDoc) { TiXmlHandle hRoot = hDoc.FirstChild("Exception").ToElement(); if(hRoot.ToElement()==NULL) { return -3; // Invalid XML structure } // Set CrashRpt version to 1000 m_dwGeneratorVersion = 1000; // Get ExceptionRecord element TiXmlHandle hExceptionRecord = hRoot.FirstChild("ExceptionRecord").ToElement(); if(hExceptionRecord.ToElement()!=NULL) { const char* szImageName = hRoot.ToElement()->Attribute("ModuleName"); if(szImageName!=NULL) { m_sImageName = szImageName; m_sAppName = Utility::GetBaseFileName(szImageName); } } // OK m_bLoaded = true; return 0; }
bool TorsoControlStaticGait::loadParameters(const TiXmlHandle& handle) { TiXmlHandle handleTorsoConfiguration(handle.FirstChild("TorsoControl").FirstChild("TorsoConfiguration")); TiXmlHandle handleDynamicGait(handle.FirstChild("TorsoControl").FirstChild("DynamicGait")); if (!comControl_->loadParameters(handleDynamicGait)) { return false; } if (!loadParametersTorsoConfiguration(handleTorsoConfiguration)) { return false; } if (!loadParametersHipConfiguration(handleDynamicGait)) { return false; } TiXmlHandle hStGait(handle.FirstChild("TorsoControl").FirstChild("StaticGait")); CoMOverSupportPolygonControlStaticGait* staticComControl = static_cast<CoMOverSupportPolygonControlStaticGait*>(comControl_); if (!staticComControl->loadParametersStaticGait(hStGait)) { return false; } return true; }
int CCrashInfoReader::ParseRegKeyList(TiXmlHandle& hRoot, CErrorReportInfo& eri) { strconv_t strconv; TiXmlHandle fl = hRoot.FirstChild("RegKeyList"); if(fl.ToElement()==0) { return 1; } TiXmlHandle fi = fl.FirstChild("RegKey"); while(fi.ToElement()!=0) { const char* pszDestFile = fi.ToElement()->Attribute("destfile"); const char* pszRegKey = fi.ToElement()->Attribute("name"); if(pszDestFile!=NULL && pszRegKey!=NULL) { CString sDestFile = strconv.utf82t(pszDestFile); CString sRegKey = strconv.utf82t(pszRegKey); eri.m_RegKeys[sRegKey] = sDestFile; } fi = fi.ToElement()->NextSibling("RegKey"); } return 0; }
void WsTranslation::answerReceived(const std::string & answer, int requestId) { std::string id = ""; std::string translatedText = ""; std::string originalText = ""; std::string status = ""; bool success; if (answer.empty()) { success = false; //VOXOX - CJC - 2010.01.20 Add notification responce when for some reason webservice return empty string LOG_DEBUG("Translation webservice responce is empty"); } TiXmlDocument doc; doc.Parse(answer.c_str()); TiXmlHandle docHandle(&doc); TiXmlHandle root = docHandle.FirstChild("Translator").FirstChild("synchronousTranslate"); TiXmlText * idXML = root.FirstChild("id").FirstChild().Text(); if (idXML) { id = idXML->Value(); } TiXmlText * originalXML = root.FirstChild("original").FirstChild().Text(); if (originalXML) { originalText = originalXML->Value(); } TiXmlText * translatedXML = root.FirstChild("text").FirstChild().Text(); if (translatedXML) { translatedText = translatedXML->Value(); } TiXmlText * statustXml = root.FirstChild("status").FirstChild().Text(); if (statustXml) { status = statustXml->Value(); } if(status=="success"){ success = true; }else{ success = false; } translationDoneEvent(*this,id,originalText,translatedText,success); }
int keyset_load_rsakey2048(TiXmlHandle node, rsakey2048* key) { key->keytype = RSAKEY_INVALID; if (!keyset_load_key(node.FirstChild("N"), key->n, sizeof(key->n), 0)) goto clean; if (!keyset_load_key(node.FirstChild("E"), key->e, sizeof(key->e), 0)) goto clean; key->keytype = RSAKEY_PUB; if (!keyset_load_key(node.FirstChild("D"), key->d, sizeof(key->d), 0)) goto clean; if (!keyset_load_key(node.FirstChild("P"), key->p, sizeof(key->p), 0)) goto clean; if (!keyset_load_key(node.FirstChild("Q"), key->q, sizeof(key->q), 0)) goto clean; if (!keyset_load_key(node.FirstChild("DP"), key->dp, sizeof(key->dp), 0)) goto clean; if (!keyset_load_key(node.FirstChild("DQ"), key->dq, sizeof(key->dq), 0)) goto clean; if (!keyset_load_key(node.FirstChild("QP"), key->qp, sizeof(key->qp), 0)) goto clean; key->keytype = RSAKEY_PRIV; clean: return (key->keytype != RSAKEY_INVALID); }
bool ReadXml(const char *file_path) { TiXmlDocument doc(file_path); doc.LoadFile(); TiXmlHandle doc_handle(&doc); TiXmlElement *p_root2 = doc_handle.FirstChildElement().Element(); TiXmlHandle hRoot = TiXmlHandle(p_root2); TiXmlElement *pElem=hRoot.FirstChild( "Messages" ).FirstChild().Element(); TiXmlElement *p_root = doc.RootElement(); TiXmlElement *p_first = p_root->FirstChildElement(); TiXmlElement *p_one = p_first->FirstChildElement(); TiXmlElement *p_two = p_one->NextSiblingElement(); TiXmlElement *p_three = p_two->NextSiblingElement(); TiXmlAttribute *p_first_id = p_first->FirstAttribute(); printf("root: %s\n", p_root->Value()); printf("first_id: %s\n", p_first_id->Value()); printf("one: %s\n", p_one->FirstChild()->Value()); printf("two: %s\n", p_two->FirstChild()->Value()); const char *aaa = p_first->Attribute("key"); if (!p_root2) printf("error\n"); else printf("three: %s\n", p_root2->Value()); printf("pElem:%s\n", pElem->Value()); return true; }
// Extract slot details from the xml void converter::loadSlotDetails(TiXmlHandle &hRoot) { //printf("Slot details\n"); for( TiXmlElement* pElem=hRoot.FirstChild("slot").Element(); pElem; pElem=pElem->NextSiblingElement()) { std::string slotName = pElem->Attribute("name"); std::map<std::string, slotData>::iterator iter = m_slots.find(slotName); if ( iter==m_slots.end() ) { errlogPrintf("sampleChanger: Unknown slot '%s' in slot details\n", slotName.c_str()); } else { iter->second.rackType = pElem->Attribute("rack_type"); if ( pElem->QueryDoubleAttribute("xoff", &(iter->second.xoff))!=TIXML_SUCCESS ) { errlogPrintf("sampleChanger: unable to read slot xoff attribute \"%s\"\n", slotName.c_str()); } if ( m_dims>1 && pElem->QueryDoubleAttribute("yoff", &(iter->second.yoff))!=TIXML_SUCCESS ) { errlogPrintf("sampleChanger: unable to read slot yoff attribute \"%s\"\n", slotName.c_str()); } //printf("Det slot %s %s %f\n", iter->second.name, iter->second.rackType, iter->second.xoff); } } }
PlayerResource ResourceCache::LoadPlayer( const PlayerType type, const std::string& name, const TiXmlHandle& hndl ) { const Size size = { static_cast<int>(mAppConfig.GetCellSize().Width * 1.55f), static_cast<int>(mAppConfig.GetCellSize().Height * 1.75f) }; const auto walk_len = 1000_ms; const auto spawn_len = 1000_ms; const auto death_len = 1000_ms; const auto player_hndl = hndl.FirstChild(name); PlayerResource player(type); player.SetFrames(PlayerAnimation::StandUp, walk_len, LoadTextures(player_hndl, "StandUp", size)); player.SetFrames(PlayerAnimation::StandDown, walk_len, LoadTextures(player_hndl, "StandDown", size)); player.SetFrames(PlayerAnimation::StandLeft, walk_len, LoadTextures(player_hndl, "StandLeft", size)); player.SetFrames(PlayerAnimation::StandRight, walk_len, LoadTextures(player_hndl, "StandRight", size)); player.SetFrames(PlayerAnimation::WalkUp, walk_len, LoadTextures(player_hndl, "WalkUp", size)); player.SetFrames(PlayerAnimation::WalkDown, walk_len, LoadTextures(player_hndl, "WalkDown", size)); player.SetFrames(PlayerAnimation::WalkLeft, walk_len, LoadTextures(player_hndl, "WalkLeft", size)); player.SetFrames(PlayerAnimation::WalkRight, walk_len, LoadTextures(player_hndl, "WalkRight", size)); player.SetFrames(PlayerAnimation::Spawn, spawn_len, LoadTextures(player_hndl, "Spawn", size)); player.SetFrames(PlayerAnimation::Destroy, death_len, LoadTextures(player_hndl, "Death", size)); return player; }
// Extract the definitions of the rack types from the xml void converter::loadRackDefs(TiXmlHandle &hRoot) { m_racks.clear(); //printf("Loading rack defs\n"); for( TiXmlElement* pElem=hRoot.FirstChild("racks").FirstChild("rack").Element(); pElem; pElem=pElem->NextSiblingElement()) { //printf("Loading rack defs - racks\n"); std::map<std::string, samplePosn> posns; std::string rackName = pElem->Attribute("name"); for ( TiXmlElement *pRack = pElem->FirstChildElement("position") ; pRack ; pRack=pRack->NextSiblingElement() ) { samplePosn posn; const char *attrib = pRack->Attribute("name"); if ( attrib!=NULL ) { posn.name = attrib; } else { errlogPrintf("sampleChanger: rack has no name attribute \"%s\"\n", rackName.c_str()); } //printf("Loading rack defs - %s\n", posn.name.c_str()); if ( pRack->QueryDoubleAttribute("x", &posn.x)!=TIXML_SUCCESS ) { errlogPrintf("sampleChanger: unable to read x attribute \"%s\" \"%s\"\n", rackName.c_str(), posn.name.c_str()); } if ( m_dims>1 && pRack->QueryDoubleAttribute("y", &posn.y)!=TIXML_SUCCESS ) { errlogPrintf("sampleChanger: unable to read y attribute \"%s\" \"%s\"\n", rackName.c_str(), posn.name.c_str()); } posns[posn.name] = posn; } m_racks[rackName] = posns; } }
void ComponentOptionMust::setComponents(TiXmlHandle docMUSTHandle, string nameOption, string tradeId) { TiXmlElement *Component; TiXmlElement *elem; TiXmlElement *Trade = docMUSTHandle.FirstChild("BODY").FirstChild("TRADELIST").FirstChild("MUST_TR").ToElement(); while (Trade) { if (strcmp(Trade->FirstChild("TradeId")->ToElement()->GetText(), tradeId.c_str()) == 0) { Component = Trade->FirstChild("MPTradeData")->FirstChild("MPTRDATA")->FirstChild("MPTrDataXML")->FirstChild("MPTRDATAXML")->FirstChild("STRUCTURED_INSTRUMENT")-> FirstChild("COMPONENT_LIST")->FirstChild("COMPONENT_OPTION")->ToElement(); while (Component) { if (strcmp(Component->Value(), "COMPONENT_OPTION") == 0) { if (strcmp(Component->FirstChild("NAME")->ToElement()->GetText(), nameOption.c_str()) == 0) { payOrSell = Component->FirstChild("PORS")->ToElement()->GetText(); freqString = Component->FirstChild("EXPIRY_SCHED")->FirstChild("BASIC_SCHED")->FirstChild("SCHED_DEF")->FirstChild("FREQ")->ToElement()->GetText(); settlementType = Component->FirstChild("EXPIRY_SCHED")->FirstChild("ACTUAL_SETTLE_MODE")->ToElement()->GetText(); //firstExpiry = Component->FirstChild("EXPIRY_SCHED")->FirstChild("BASIC_SCHED")->FirstChild("START_DATE")->FirstChild("DATE_FORMULA")->FirstChild("TARGET")->FirstChild("ATTRIBUTE")->ToElement()->GetText(); //lastExpiry = Component->FirstChild("EXPIRY_SCHED")->FirstChild("BASIC_SCHED")->FirstChild("END_DATE")->FirstChild("DATE_FORMULA")->FirstChild("TARGET")->FirstChild("ATTRIBUTE")->ToElement()->GetText(); } } break; Component = Component->NextSiblingElement(); } //****** recherche du type de l'option elem = Trade->FirstChild("MPTradeData")->FirstChild("MPTRDATA")->FirstChild("MPTrDataXML")->FirstChild("MPTRDATAXML")->FirstChild("STRUCTURED_INSTRUMENT")-> FirstChild("VARIABLE_LIST")->FirstChild("VARIABLE")->ToElement(); while (elem) { if (strcmp(elem->Value(), "VARIABLE") == 0) { if (strcmp(elem->FirstChild("NAME")->ToElement()->GetText(), "OptionStyle") == 0) { typeOption = elem->FirstChild("FORMULA")->FirstChild("FORMULA_STRING")->ToElement()->GetText(); } break; } elem = elem->NextSiblingElement(); } break; } Trade = Trade->NextSiblingElement(); } }
int CCrashInfoReader::ParseFileList(TiXmlHandle& hRoot, CErrorReportInfo& eri) { strconv_t strconv; TiXmlHandle fl = hRoot.FirstChild("FileList"); if(fl.ToElement()==0) { return 1; } TiXmlHandle fi = fl.FirstChild("FileItem"); while(fi.ToElement()!=0) { const char* pszDestFile = fi.ToElement()->Attribute("destfile"); const char* pszSrcFile = fi.ToElement()->Attribute("srcfile"); const char* pszDesc = fi.ToElement()->Attribute("description"); const char* pszMakeCopy = fi.ToElement()->Attribute("makecopy"); if(pszDestFile!=NULL) { CString sDestFile = strconv.utf82t(pszDestFile); ERIFileItem item; item.m_sDestFile = sDestFile; if(pszSrcFile) item.m_sSrcFile = strconv.utf82t(pszSrcFile); if(pszDesc) item.m_sDesc = strconv.utf82t(pszDesc); if(pszMakeCopy) { if(strcmp(pszMakeCopy, "1")==0) item.m_bMakeCopy = TRUE; else item.m_bMakeCopy = FALSE; } else item.m_bMakeCopy = FALSE; eri.m_FileItems[sDestFile] = item; } fi = fi.ToElement()->NextSibling("FileItem"); } return 0; }
bool OutputFile::getIt(ParamQt * p) { int deb=0; currentIteration++; p->setRho(0); p->setTheta(0); p->setLL(0); TiXmlHandle root(&mDoc); TiXmlHandle h = root.FirstChild("outputFile"); TiXmlHandle hIter = h.Child("Iteration", currentIteration); TiXmlElement* t; // <Tree> t = hIter.FirstChild("Tree").ToElement(); if (t == NULL) // Can I use hIter to return false? return false; string s(t->GetText()); while (s.at(0)==10 || s.at(0)==13) s=s.substr(1,s.length()-1); while (s.at(s.size()-1)==10 || s.at(s.size()-1)==13) s=s.substr(0,s.length()-1); p->setTreeData(new RecTree(getL(),s,false,false),blocks); // <number>, <theta>, <delta>, <rho>, <ll>. t = hIter.FirstChild("number").ToElement(); p->setNumber(atol(t->GetText())); t = hIter.FirstChild("theta").ToElement(); p->setTheta(p->getTheta() + atof(t->GetText())); t = hIter.FirstChild("delta").ToElement(); p->setDelta(atof(t->GetText())); t = hIter.FirstChild("rho").ToElement(); p->setRho(p->getRho() + atof(t->GetText())); t = hIter.FirstChild("ll").ToElement(); p->setLL(p->getLL() + atof(t->GetText())); // <recedge> TiXmlElement* parent = hIter.ToElement(); TiXmlElement* child = 0; while (child = (TiXmlElement*) parent->IterateChildren("recedge", child)) { int start=0,end=0,efrom=0,eto=0; double ato=0,afrom=0; t = child->FirstChildElement("start"); start = deb + atoi(t->GetText()); t = child->FirstChildElement("end"); end = deb + atoi(t->GetText()); t = child->FirstChildElement("efrom"); efrom = atoi(t->GetText()); t = child->FirstChildElement("eto"); eto = atoi(t->GetText()); t = child->FirstChildElement("afrom"); afrom = atof(t->GetText()); t = child->FirstChildElement("ato"); ato = atof(t->GetText()); p->getTree()->addRecEdge(afrom,ato,start,end,efrom,eto); } return true; }
// Read Blocks, comment, nameMap, regions. void OutputFile::startOver() { currentIteration=-1; TiXmlHandle root(&mDoc); TiXmlElement* t; TiXmlHandle h = root.FirstChild("outputFile"); t = h.FirstChild("Blocks").ToElement(); blocks = t->GetText(); while (blocks.at(0)==10 || blocks.at(0)==13) blocks=blocks.substr(1,blocks.length()-1); while (blocks.at(blocks.size()-1)==10 || blocks.at(blocks.size()-1)==13) blocks=blocks.substr(0,blocks.length()-1); vector<string> blocksString = Daniweb::Split (blocks, ","); for (int i = 0; i < blocksString.size(); i++) blocksInt.push_back(atoi(blocksString[i].c_str())); t = h.FirstChild("comment").ToElement(); comment = t->GetText(); t = h.FirstChild("nameMap").ToElement(); names = t->GetText(); t = h.FirstChild("regions").ToElement(); regionsString = t->GetText(); }
bool DateXMLSerializer::unserialize(const std::string & data) { TiXmlDocument doc; doc.Parse(data.c_str()); TiXmlHandle docHandle(&doc); TiXmlHandle date = docHandle.FirstChild("date"); //Retrieving day _date._day = String(date.FirstChild("day").FirstChild().Text()->Value()).toInteger(); //Retrieving month _date._month = String(date.FirstChild("month").FirstChild().Text()->Value()).toInteger(); //Retrieving year _date._year = String(date.FirstChild("year").FirstChild().Text()->Value()).toInteger(); return true; }
bool TimeXMLSerializer::unserialize(const std::string & data) { TiXmlDocument doc; doc.Parse(data.c_str()); TiXmlHandle docHandle(&doc); TiXmlHandle date = docHandle.FirstChild("time"); //Retrieving hour _time._hour = String(date.FirstChild("hour").FirstChild().Text()->Value()).toInteger(); //Retrieving minute _time._minute = String(date.FirstChild("minute").FirstChild().Text()->Value()).toInteger(); //Retrieving second _time._second = String(date.FirstChild("second").FirstChild().Text()->Value()).toInteger(); return true; }
// Recursively search all children of "trakem2" node for either // 'id' or 'oid' tags. // // Return highest found + 1. // int NextOID( const TiXmlHandle hDoc ) { int highest = 0; TiXmlNode* par = hDoc.FirstChild( "trakem2" ).ToNode(); if( par ) highest = NextOID_IntoNode( par ); return highest + 1; }
int CCrashInfoReader::ParseCrashDescription(CString sFileName) { strconv_t strconv; TiXmlDocument doc; bool bOpen = doc.LoadFile(strconv.t2a(sFileName)); if(!bOpen) return 1; TiXmlHandle hRoot = doc.FirstChild("CrashRpt"); if(hRoot.ToElement()==NULL) return 1; TiXmlHandle hAppName = hRoot.FirstChild("AppName"); const char* szAppName = hAppName.FirstChild().ToText()->Value(); if(szAppName!=NULL) m_sAppName = strconv.utf82t(szAppName); TiXmlHandle hAppVersion = hRoot.FirstChild("AppVersion"); const char* szAppVersion = hAppVersion.FirstChild().ToText()->Value(); if(szAppVersion!=NULL) m_sAppVersion = strconv.utf82t(szAppVersion); TiXmlHandle hImageName = hRoot.FirstChild("ImageName"); const char* szImageName = hAppName.FirstChild().ToText()->Value(); if(szImageName!=NULL) m_sImageName = strconv.utf82t(szImageName); return 0; }
bool userCheck(std::string createdAtStr, TiXmlHandle timelineRootHandle, TiXmlHandle userRootHandle) { std::string weekday, month, day, time, year, tmpStr; long utcOffset, utcLower, utcHigher; std::stringstream ss, utcStrstream; std::stringstream strstream; boost::posix_time::ptime ptime, pt, currentTime, mostRecentTweetTime; boost::posix_time::time_duration hourDiff; int userCount = 0; ///// Checks to see if the UTC Offset of the user is in the Americas /////////// if(userRootHandle.FirstChild("user").FirstChild("utc_offset").ToNode()) { utcStrstream << userRootHandle.FirstChild("user").FirstChild("utc_offset").ToElement()->GetText(); utcStrstream >> utcOffset; utcLower = 60*60*(-10); // This is the time zone for Hawaii utcHigher = 60*60*(-5); // This is the time zone for the Eastern most US if(utcOffset >= utcLower && utcOffset <= utcHigher) { userCount++; } }
bool statusCheck(TiXmlHandle rootHandle) { std::string status; status = rootHandle.FirstChild("text").ToElement()->GetText(); for(int i = 0; i < status.size(); i++) { if(!isascii(status[i])) return false; } return true; }
void writeSRDF(const string filename, const string poseName, map<string, double>& joints) { TiXmlDocument doc(filename); if (!doc.LoadFile()) { printf("File %s could not be loaded.\n", filename.c_str()); return; } TiXmlHandle hDoc(&doc); TiXmlElement* robot = hDoc.FirstChildElement().Element(); for (;; robot = robot->NextSiblingElement()) { if (!robot) { printf("File does not contain a robot root element.\n"); return; } const char *rName = robot->Attribute("name"); // TODO hardcoded robot? if (rName == NULL || strcmp(rName, "kuka_lwr")) { continue; } break; } TiXmlHandle robotHandle = TiXmlHandle(robot); TiXmlElement* groupState = robotHandle.FirstChild("group_state").Element(); for (;; groupState = groupState->NextSiblingElement()) { if (!groupState) { break; } const char *gName = groupState->Attribute("name"); const char *gGroup = groupState->Attribute("group"); if (gName == NULL || strcmp(gName, poseName.c_str())) { continue; } robot->RemoveChild(groupState); } groupState = new TiXmlElement("group_state"); robot->LinkEndChild(groupState); groupState->SetAttribute("name", poseName); // TODO hardcoded group? groupState->SetAttribute("group", "arm_base"); writeJoints(groupState, joints); doc.SaveFile(filename); }
bool sGang::LoadGangXML( TiXmlHandle hGang ) { TiXmlElement* pGang = hGang.ToElement(); if( pGang == nullptr ) { return false; } if( pGang->Attribute( "Name" ) ) { m_Name = pGang->Attribute( "Name" ); } // load their skills LoadSkillsXML( hGang.FirstChild( "Skills" ), m_Skills ); // load their stats LoadStatsXML( hGang.FirstChild( "Stats" ), m_Stats ); pGang->QueryIntAttribute( "Num", &m_Num ); //these may not have been saved //if not, the query just does not set the value //so the default is used, assuming the gang was properly init { pGang->QueryValueAttribute<u_int>( "MissionID", &m_MissionID ); pGang->QueryIntAttribute( "LastMissID", &m_LastMissID ); // load the combat boolean pGang->QueryValueAttribute<bool>( "Combat", &m_Combat ); // load the auto recruit boolean pGang->QueryValueAttribute<bool>( "AutoRecruit", &m_AutoRecruit ); } return true; }
// ------------------------------------------------------------------------------------------------ void processXmlDocument(TiXmlHandle& handler, std::vector<Image>* array) { TiXmlHandle images = handler.FirstChild("response").FirstChild("data").FirstChild("images"); TiXmlHandle item_1 = images.Child("image", 0); TiXmlHandle item_2 = images.Child("image", 1); TiXmlHandle item_3 = images.Child("image", 2); Image image_1 = processImage(item_1); Image image_2 = processImage(item_2); Image image_3 = processImage(item_3); array->push_back(image_1); array->push_back(image_2); array->push_back(image_3); }
std::vector<SDL_Surface*> ResourceCache::LoadTextures( const TiXmlHandle& hndl, const std::string& name, const Size size ) { std::vector<SDL_Surface*> textures; for (auto elem = hndl.FirstChild(name).Element(); elem; elem = elem->NextSiblingElement(name)) { textures.push_back(LoadTexture(elem->GetText(), size)); } return textures; }
vector<BaseModule *> XmlConfigurationLoader::LoadModules(string type,void * docHandle){ vector<BaseModule *> modules; TiXmlHandle * handle = (TiXmlHandle *) docHandle; TiXmlElement * elem = handle->FirstChild("Configuration").FirstChild(type.c_str()).FirstChild("Module").ToElement(); if(elem == 0){ return modules; } do{ BaseModule * m = XmlConfigurationLoader::LoadModule(elem); if(m != 0){ modules.push_back(m); } elem = elem->NextSiblingElement("Module"); } while(elem != 0); return modules; }
void File::parse(){ // Make sure we can parse the file TiXmlDocument doc(simFile); if(!doc.LoadFile()){ string exp_str = "Invalid simulation file: "; exp_str += simFile; throw(Exception(exp_str)); } // Get root node and check TiXmlHandle hDoc = TiXmlHandle(&doc); TiXmlElement *pParent = hDoc.FirstChild("simulation").ToElement(); if(!pParent) throw(Exception("Invalid root")); pParent->QueryIntAttribute("runs",&numRuns); pParent->QueryIntAttribute("seed",&seed); TiXmlNode* pChild; for(pChild = pParent->FirstChild(); pChild!=NULL; pChild = pChild->NextSibling()){ // Ignore comments if(pChild->Type() == TiXmlNode::TINYXML_COMMENT){ continue; } // Devicelist if(strcmp(pChild->Value(),"devicelist") == 0){ parseDevices(pChild); } // Strategylist else if(strcmp(pChild->Value(),"strategylist") == 0){ parseStrategies(pChild); } // Targetlist else if(strcmp(pChild->Value(),"targetlist") == 0){ parseTargets(pChild); } // Outputlist else if(strcmp(pChild->Value(),"outputlist") == 0){ parseOutputs(pChild); } } }
void StateLoader::LoadFunctionEnums(TiXmlHandle &handle, IGlobalState *state) { TiXmlElement *pElem; std::string name; std::string data = ""; std::string functionName; pElem = handle.FirstChild().Element(); for (; 0 != pElem; pElem = pElem->NextSiblingElement()) { TiXmlHandle methodHandle(pElem); pElem->QueryStringAttribute("function", &functionName); LoadEnums(methodHandle, functionName, state); } }
void StateLoader::LoadEnums(TiXmlHandle &hRoot, std::string functionName, IGlobalState *state) { std::string name = ""; std::string valueString = ""; TiXmlElement *pElem; TiXmlHandle handle(hRoot.FirstChild("enums").Element()); pElem = handle.FirstChild().Element(); for (; 0 != pElem; pElem = pElem->NextSiblingElement()) { int value, length = 1; pElem->QueryStringAttribute("name", &name); pElem->QueryStringAttribute("value", &valueString); if (pElem->QueryIntAttribute("length", &length) != TIXML_SUCCESS){ length = 1; } value = (int)strtol(valueString.c_str(), NULL, 0); state->addStateEnum(name, functionName, value, length); } }
void ComponentCashFlowMust::setComponent(TiXmlHandle docMUSTHandle, string nameLeg, string tradeId) { TiXmlElement *Component; TiXmlElement *Trade = docMUSTHandle.FirstChild("BODY").FirstChild("TRADELIST").FirstChild("MUST_TR").ToElement(); while (Trade) { if (strcmp(Trade->FirstChild("TradeId")->ToElement()->GetText(), tradeId.c_str()) == 0) { Component = Trade->FirstChild("MPTradeData")->FirstChild("MPTRDATA")->FirstChild("MPTrDataXML")->FirstChild("MPTRDATAXML")->FirstChild("STRUCTURED_INSTRUMENT")-> FirstChild("COMPONENT_LIST")->FirstChild("COMPONENT_CASHFLOW")->ToElement(); while (Component) { if (strcmp(Component->Value(), "COMPONENT_CASHFLOW") == 0) { if (strcmp(Component->FirstChild("NAME")->ToElement()->GetText(), nameLeg.c_str()) == 0) { CashFlowCcy = Component->FirstChild("PAYOFF_CCY")->FirstChild("CCY")->ToElement()->GetText(); CashFlowFreq = Component->FirstChild("PAY_SCHED")->FirstChild("BASIC_SCHED")->FirstChild("SCHED_DEF")->FirstChild("FREQ")->ToElement()->GetText(); freqQ = this->eff_convert_frequency(CashFlowFreq.c_str()[0]); CashFlowBasis = Component->FirstChild("BASIS_DEF")->FirstChild("BASIS")->ToElement()->GetText(); basisQ = this->eff_convert_basis(CashFlowBasis); } } Component = Component->NextSiblingElement(); } } Trade = Trade->NextSiblingElement(); } }
// Extract the definitions of the slots from the xml void converter::loadSlotDefs(TiXmlHandle &hRoot) { //printf("Loading slot defs\n"); m_slots.clear(); for( TiXmlElement* pElem=hRoot.FirstChild("slots").FirstChild("slot").Element(); pElem; pElem=pElem->NextSiblingElement()) { slotData slot; std::string slotName = pElem->Attribute("name"); slot.name = slotName; if ( pElem->QueryDoubleAttribute("x", &slot.x)!=TIXML_SUCCESS ) { errlogPrintf("sampleChanger: unable to read slot x attribute \"%s\"\n", slotName.c_str()); } if ( m_dims>1 && pElem->QueryDoubleAttribute("y", &slot.y)!=TIXML_SUCCESS ) { errlogPrintf("sampleChanger: unable to read slot y attribute \"%s\"\n", slotName.c_str()); } m_slots[slotName] = slot; //printf("Def slot %s\n", slot.name); } }