/** * Scan the core node that will have the pins and clock nodes. * Also will read the core ID and the core id address. * @param xml is the xml node "pins" * @return RES_OK or ERROR_XML if the attribute was not found. */ int ResourceMap::scanCoreXML(TiXmlNode *xml) { const char* description; TiXmlNode* cChild; // Get the address and ID information from core node if ((getXMLAttribute(xml, "addr",&this->core_addr)<0)|| (getXMLAttribute(xml, "id",&this->core_id)<0)) { return ERROR_XML; } // Get the core description and store it description = xml->ToElement()->Attribute("description"); if (description) { if (core_description) free(core_description); core_description = strdup(description); } else { if (core_description) free(core_description); core_description = NULL; } cChild=xml->FirstChild(); while(cChild!=0) { if (strcmp(cChild->Value(),"clocks")==0) { scanCoreXMLClocks(cChild); } else if (strcmp(cChild->Value(),"pins")==0) { scanCoreXMLPins(cChild); } cChild = cChild->NextSibling(); } return 0; }
std::string GD_EXTENSION_API GetText(const std::string &refName, RuntimeScene &scene) { TiXmlNode *refNode = RefManager::Get(&scene)->GetRef(refName); if(refNode) { return std::string(refNode->Value()); } return ""; }
//GetItemValue String XmlArchiveFile::GetItemValue( TiXmlNode* node ) { String value = ""; if ( node ) { TiXmlNode* valNode = node->FirstChild(); if ( valNode && valNode->Type() == TiXmlNode::TEXT ) value = valNode->Value(); } return value; }
std::string GetElementChildValue(TiXmlElement *pElement, const char *szChildName) { std::string ret; TiXmlNode *pNode = pElement->FirstChild(szChildName); if (!pNode) return ret; pNode = pNode->FirstChild(); if (!pNode) return ret; ret = pNode->Value(); return ret; }
wxString GetTextElement(TiXmlElement* node) { wxASSERT(node); for (TiXmlNode* pChild = node->FirstChild(); pChild; pChild = pChild->NextSibling()) { if (pChild->ToText()) { return ConvLocal(pChild->Value()); } } return wxString(); }
TiXmlNode *TiXmlNode::LastChild(const char *_value) { TiXmlNode *node; for (node = lastChild; node; node = node->prev) { if (strcmp(node->Value(), _value) == 0) { return node; } } return 0; }
TiXmlNode *TiXmlNode::FirstChild(const char *_value) { TiXmlNode *node; for (node = firstChild; node; node = node->next) { if (strcmp(node->Value(), _value) == 0) { return node; } } return 0; }
TiXmlNode *TiXmlNode::PreviousSibling(const char *_value) { TiXmlNode *node; for (node = prev; node; node = node->prev) { if (strcmp(node->Value(), _value) == 0) { return node; } } return 0; }
TiXmlNode *TiXmlNode::NextSibling(const char *_value) { TiXmlNode *node; for (node = next; node; node = node->next) { if (strcmp(node->Value(), _value) == 0) { return node; } } return 0; }
vector<TiXmlNode*> XmlParser::getAgentChildren(TiXmlNode* node) { vector<TiXmlNode*> agentChildren; for (TiXmlNode* child = node->FirstChild(); child; child = child->NextSibling()) { string value = child->Value(); if (child != NULL && !value.empty() && // if node has defined value this->tagParsers.count(value) > 0) { // that matches a tag parser agentChildren.push_back(child); } } return agentChildren; }
XmlNode TinyXmlInterface::addNode(TiXmlNode* n) { if (!n) throw CasadiException("Error in TinyXmlInterface::addNode: Node is 0"); XmlNode ret; // Save name ret.setName(n->Value()); // Save attributes int type = n->Type(); if (type == TiXmlNode::TINYXML_ELEMENT) { if (n->ToElement()!=0) { for (TiXmlAttribute* pAttrib=n->ToElement()->FirstAttribute(); pAttrib; pAttrib=pAttrib->Next()) { ret.setAttribute(pAttrib->Name(), pAttrib->Value()); } } } else if (type == TiXmlNode::TINYXML_DOCUMENT) { // do nothing } else { throw CasadiException("TinyXmlInterface::addNode"); } // Count the number of children int num_children = 0; for (TiXmlNode* child = n->FirstChild(); child != 0; child= child->NextSibling()) { num_children++; } ret.children_.reserve(num_children); // add children int ch = 0; for (TiXmlNode* child = n->FirstChild(); child != 0; child= child->NextSibling(), ++ch) { int childtype = child->Type(); if (childtype == TiXmlNode::TINYXML_ELEMENT) { XmlNode newnode = addNode(child); ret.children_.push_back(newnode); ret.child_indices_[newnode.getName()] = ch; } else if (childtype == TiXmlNode::TINYXML_COMMENT) { ret.comment_ = child->Value(); } else if (childtype == TiXmlNode::TINYXML_TEXT) { ret.text_ = child->ToText()->Value(); } else if (childtype == TiXmlNode::TINYXML_DECLARATION) { cout << "Warning: Skipped TiXmlNode::TINYXML_DECLARATION" << endl; } else { throw CasadiException("Error in TinyXmlInterface::addNode: Unknown node type"); } } // Note: Return value optimization return ret; }
TiXmlNode* XMLDocument::FindNode( const kvs::XMLDocument* document, const std::string& node_name ) { TiXmlNode* node = document->FirstChild(); while( node ) { if( node->Value() == node_name ) return node; node = node->NextSibling(); } return NULL; }
bool writeconf(int hconf,char *option,char *field,char *value ) { TiXmlNode *node = 0; TiXmlElement *rootElement = 0; TiXmlElement *settingElement = 0; TiXmlElement *fieldElement = 0; TiXmlElement *newldElement = 0; TiXmlDocument *pdoc = 0; TiXmlText *pTextValue = 0; TiXmlNode *pTextNode = 0; if(hconf){ pdoc = (TiXmlDocument*)hconf; } else { return false; } node = pdoc->RootElement(); if(!node){ //here we need create a new node node = new TiXmlElement(ROOT_NAME); pdoc->LinkEndChild(node); //root element no exist,the create a new element } if(strcmp(ROOT_NAME,node->Value())){ //delete and create a new one return false; } rootElement = node->ToElement(); //we come to <SNWTool> </SNWTool> element settingElement = rootElement->FirstChildElement(option); if( settingElement) { fieldElement = settingElement->FirstChildElement(field); if(fieldElement){ pTextNode = fieldElement->FirstChild(); if(pTextNode) { pTextNode->SetValue(value); } else { pTextValue = new TiXmlText(value); fieldElement->LinkEndChild(pTextValue); } } else { pTextValue = new TiXmlText(value); fieldElement = new TiXmlElement(field); fieldElement->LinkEndChild(pTextValue); settingElement->LinkEndChild( fieldElement ); } } else { pTextValue = new TiXmlText(value); fieldElement = new TiXmlElement(field); fieldElement->LinkEndChild(pTextValue); settingElement = new TiXmlElement(option); settingElement->LinkEndChild( fieldElement ); rootElement->LinkEndChild( settingElement ); } return true; }
//FIXME string CTinyXMLAttributeExchangingObject::getString(const string& name) throw(CParsingException) { for(TiXmlNode* child = mRoot->FirstChild(name.c_str()); child; child = child->NextSibling(name.c_str())) { /*TiXmlText* myElement = child->ToText(); if(myElement) */return child->Value(); } THROW_PARSING("Element \"" + name + "\" not found."); }
int KSGTaskParams::Parse(const std::string& str) { TiXmlDocument doc; doc.Parse(str.c_str()); TiXmlNode* root = doc.FirstChild("taskdef"); if(!root) return -1; TiXmlNode* elem = root->FirstChild(); while(elem!=NULL) { //elem->f TiXmlNode* t = elem->FirstChild(); if(t) PutParam(elem->Value(),t->Value()); else PutParam(elem->Value(),""); elem = elem->NextSibling(); } return 0; }
bool readvalue(int hconf,const char *field,char *value,int *cnt) { TiXmlNode *node = 0; TiXmlElement *rootElement = 0; //TiXmlElement *settingElement = 0; TiXmlElement *fieldElement = 0; TiXmlElement *newldElement = 0; TiXmlDocument *pdoc = 0; TiXmlText *pTextValue = 0; TiXmlNode *pTextNode = 0; const char *tvalue = 0; //every node no exist we should return false if(hconf){ pdoc = (TiXmlDocument*)hconf; } else { return false; } node = pdoc->RootElement(); if(!node){ return false; } if(strcmp(ROOT_NAME,node->Value())){ //delete and create a new one return false; } rootElement = node->ToElement(); //we enter <SNWTool> </SNWTool> element fieldElement = rootElement->FirstChildElement(field); if(fieldElement){ pTextNode = fieldElement->FirstChild(); if(pTextNode) { tvalue = pTextNode->Value(); if(strlen(tvalue) < *cnt - 1){ strcpy_s(value,*cnt,tvalue); *cnt = strlen(tvalue); return true; } } } return false; }
/* * Handle <title>. */ bool PhoneData::ProcessTitle(TiXmlNode* pNode) { TiXmlNode* pChild; pChild = pNode->FirstChild(); if (pChild->Type() != TiXmlNode::TEXT) { fprintf(stderr, "SimCFG: title is funky\n"); return false; } SetTitle(pChild->Value()); return true; }
/* * TinyXml has loaded and parsed the XML document for us. We need to * run through the DOM tree, pull out the interesting bits, and make * sure the stuff we need is present. * * Returns "true" on success, "false" on failure. */ bool PhoneData::ProcessAndValidate(TiXmlDocument* pDoc) { bool deviceFound = false; TiXmlNode* pChild; assert(pDoc->Type() == TiXmlNode::DOCUMENT); for (pChild = pDoc->FirstChild(); pChild != NULL; pChild = pChild->NextSibling()) { /* * Find the <device> entry. There should be exactly one. */ if (pChild->Type() == TiXmlNode::ELEMENT) { if (strcasecmp(pChild->Value(), "device") != 0) { fprintf(stderr, "SimCFG: Warning: unexpected element '%s' at top level\n", pChild->Value()); continue; } if (deviceFound) { fprintf(stderr, "SimCFG: one <device> per customer\n"); return false; } bool result = ProcessDevice(pChild); if (!result) return false; deviceFound = true; } } if (!deviceFound) { fprintf(stderr, "SimCFG: no <device> section found\n"); return false; } return true; }
bool CButtonTranslator::Load() { // load our xml file, and fill up our mapping tables TiXmlDocument xmlDoc; // Load the config file CStdString keymapPath; //CUtil::AddFileToFolder(g_settings.GetUserDataFolder(), "Keymap.xml", keymapPath); keymapPath = g_settings.GetUserDataItem("Keymap.xml"); CLog::Log(LOGINFO, "Loading %s", keymapPath.c_str()); if (!xmlDoc.LoadFile(keymapPath)) { g_LoadErrorStr.Format("%s, Line %d\n%s", keymapPath.c_str(), xmlDoc.ErrorRow(), xmlDoc.ErrorDesc()); return false; } translatorMap.clear(); TiXmlElement* pRoot = xmlDoc.RootElement(); CStdString strValue = pRoot->Value(); if ( strValue != "keymap") { g_LoadErrorStr.Format("%sl Doesn't contain <keymap>", keymapPath.c_str()); return false; } // run through our window groups TiXmlNode* pWindow = pRoot->FirstChild(); while (pWindow) { WORD wWindowID = WINDOW_INVALID; const char *szWindow = pWindow->Value(); { if (szWindow) { if (strcmpi(szWindow, "global") == 0) wWindowID = (WORD) -1; else wWindowID = TranslateWindowString(szWindow); } MapWindowActions(pWindow, wWindowID); pWindow = pWindow->NextSibling(); } } #ifdef HAS_LIRC if (!LoadLircMap()) return false; #endif // Done! return true; }
bool WSWorld::init() { m_worldPopulation = 0; if( !loadTerrain( WSApp::instance()->getSetting("/config/WorldCfg")) ) return false; TiXmlDocument doc; CLog::instance()->log(CLog::msgFlagResources, CLog::msgLvlInfo,__FUNCTION__, _("Loading mobs info...")); doc.LoadFile("../data/zones/teeran/mobs.xml"); if (doc.Error()) { CLog::instance()->log(CLog::msgFlagResources, CLog::msgLvlError,__FUNCTION__, _("XML parser returned an error: %s\n"), doc.ErrorDesc()); return false; } TiXmlElement* mobsxml = doc.FirstChildElement("mobs"); CWorldCharMob::setDefaults(mobsxml); TiXmlNode* childNode; for ( childNode = mobsxml->FirstChild(); childNode != 0; childNode = childNode->NextSibling() ) if (childNode->Type() == TiXmlNode::ELEMENT) if (!strcmp(childNode->Value(), "mob")) // { insertEntity(WSEntityPtr(new CWorldCharMob(getNewEntityID(), childNode->ToElement()))); // CharMobPtr mob(new CWorldCharMob(childNode->ToElement())); // insertCharMob(mob); // } else if (!strcmp(childNode->Value(), "flock")) // { insertEntity(WSEntityPtr(new CMobFlock(getNewEntityID(), childNode->ToElement()))); // MobFlockPtr flock(new CMobFlock(childNode->ToElement())); // m_flocks.push_back(flock); // } CLog::instance()->log(CLog::msgFlagResources, CLog::msgLvlInfo,__FUNCTION__, _("WSWorld.init: Done.")); return true; };
//获取状态Bar的离线和在线的背景图 IVS_ULONG CWindowSkinXML::StatusBarGetBackGround(std::string &strOnlinePath,std::string &strOfflinePath) { strOnlinePath.clear(); TiXmlElement * pChildElement = nullptr; CHECK_POINTER(m_pTVwallStatusBarRootElement,IVS_FAIL); //获取Online的背景图片 pChildElement = m_pTVwallStatusBarRootElement->FirstChildElement("Online"); CHECK_POINTER(pChildElement,IVS_FAIL); pChildElement = pChildElement->FirstChildElement("Picture"); CHECK_POINTER(pChildElement,IVS_FAIL); TiXmlNode *pChildNode = nullptr; pChildNode = pChildElement->FirstChild(); CHECK_POINTER(pChildNode,IVS_FAIL); const TCHAR * pc = pChildNode->Value(); (void)strOnlinePath.append(pc); //获取Offline的背景图片 strOfflinePath.clear(); pChildElement = m_pTVwallStatusBarRootElement->FirstChildElement("Offline"); CHECK_POINTER(pChildElement,IVS_FAIL); pChildElement = pChildElement->FirstChildElement("Picture"); CHECK_POINTER(pChildElement,IVS_FAIL); //TiXmlNode *pChildNode = nullptr; pChildNode = pChildElement->FirstChild(); CHECK_POINTER(pChildNode,IVS_FAIL); pc = pChildNode->Value(); (void)strOfflinePath.append(pc); return IVS_SUCCEED; }
//////////////////////////////////////////////////////////////////////////////////// /// /// \brief Loads UDP configuration values from an XML file. Only loads values /// if transport has not been initialized. /// /// \param[in] filename File containing Service settings data. /// /// \return True on success, false on failure. /// //////////////////////////////////////////////////////////////////////////////////// bool AccessControl::LoadSettings(const std::string& filename) { TiXmlDocument xml; if(xml.LoadFile(filename.c_str()) == false) { return false; } TiXmlHandle doc(&xml); TiXmlNode* node; node = doc.FirstChild("JAUS").FirstChild("AccessControl").FirstChild("Controllable").FirstChild().ToNode(); if(node && node->Value()) { mControllableFlag = atoi(node->Value()) > 0 ? true : false; } TiXmlElement* element = NULL; element = doc.FirstChild("JAUS").FirstChild("AccessControl").FirstChild("TimeoutSeconds").ToElement(); if(element && element->FirstChild() && element->FirstChild()->Value()) { mTimeoutPeriod = (Byte)atoi(element->FirstChild()->Value()); if(element->Attribute("threshold")) { mTimeoutThreshold = atof(element->Attribute("threshold")); if(mTimeoutThreshold < 0.5 || mTimeoutThreshold > 50.0) { mTimeoutThreshold = 5; // 5 % } } } node = doc.FirstChild("JAUS").FirstChild("AccessControl").FirstChild("AuthorityLevel").FirstChild().ToNode(); if(node && node->Value()) { mAuthorityCode = (Byte)atoi(node->Value()); } return true; }
void ConfigManager::readXml(const icl_core::String& prefix, TiXmlNode *node, FilePath fp, bool extend_prefix) { icl_core::String node_name(node->Value()); icl_core::String fq_node_name = prefix; if (extend_prefix) { fq_node_name = prefix + "/" + node_name; } TiXmlNode *child = node->IterateChildren(NULL); while (child != 0) { if (child->Type() == TiXmlNode::TINYXML_ELEMENT) { if (strcmp(child->Value(), "INCLUDE") == 0) { TiXmlElement *child_element = dynamic_cast<TiXmlElement*>(child); assert(child_element != NULL); const char *included_file = child_element->GetText(); if (included_file != NULL) { load(fp.path() + included_file); } } else { readXml(fq_node_name, child, fp); } } else if (child->Type() == TiXmlNode::TINYXML_TEXT) { insert(fq_node_name, child->Value()); notify(fq_node_name); } child = node->IterateChildren(child); } }
void XMLEntityMappingDefinitionSerializer::parseActionElement(EntityMappingDefinition& definition, ActionDefinition& actionDef, TiXmlElement* element) { for (TiXmlAttribute* attribute = element->FirstAttribute(); attribute != 0; attribute = attribute->Next()) { actionDef.getProperties()[attribute->Name()] = attribute->Value(); } actionDef.setType(element->Attribute("type" )); TiXmlNode* textNode = element->FirstChild(); if (textNode) { actionDef.setValue(textNode->Value()); } }
// Extracts the content of an XML element that contains only text const char* textValue(TiXmlElement* e) { TiXmlNode* first = e->FirstChild( ); if ( first != 0 && first == e->LastChild( ) && first->Type( ) == TiXmlNode::TEXT ) { // the element e has a single child, of type TEXT; // return the child's return first->Value( ); } else { throw runtime_error(string("bad ") + e->Value( ) + " element"); } }
wxString GetTextElement(TiXmlElement* node, const char* name) { wxASSERT(node); TiXmlElement* element = node->FirstChildElement(name); if (!element) return wxString(); TiXmlNode* textNode = element->FirstChild(); if (!textNode || !textNode->ToText()) return wxString(); return ConvLocal(textNode->Value()); }
void zzzSndSystem::LoadSounds() { //read xml & load sets DataStreamPtr data = ResourceGroupManager::getSingleton().openResource("sounds.xml"); String str = data->getAsString(); TiXmlDocument doc; doc.Parse(str.c_str()); if (!doc.Error()) { TiXmlNode* node; node=doc.FirstChild(); node=node->FirstChild(); for (;node!=0;node=node->NextSibling()) { if (node->Type() == TiXmlNode::ELEMENT) { //get params String name = ""; String file = ""; if (strcmp(node->Value(), "sound") == 0) { TiXmlAttribute* att = node->ToElement()->FirstAttribute(); while (att) { if (strcmp(att->Name(), "name") == 0) { name = att->Value(); } else if (strcmp(att->Name(), "file") == 0) { file = att->Value(); } att = att->Next(); } if (name.length() > 0) { SND->LoadSound(name, file); } } } } } else { throw Exception(Exception::ERR_FILE_NOT_FOUND, std::string(doc.ErrorDesc()) + " : particles.xml", __FUNCTION__); } }
const String& MimeType::comment(void) { // calling without mime loaded do nothing if(!(status & MIME_LOADED)) return mcmt; if(status & COMMENT_LOADED) return mcmt; String ttype = mtype; ttype += ".xml"; const char* p = xdg_mime_find_data(ttype.c_str()); if(!p) return mcmt; String path = p; TiXmlDocument doc(path.c_str()); if(!doc.LoadFile()) { E_DEBUG(E_STRLOC ": MimeType::comment() %s malformed\n", path.c_str()); return mcmt; } TiXmlNode* el = doc.FirstChild("mime-type"); /* * First element which does not have "xml:lang" attribute * is default one. So hunt that one :) * * Btw. TinyXML does not handle XML namespaces and will return * "<namespace>:<attribute>" value. This is not big deal as long * as correctly fetch attribute values. */ for(el = el->FirstChildElement(); el; el = el->NextSibling()) { if(strncmp(el->Value(), "comment", 7) == 0) { // TODO: add locale here if(!el->ToElement()->Attribute("xml:lang")) { TiXmlText* data = el->FirstChild()->ToText(); if(data) { mcmt = data->Value(); break; } } } } status |= COMMENT_LOADED; return mcmt; }
static void mediaDbAddItem(MediaDb* mediaDb, TiXmlElement* dmp, const MediaType& mediaType) { for (TiXmlElement* it = dmp->FirstChildElement(); it != NULL; it = it->NextSiblingElement()) { if (strcmp(it->Value(), "hash") == 0) { const char* type = it->Attribute("algo"); if (type != NULL) { if (strcmp(type, "sha1") == 0) { TiXmlNode* hash = it->FirstChild(); string sha1(hash->Value()); mediaDb->sha1Map[sha1] = new MediaType(mediaType); // if (mediaDb == casdb) printf("Adding: %s: %s\n", mediaType.title.c_str(), sha1.c_str()); } if (strcmp(type, "crc32") == 0) { UInt32 crc32; TiXmlNode* hash = it->FirstChild(); if (sscanf(hash->Value(), "%x", &crc32) == 1) { mediaDb->crcMap[crc32] = new MediaType(mediaType); } } } } } }
TiXmlElement* Gameplay::getConfigElement(const char* name) { TiXmlNode* child = _config->FirstChild(); assert( child ); if( child != NULL ) do { if( child->Type() == TiXmlNode::ELEMENT && strcmp( child->Value(), name ) == 0 ) { return static_cast<TiXmlElement*>( child ); } child = child->NextSibling(); } while( child != NULL ); return NULL; }