bool LoadMaterial(const char* pFilename, Material* pMtl) { TiXmlDocument doc(pFilename); if (!doc.LoadFile()) { printf("failed to load material %s\n", pFilename); return false; } TiXmlNode* pMtlRoot = doc.FirstChild("mtl"); TiXmlElement* pTex0Elem = pMtlRoot->FirstChildElement("tex0"); if (pTex0Elem) { pMtl->uTexture = LoadTexture(pTex0Elem->GetText()); } TiXmlElement* pSpecElem = pMtlRoot->FirstChildElement("spec"); if (pSpecElem) { pMtl->spec = StrToVec3(pSpecElem->GetText()); } TiXmlElement* pShininessElem = pMtlRoot->FirstChildElement("shininess"); if (pShininessElem) { pMtl->fShininess = (float)atof(pShininessElem->GetText()); } printf("loaded material %s\n", pFilename); return true; }
bool FunctionParsersManager::getUnitPaserParameters(TiXmlNode *functionParser, generic_string &mainExprStr, std::vector<generic_string> &functionNameExprArray, std::vector<generic_string> &classNameExprArray) { const TCHAR *mainExpr = (functionParser->ToElement())->Attribute(TEXT("mainExpr")); if (!mainExpr || !mainExpr[0]) return false; mainExprStr = mainExpr; TiXmlNode *functionNameParser = functionParser->FirstChild(TEXT("functionName")); if (functionNameParser) { for (TiXmlNode *childNode = functionNameParser->FirstChildElement(TEXT("nameExpr")); childNode; childNode = childNode->NextSibling(TEXT("nameExpr")) ) { const TCHAR *expr = (childNode->ToElement())->Attribute(TEXT("expr")); if (expr && expr[0]) functionNameExprArray.push_back(expr); } } TiXmlNode *classNameParser = functionParser->FirstChild(TEXT("className")); if (classNameParser) { for (TiXmlNode *childNode = classNameParser->FirstChildElement(TEXT("nameExpr")); childNode; childNode = childNode->NextSibling(TEXT("nameExpr")) ) { const TCHAR *expr = (childNode->ToElement())->Attribute(TEXT("expr")); if (expr && expr[0]) classNameExprArray.push_back(expr); } } return true; }
bool CSPrimMultiBox::ReadFromXML(TiXmlNode &root) { if (CSPrimitives::ReadFromXML(root)==false) return false;; TiXmlElement *SP=root.FirstChildElement("StartP"); TiXmlElement *EP=root.FirstChildElement("EndP"); if (vCoords.size()!=0) return false; int i=0; while ((SP!=NULL) && (EP!=NULL)) { for (int n=0;n<6;++n) this->AddCoord(0.0); if (ReadTerm(*vCoords.at(i*6),*SP,"X")==false) return false; if (ReadTerm(*vCoords.at(i*6+2),*SP,"Y")==false) return false; if (ReadTerm(*vCoords.at(i*6+4),*SP,"Z")==false) return false; if (ReadTerm(*vCoords.at(i*6+1),*EP,"X")==false) return false; if (ReadTerm(*vCoords.at(i*6+3),*EP,"Y")==false) return false; if (ReadTerm(*vCoords.at(i*6+5),*EP,"Z")==false) return false; // for (int n=0;n<6;++n) fprintf(stderr,"%e ",vCoords.at(i*6+n)->GetValue()); // fprintf(stderr,"\n"); SP=SP->NextSiblingElement("StartP"); EP=EP->NextSiblingElement("EndP"); ++i; }; return true; }
void LangHelper::SetNewTaskLv(HWND hDlg) { if (!hDlg || !_pXmlDoc) return ; HWND hwndLV = GetDlgItem(hDlg, IDC_LIST_TASK); if (hwndLV == 0) return ; TiXmlNode *node = _pXmlDoc->FirstChild("Language"); ASSERT_POINTER(node); node = node->FirstChild("Dialog"); ASSERT_POINTER(node); node = node->FirstChild("NewTask"); ASSERT_POINTER(node); node = node->FirstChild("FileList"); ASSERT_POINTER(node); TiXmlElement *item = node->FirstChildElement("FileName"); if (item) { const char *v = item->Attribute("text"); if (v) { LVCOLUMN lvc = {0}; TString str(v); lvc.mask = LVCF_TEXT; lvc.pszText = (TCHAR*)str.c_str(); ListView_SetColumn(hwndLV, 0, &lvc); } } item = node->FirstChildElement("FileSize"); if (item) { const char *v = item->Attribute("text"); if (v) { LVCOLUMN lvc = {0}; TString str(v); lvc.mask = LVCF_TEXT; lvc.pszText = (TCHAR*)str.c_str(); ListView_SetColumn(hwndLV, 1, &lvc); } } }
GupDownloadInfo::GupDownloadInfo(const char * xmlString) : _updateVersion(""), _updateLocation("") { _xmlDoc.Parse(xmlString); TiXmlNode *root = _xmlDoc.FirstChild("GUP"); if (!root) throw exception("It's not a valid GUP xml."); TiXmlNode *needUpdateNode = root->FirstChildElement("NeedToBeUpdated"); if (!needUpdateNode) throw exception("NeedToBeUpdated node is missed."); TiXmlNode *nun = needUpdateNode->FirstChild(); if (!nun) throw exception("NeedToBeUpdated is missed."); const char *nunVal = nun->Value(); if (!nunVal || !(*nunVal)) throw exception("NeedToBeUpdated is missed."); if (stricmp(nunVal, "yes") == 0) _need2BeUpdated = true; else if (stricmp(nunVal, "no") == 0) _need2BeUpdated = false; else throw exception("NeedToBeUpdated value is incorrect (only \"yes\" or \"no\" is allowed)."); if (_need2BeUpdated) { TiXmlNode *versionNode = root->FirstChildElement("Version"); if (versionNode) { TiXmlNode *n = versionNode->FirstChild(); if (n) { const char *val = n->Value(); if (val) { _updateVersion = val; } } } TiXmlNode *locationNode = root->FirstChildElement("Location"); if (!locationNode) throw exception("Location node is missed."); TiXmlNode *ln = locationNode->FirstChild(); if (!ln) throw exception("Location is missed."); const char *locVal = ln->Value(); if (!locVal || !(*locVal)) throw exception("Location is missed."); _updateLocation = locVal; } }
bool FunctionParsersManager::getZonePaserParameters(TiXmlNode *classRangeParser, generic_string &mainExprStr, generic_string &openSymboleStr, generic_string &closeSymboleStr, std::vector<generic_string> &classNameExprArray, generic_string &functionExprStr, std::vector<generic_string> &functionNameExprArray) { const TCHAR *mainExpr = NULL; const TCHAR *openSymbole = NULL; const TCHAR *closeSymbole = NULL; const TCHAR *functionExpr = NULL; mainExpr = (classRangeParser->ToElement())->Attribute(TEXT("mainExpr")); if (!mainExpr || !mainExpr[0]) return false; mainExprStr = mainExpr; openSymbole = (classRangeParser->ToElement())->Attribute(TEXT("openSymbole")); if (openSymbole && openSymbole[0]) openSymboleStr = openSymbole; closeSymbole = (classRangeParser->ToElement())->Attribute(TEXT("closeSymbole")); if (closeSymbole && closeSymbole[0]) closeSymboleStr = closeSymbole; TiXmlNode *classNameParser = classRangeParser->FirstChild(TEXT("className")); if (classNameParser) { for (TiXmlNode *childNode2 = classNameParser->FirstChildElement(TEXT("nameExpr")); childNode2; childNode2 = childNode2->NextSibling(TEXT("nameExpr")) ) { const TCHAR *expr = (childNode2->ToElement())->Attribute(TEXT("expr")); if (expr && expr[0]) classNameExprArray.push_back(expr); } } TiXmlNode *functionParser = classRangeParser->FirstChild(TEXT("function")); if (!functionParser) return false; functionExpr = (functionParser->ToElement())->Attribute(TEXT("mainExpr")); if (!functionExpr || !functionExpr[0]) return false; functionExprStr = functionExpr; TiXmlNode *functionNameParser = functionParser->FirstChild(TEXT("functionName")); if (functionNameParser) { for (TiXmlNode *childNode3 = functionNameParser->FirstChildElement(TEXT("funcNameExpr")); childNode3; childNode3 = childNode3->NextSibling(TEXT("funcNameExpr")) ) { const TCHAR *expr = (childNode3->ToElement())->Attribute(TEXT("expr")); if (expr && expr[0]) functionNameExprArray.push_back(expr); } } return true; }
bool CSProperties::ReadFromXML(TiXmlNode &root) { TiXmlElement* prop = root.ToElement(); if (prop==NULL) return false; int help; if (prop->QueryIntAttribute("ID",&help)==TIXML_SUCCESS) uiID=help; const char* cHelp=prop->Attribute("Name"); if (cHelp!=NULL) sName=string(cHelp); else sName.clear(); TiXmlElement* FC = root.FirstChildElement("FillColor"); if (FC!=NULL) { if (FC->QueryIntAttribute("R",&help)==TIXML_SUCCESS) FillColor.R=(unsigned char) help; if (FC->QueryIntAttribute("G",&help)==TIXML_SUCCESS) FillColor.G=(unsigned char) help; if (FC->QueryIntAttribute("B",&help)==TIXML_SUCCESS) FillColor.B=(unsigned char) help; if (FC->QueryIntAttribute("a",&help)==TIXML_SUCCESS) FillColor.a=(unsigned char) help; } TiXmlElement* EC = root.FirstChildElement("EdgeColor"); if (EC!=NULL) { if (EC->QueryIntAttribute("R",&help)==TIXML_SUCCESS) EdgeColor.R=(unsigned char) help; if (EC->QueryIntAttribute("G",&help)==TIXML_SUCCESS) EdgeColor.G=(unsigned char) help; if (EC->QueryIntAttribute("B",&help)==TIXML_SUCCESS) EdgeColor.B=(unsigned char) help; if (EC->QueryIntAttribute("a",&help)==TIXML_SUCCESS) EdgeColor.a=(unsigned char) help; } TiXmlElement* att_root = root.FirstChildElement("Attributes"); if (att_root) { TiXmlAttribute* att = att_root->FirstAttribute(); while (att) { AddAttribute(att->Name(),att->Value()); att = att->Next(); } } return true; }
QuantLib::Period timeUnit(TiXmlNode* node) { TiXmlNode* thisNode = node->FirstChildElement("tenor"); if(!thisNode) thisNode = node; TiXmlElement* periodMultiNode = thisNode->FirstChildElement("periodMultiplier"); TiXmlElement* periodNode = thisNode->FirstChildElement("period"); Integer multi = std::atoi(periodMultiNode->GetText()); std::string period = periodNode->GetText(); return this->timeUnit(multi,period); }
bool CMetadataResolverMusic::LoadAlbumsInfo(BOXEE::BXXMLDocument& doc, vectorMetadata& list) { TiXmlElement* pRootElement = doc.GetDocument().RootElement(); bool bRetVal = true; if (pRootElement->ValueStr() == "results") { TiXmlNode* pTag = 0; BXMetadata album(MEDIA_ITEM_TYPE_AUDIO); while ((pTag = pRootElement->IterateChildren(pTag))) { if (pTag && pTag->ValueStr() == "album") { TiXmlElement* pValue = pTag->FirstChildElement(); if (pValue && (LoadAlbumInfo(pValue,album))) list.push_back(album); else bRetVal = false; } else bRetVal = false; } } else bRetVal = false; return bRetVal; }
bool CSPrimPolygon::ReadFromXML(TiXmlNode &root) { if (CSPrimitives::ReadFromXML(root)==false) return false; TiXmlElement *elem = root.ToElement(); if (elem==NULL) return false; if (ReadTerm(Elevation,*elem,"Elevation")==false) Elevation.SetValue(0); int help; if (elem->QueryIntAttribute("NormDir",&help)!=TIXML_SUCCESS) return false; m_NormDir=help; TiXmlElement *VT=root.FirstChildElement("Vertex"); if (vCoords.size()!=0) return false; int i=0; while (VT) { for (int n=0;n<2;++n) this->AddCoord(0.0); if (ReadTerm(vCoords.at(i*2),*VT,"X1")==false) return false; if (ReadTerm(vCoords.at(i*2+1),*VT,"X2")==false) return false; VT=VT->NextSiblingElement("Vertex"); ++i; }; return true; }
void DirectoryWriter::DeleteNode(char *nodeName) { TiXmlDocument doc("Config.xml"); bool loadOkay = doc.LoadFile(); if (!loadOkay) { printf("Could not load test file 'Config.xml'. Error='%s'. Exiting.\n", doc.ErrorDesc()); exit(1); } TiXmlNode *versionNode = 0; versionNode = doc.FirstChild("Version"); TiXmlElement *versionelement = versionNode->ToElement(); std::string version = versionelement->Attribute("Number"); int value = atoi(version.c_str()); value += 1; versionelement->SetAttribute("Number", value); TiXmlNode *node = 0; node = doc.FirstChild("Filesystem"); TiXmlElement *searchNode = 0; for (TiXmlElement* e = node->FirstChildElement("File"); e != NULL; e = e->NextSiblingElement("File")) { const char *attribute = e->Attribute("filename"); if (strcmp(attribute, nodeName) == 0) { node->RemoveChild(e); break; } } doc.SaveFile(); }
void WebCoreClass::logIn(const char* user, const char* pass, TiXmlDocument &doc) { if (m_bUserAuth) throw gcException(ERR_ALREADYLOGGEDIN); PostMap post; post["username"] = user; post["password"] = pass; TiXmlNode* uNode = loginToServer(getLoginUrl(), "memberlogin", post, doc); TiXmlElement *memNode = uNode->FirstChildElement("member"); if (!memNode) throw gcException(ERR_BADXML); const char* idStr = memNode->Attribute("siteareaid"); if (!idStr || atoi(idStr) < 0) throw gcException(ERR_BAD_PORU); m_uiUserId = atoi(idStr); TiXmlNode *cookieNode = memNode->FirstChild("cookies"); if (cookieNode) { XML::GetChild("id", m_szIdCookie, cookieNode); XML::GetChild("session", m_szSessCookie, cookieNode); } m_bUserAuth = true; }
BOOL CTestScript::InitOccuList() { m_mapOccu.clear(); char strfile[512] = "setup\\ChangeOccu.xml"; TiXmlNode *pNode = NULL; TiXmlDocument doc(strfile); ///载入配置文件 if(!doc.LoadFile()) { return FALSE; } pNode = doc.FirstChild("ChangeOccu"); if(pNode) { int i = 0; TiXmlElement *pChildElement = pNode->FirstChildElement(); for(; pChildElement!=NULL; pChildElement=pChildElement->NextSiblingElement()) { if(!strcmp(pChildElement->Value(),"Occu")) { m_mapOccu[i] = string(pChildElement->Attribute("name")); m_ctrlOcculist.InsertString(i,m_mapOccu[i].c_str()); i++; } } } return TRUE; }
void LangHelper::GetMsgBox(const char *type, TString &text, TString &title) { if (type == 0 || _pXmlDoc == 0) return ; TiXmlNode *nodeMsg = _pXmlDoc->FirstChild("Language"); if (!nodeMsg) return ; nodeMsg = nodeMsg->FirstChild("MsgBox"); if (!nodeMsg) return ; TiXmlElement *item = nodeMsg->FirstChildElement(type); if (item) { const char *v = item->Attribute("title"); if (v){ title = v; } } item = item->FirstChildElement("Text"); if (item) { TiXmlNode *node = item->FirstChild(); if (node) { const char *v = node->Value(); if (v){ text = v; } } } }
XMLtoVecteur::XMLtoVecteur(string path) { TiXmlDocument doc(path); bool loadOkay = doc.LoadFile(); if (loadOkay) { TiXmlNode* vecteurs = doc.FirstChild("Vecteurs"); if (vecteurs != NULL) { TiXmlElement* child = vecteurs->FirstChildElement(); while (child != NULL) { this->vecteurs.push_back(this->xmlToVecteur(child)); child = child->NextSiblingElement(); } } else { cout << "Bad document " << path << endl; } } else { cout << "Failed to load file " << path << endl; } }
/**Parser xml extrai nomes de ficheiros que conteem os triângulos das figuras a desenhar*/ void readFromXML(string filename) { const char * nomeFich = filename.c_str(); TiXmlDocument doc(nomeFich); doc.LoadFile(); TiXmlHandle docHandle(&doc); TiXmlNode * node = docHandle.FirstChild("imagem").ToNode(); TiXmlElement * element; TiXmlElement * aux; element = node->FirstChildElement(); readGrupoFromXML(element); /*BLOCO DE TESTE DO PARSER XML*/ /*-------------------------- TESTE ---------------------------*/ /*for (std::vector<Forma*>::iterator it = formas.begin(); it != formas.end(); ++it){ (*it)->printAllTransforms(); }*/ }
bool CSPrimBox::ReadFromXML(TiXmlNode &root) { if (CSPrimitives::ReadFromXML(root)==false) return false; if (m_Coords[0].ReadFromXML(root.FirstChildElement("P1")) == false) return false; if (m_Coords[1].ReadFromXML(root.FirstChildElement("P2")) == false) return false; return true; }
void WriteToXml(string& strXml, vector<bool>& vecType,string& FileName) { COriFileOperate oriFile(FileName); size_t nVecSize = vecType.size(); if (strXml.find("chinese_simple") != -1) { for (size_t i=1;i<nVecSize;++i) { vecType[i] = false; } } char* szNumOrStrInfo = new char[nVecSize+1]; for (size_t i = 0; i < nVecSize; i++) { if (vecType[i]) { szNumOrStrInfo[i] = 'n'; } else { szNumOrStrInfo[i] = 's'; } } szNumOrStrInfo[nVecSize] = '\0'; TiXmlDocument* pXmlDoc = new TiXmlDocument; pXmlDoc->InsertEndChild(TiXmlElement("config")); TiXmlNode* pXmlNode = pXmlDoc->FirstChild("config"); pXmlNode->InsertEndChild(TiXmlElement("TableType")); TiXmlElement* pXmlElem = pXmlNode->FirstChildElement("TableType"); pXmlElem->InsertEndChild(TiXmlText("S")); string str = szNumOrStrInfo; string str1 = oriFile.GetDataByRowCol(0,0); transform(str1.begin(),str1.end(),str1.begin(),toupper); for(uint32 i=1;i<=str.size();i++) { TiXmlElement* cxn = new TiXmlElement("Col"); pXmlNode->LinkEndChild(cxn); // cxn->SetAttribute("ColNum",i); if(str1!="NOTE:") { cxn->SetAttribute("Name",oriFile.GetDataByRowCol(0,i-1).c_str()); } else { cxn->SetAttribute("Name",oriFile.GetDataByRowCol(1,i-1).c_str()); } string ss; stringstream temp; temp<<szNumOrStrInfo[i-1]; temp>>ss; cxn->SetAttribute("Type",ss); } pXmlDoc->SaveFile(strXml); delete pXmlDoc; pXmlDoc = NULL; delete[] szNumOrStrInfo; szNumOrStrInfo = NULL; }
void SpellCheckHelper::LoadConfiguration() { //TiXmlDocument doc("OnlineSpellChecking.xml"); wxString fname = SpellCheckerPlugin::GetOnlineCheckerConfigPath() + wxFILE_SEP_PATH + _T("OnlineSpellChecking.xml"); TiXmlDocument doc( fname.char_str() ); if( !doc.LoadFile() ) Manager::Get()->GetLogManager()->Log( _("SpellCheck Plugin: Error loading Online SpellChecking Configuration file \"") + fname +_T("\"") ); TiXmlNode *rootnode = doc.FirstChildElement( "OnlineSpellCheckingConfigurationFile" ); if ( rootnode ) { for ( TiXmlElement* LangElement = rootnode->FirstChildElement("Language"); LangElement; LangElement = LangElement->NextSiblingElement("Language") ) { wxString name = wxString( LangElement->Attribute("name"), wxConvUTF8 ); // comma-separated indices wxString index = wxString ( LangElement->Attribute("index"), wxConvUTF8 ); // break-up array wxArrayString indices = GetArrayFromString(index, _T(",")); std::set<long> idcs; for (size_t i = 0; i < indices.GetCount(); ++i) { if (indices[i].IsEmpty()) continue; long value = 0; indices[i].ToLong(&value); idcs.insert(value); } if ( idcs.size() > 0) m_LanguageIndices[name] = idcs; } } }
void CTestScript::LoadCaseSetup() { //载入配置文件 char strfile[512] = "TestCase\\TestCases.xml"; TiXmlDocument doc(strfile); if(!doc.LoadFile()) { PutDebugString("装载配置文件<TestCases.xml>出错!"); return; } //读配置 TiXmlNode *pTestNode = NULL; pTestNode = doc.FirstChild("Test"); if(pTestNode) { TiXmlElement* caseElem = pTestNode->FirstChildElement(); for(; caseElem!=NULL; caseElem = caseElem->NextSiblingElement()) { if(!strcmp(caseElem->Value(),"case")) { LoadCase(caseElem); } } } }
void BBWinConfig::LoadConfiguration(const string & fileName, const string & configNameSpace, bbwinconfig_t & config) { string configName(BBWIN_CONFIG_ROOT); EnterCriticalSection(&m_configCriticalSection); m_path = fileName; m_doc = new TiXmlDocument(m_path.c_str()); if (m_doc == NULL) throw BBWinConfigException("can't allocare tinyxml instance"); bool loadOkay = m_doc->LoadFile(); if ( !loadOkay ) { LeaveCriticalSection(&m_configCriticalSection); throw BBWinConfigException(m_doc->ErrorDesc()); } TiXmlElement *root = m_doc->FirstChildElement( "configuration" ); if ( root ) { TiXmlNode * nameSpaceNode = root->FirstChild( configNameSpace.c_str() ); if ( nameSpaceNode ) { TiXmlElement * elem; for (elem = nameSpaceNode->FirstChildElement(); elem ; elem = elem->NextSiblingElement()) { bbwinconfig_attr_t config_attr; if (elem->Type() == TiXmlNode::ELEMENT) { TiXmlAttribute * attr; for (attr = elem->FirstAttribute(); attr; attr = attr->Next()) { config_attr.insert(pair< string, string >(attr->Name(), attr->Value())); } } config.insert(pair < string, bbwinconfig_attr_t > (elem->Value(), config_attr)); } } } delete m_doc; m_doc = NULL; LeaveCriticalSection(&m_configCriticalSection); }
bool Pipeline::load() { std::string path = getPath(); std::string directory = core::FileSystem::getDirectory(path); // Parse XML file TiXmlDocument xml(path.c_str()); if (!loadResourceFile(xml)) { finishLoading(false); return false; } // Load XML file TiXmlNode *root = xml.FirstChild("Pipeline"); if (!root) { getManager()->getLog()->error("%s: <Pipeline> not found.", getName().c_str()); finishLoading(false); return false; } // Load render target setup TiXmlElement *setupelem = root->FirstChildElement("Setup"); if (setupelem) { if (!loadSetup(setupelem)) { finishLoading(false); return false; } } // Load commands TiXmlElement *commandelem = root->FirstChildElement("Commands"); if (!commandelem) { getManager()->getLog()->error("%s: <Commands> not found.", getName().c_str()); finishLoading(false); return false; } if (!loadCommands(commandelem)) { finishLoading(false); return false; } finishLoading(true); return true; }
void N7Xml::list_channels() { CStdString strUrl; strUrl.Format("http://%s:%i/n7channel_nt.xml", g_strHostname.c_str(), g_iPort); CStdString strXML; CCurlFile http; if(!http.Get(strUrl, strXML)) { XBMC->Log(LOG_DEBUG, "N7Xml - Could not open connection to N7 backend."); } else { TiXmlDocument xml; xml.Parse(strXML.c_str()); TiXmlElement* rootXmlNode = xml.RootElement(); if (rootXmlNode == NULL) return; TiXmlElement* channelsNode = rootXmlNode->FirstChildElement("channel"); if (channelsNode) { XBMC->Log(LOG_DEBUG, "N7Xml - Connected to N7 backend."); m_connected = true; int iUniqueChannelId = 0; TiXmlNode *pChannelNode = NULL; while ((pChannelNode = channelsNode->IterateChildren(pChannelNode)) != NULL) { CStdString strTmp; PVRChannel channel; /* unique ID */ channel.iUniqueId = ++iUniqueChannelId; /* channel number */ if (!XMLUtils::GetInt(pChannelNode, "number", channel.iChannelNumber)) channel.iChannelNumber = channel.iUniqueId; /* channel name */ if (!XMLUtils::GetString(pChannelNode, "title", strTmp)) continue; channel.strChannelName = strTmp; /* icon path */ const TiXmlElement* pElement = pChannelNode->FirstChildElement("media:thumbnail"); channel.strIconPath = pElement->Attribute("url"); /* channel url */ if (!XMLUtils::GetString(pChannelNode, "guid", strTmp)) channel.strStreamURL = ""; else channel.strStreamURL = strTmp; m_channels.push_back(channel); } } } }
void Profile::read_from_configuration (Configuration* configuration) { TiXmlNode* node = 0; // insert initial mandatory declaration if not present TiXmlNode* decl = 0; for (TiXmlNode* child = xmlProfileDoc->FirstChild(); child && !decl; child = child->NextSibling() ) { decl = child->ToDeclaration (); } if (! decl) { node = xmlProfileDoc->InsertEndChild( TiXmlDeclaration( "1.0", "UTF-8", "no" ) ); assert (node); } // for each configuration variable in configuration for (std::map<std::string, Variable*>::const_iterator conf_it = configuration->begin(); conf_it != configuration->end(); conf_it ++) { // start from root of DOM node = xmlProfileDoc; // get the variable name and break it up in its component vector std::string variable_name = conf_it->second->get_name (); std::vector<std::string> variable_name_vector = Variable::string_to_vector (variable_name); // for each component in variable name vector for (size_t i = 0; i < variable_name_vector.size(); i++) { // check if component element exists TiXmlElement* existing = node->FirstChildElement (variable_name_vector[i].c_str()); if (existing) { // carry on with existing component node = existing; } else { // create missing component element and carry on with new component node = node->InsertEndChild (TiXmlElement (variable_name_vector[i].c_str())); assert (node); } } // check if a text node for element exists TiXmlText* text = 0; for(TiXmlNode* child = node->FirstChild(); child && !text; child = child->NextSibling() ) { text = child->ToText (); } if (text) { // text child already exists, so remove it to set new value node->RemoveChild (text); } node = node->InsertEndChild (TiXmlText (conf_it->second->get_value ().c_str ())); assert (node); } }
void CButtonTranslator::MapWindowActions(TiXmlNode *pWindow, int windowID) { if (!pWindow || windowID == WINDOW_INVALID) return; buttonMap map; std::map<int, buttonMap>::iterator it = translatorMap.find(windowID); if (it != translatorMap.end()) { map = it->second; translatorMap.erase(it); } TiXmlNode* pDevice; const char* types[] = {"gamepad", "remote", "universalremote", "keyboard", "appcommand", NULL}; for (int i = 0; types[i]; ++i) { CStdString type(types[i]); if (HasDeviceType(pWindow, type)) { pDevice = pWindow->FirstChild(type); TiXmlElement *pButton = pDevice->FirstChildElement(); while (pButton) { uint32_t buttonCode=0; if (type == "gamepad") buttonCode = TranslateGamepadString(pButton->Value()); else if (type == "remote") buttonCode = TranslateRemoteString(pButton->Value()); else if (type == "universalremote") buttonCode = TranslateUniversalRemoteString(pButton->Value()); else if (type == "keyboard") buttonCode = TranslateKeyboardButton(pButton); else if (type == "appcommand") buttonCode = TranslateAppCommand(pButton->Value()); if (buttonCode && pButton->FirstChild()) MapAction(buttonCode, pButton->FirstChild()->Value(), map); pButton = pButton->NextSiblingElement(); } } } #if defined(HAS_SDL_JOYSTICK) || defined(HAS_EVENT_SERVER) if ((pDevice = pWindow->FirstChild("joystick")) != NULL) { // map joystick actions while (pDevice) { MapJoystickActions(windowID, pDevice); pDevice = pDevice->NextSibling("joystick"); } } #endif // add our map to our table if (map.size() > 0) translatorMap.insert(pair<int, buttonMap>( windowID, map)); }
void ProfileInfo() { char XfireUsername[64]; GetPrivateProfileString("Xfire", "Username", "", XfireUsername, sizeof(XfireUsername), IniFile); if(CanRun() && strcmp(XfireUsername, "") != 0) { //^_^ const string LoadingMessage = "Loading profile info... "; cout << LoadingMessage; Socket Socket; Socket.ConnectInfo.Address = "www.xfire.com"; Socket.ConnectInfo.Port = 80; Socket::SockMessage Message; string XfireProfileXML = ""; if(Socket.Connect(Socket.ConnectInfo)) { char RequestStr[128]; sprintf(RequestStr, "GET /xml/%s/user_gameplay/ HTTP/1.0\r\nHost: %s\r\nConnection: close\r\n\r\n", XfireUsername, Socket.ConnectInfo.Address); Socket.SendData(RequestStr); while(Socket.RecvData(Message, Socket.MSGLEN) > 0) XfireProfileXML += Message; Socket.CloseConnection(); TiXmlDocument Doc; Doc.Parse(XfireProfileXML.substr(XfireProfileXML.find("<?xml"), XfireProfileXML.length()).c_str()); if(!Doc.Error()) { TiXmlElement *DocRoot = Doc.RootElement(); TiXmlNode *DocAttribute = DocRoot->FirstChild(); int XfireHours = 0; while(DocAttribute) { XfireHours += atoi(DocAttribute->FirstChildElement("weektime")->GetText()); DocAttribute = DocAttribute->NextSibling(); } for(unsigned int i = 1; i <= LoadingMessage.length(); i++) cout << "\b"; cout.setf(ios::fixed, ios::floatfield); cout.precision(1); cout << "(Xfire):\t\t" << (float) XfireHours / (60 * 60) << endl; } else cout << "Unable to parse XML: " << Doc.ErrorDesc() << endl; } else cout << "Unable to create socket." << endl; } }
void Sprite::reload() { TiXmlNode* xSprite; int texture_id; // Release resources clean(); try { cout << "Loading " << sprite_file << "..." << endl; TiXmlDocument doc(sprite_file); bool loadOkay = doc.LoadFile(); xSprite = doc.FirstChild("sprite"); if(xSprite != 0) { //position sscanf(xSprite->FirstChildElement("position")->Attribute("x"), "%d", &x); sscanf(xSprite->FirstChildElement("position")->Attribute("y"), "%d", &y); //texture sscanf(xSprite->FirstChildElement("texture")->Attribute("id"), "%d", &texture_id); texture = Game::getInstance()->getTextureManager()->getTexture(texture_id); //animation current_frame = 0; counter = 0; sscanf(xSprite->FirstChildElement("animation")->Attribute("frames"), "%d", &frames); frame_width = (float) (texture->getWidth() / frames); offset_x = frame_width / texture->getWidth(); sscanf(xSprite->FirstChildElement("animation")->Attribute("time"), "%f", &animation_time); for(TiXmlElement* frame = xSprite->FirstChildElement("animation")->FirstChildElement("frame"); frame != 0; frame = frame->NextSiblingElement("frame")) { int value; sscanf(frame->GetText(), "%d", &value); animation.push_back(value); } } } catch(exception& e) { cout << "Error loading " << sprite_file << endl; cout << e.what() << endl; } }
void UpdateThreadOld::loadLoginItems() { UserCore::ItemManager* im = dynamic_cast<UserCore::ItemManager*>(m_pUser->getItemManager()); TiXmlDocument doc; try { m_pWebCore->getLoginItems(doc); TiXmlNode* first = doc.FirstChildElement("memberdata"); im->parseLoginXml2(first->FirstChildElement("games"), first->FirstChildElement("platforms")); } catch (gcException &e) { Warning(gcString("Failed to get login items: {0}\n", e)); } im->enableSave(); m_pUser->getLoginItemsLoadedEvent()->operator()(); }
void DirectoryWriter::UpdateNode(string nodeName, string directory, string editDate) { TiXmlDocument doc("Config.xml"); bool loadOkay = doc.LoadFile(); if (!loadOkay) { printf("Could not load test file 'Config.xml'. Error='%s'. Exiting.\n", doc.ErrorDesc()); exit(1); } TiXmlNode *versionNode = 0; versionNode = doc.FirstChild("Version"); TiXmlElement *versionelement = versionNode->ToElement(); std::string version = versionelement->Attribute("Number"); int value = atoi(version.c_str()); value += 1; versionelement->SetAttribute("Number", value); TiXmlNode *node = 0; node = doc.FirstChild("Filesystem"); TiXmlElement *searchNode = 0; for (TiXmlElement* e = node->FirstChildElement("File"); e != NULL; e = e->NextSiblingElement("File")) { const char *attribute = e->Attribute("Originalname"); if (strcmp(attribute, nodeName.c_str()) == 0) { vector<string> segments = vector<string>(); StrSplit(e->Attribute("directory"), segments); segments.pop_back(); segments.push_back(nodeName); string directory = ""; for (size_t i = 0; i < segments.size(); i++) { directory.append(segments[i]); if (i != segments.size() - 1) { directory.append("/"); } } e->SetAttribute("filename", nodeName.c_str()); e->SetAttribute("Editdate", editDate.c_str()); e->SetAttribute("directory", directory.c_str()); break; } } doc.SaveFile(); }
kerberos::StringMap getSettingsFromXML(const std::string & path) { kerberos::StringMap settings; std::string directory = path.substr(0,path.rfind('/')) + "/" ; TiXmlDocument doc(path.c_str()); if(doc.LoadFile()) { TiXmlNode * root = doc.FirstChildElement("kerberos"); if(root) { root = root->FirstChildElement("instance"); TiXmlElement * node = root->FirstChildElement(); while (node) { settings[node->Value()] = node->ToElement()->GetText(); if(node->Attribute("file") != 0) { // read configuration file.. std::string path = directory + node->Attribute("file"); TiXmlDocument doc(path.c_str()); if(doc.LoadFile()) { TiXmlElement * subnode = doc.FirstChildElement(); getSettingsFromXML(subnode, subnode->Value(), settings); } } node = node->NextSiblingElement(); } } } else { throw TinyXMLOpenFileException(); } return settings; }