当前位置: 首页>>代码示例>>C++>>正文


C++ TiXmlHandle::FirstChildElement方法代码示例

本文整理汇总了C++中TiXmlHandle::FirstChildElement方法的典型用法代码示例。如果您正苦于以下问题:C++ TiXmlHandle::FirstChildElement方法的具体用法?C++ TiXmlHandle::FirstChildElement怎么用?C++ TiXmlHandle::FirstChildElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TiXmlHandle的用法示例。


在下文中一共展示了TiXmlHandle::FirstChildElement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: loadServer

void TinyXmlServerConfigImp::loadServer(TiXmlHandle &serverH){
	TiXmlElement *portE = serverH.FirstChildElement("port").Element();
	if(portE){
		port = atoi(portE->GetText());
	}

	if(port == 0){
		log(Fatal, "config port first");
		exit(-1);
	}

	TiXmlElement *nameE = serverH.FirstChildElement("name").Element();
	if(nameE){
		//null to die;
		name = nameE->GetText();
	}

	TiXmlElement *fportE = serverH.FirstChildElement("front_port").Element();
	while(fportE){
		uint16_t p = atoi(fportE->GetText());
		if(p != 0)
			frontPorts.push_back(p);
		fportE = fportE->NextSiblingElement("front_port");
	}


	TiXmlElement *groupE = serverH.FirstChildElement("group").Element();
	if(groupE){
		groupId = atoi(groupE->GetText());
	}else{
		groupId = 0;
	}
}
开发者ID:NonPlayerCharactor,项目名称:serviceframe,代码行数:33,代码来源:TinyXmlServerConfigImp.cpp

示例2: ReadXml

void Animation::ReadXml(const char* filename)
{
	m_animationParts.clear(); // clear our parts list first

	// create a new xml document 
	XmlDocument doc;
	doc.Load(filename);

	TiXmlHandle * hdoc = doc.Handle();
	TiXmlElement * root = hdoc->FirstChildElement().Element();

	if(root != 0)
	{
		TiXmlElement * child = root->FirstChildElement();

		// loop through children
		while(child)
		{
			// whats the name of this part
			string partName = (string)child->Value();

			// add this part to the part map
			m_animationParts[partName] = new AnimationPart(child);

			// move to the next game object
			child = child->NextSiblingElement();
		}
	}
}
开发者ID:jeromebyrne,项目名称:2DPlatformer,代码行数:29,代码来源:Animation.cpp

示例3: flushNodeSrvs

int MetaConfig::flushNodeSrvs(TiXmlHandle *meta)
{
	std::vector<NodeService> tmp;
	TiXmlHandle srvs = meta->FirstChildElement("services");
	if(srvs.Element()){
		TiXmlHandle srv = srvs.FirstChildElement("service");
		while(srv.Element()){
			NodeService ns;
			loadInt(&srv, "gid", ns.gid, -1);
			loadString(&srv, "name", ns.service, "");
			loadString(&srv, "ip", ns.ip, "");
			loadInt(&srv, "port", ns.port, -1);

			if(!(ns.gid != -1 && !ns.service.empty() && !ns.ip.empty() && ns.port != -1)){
				std::cerr << "load service error name:" << ns.service << " ip:" << ns.ip << " port:" << ns.port << " node:" << ns.gid<< std::endl;
				return -1;
			}

			tmp.push_back(ns);
			srv = srv.Element()->NextSibling("service");
		}
		std::sort(tmp.begin(), tmp.end());
		std::unique(tmp.begin(), tmp.end());
	}
	boost::mutex::scoped_lock lock(mtx);
	ndSrvs.swap(tmp);
	return 0;
}
开发者ID:zhangchuhu,项目名称:s2s,代码行数:28,代码来源:MetaConfig.cpp

示例4: readTag

//---------------------------------------------------------
bool ofXMLSettings::readTag(string  tag, char * valueString, int which){

	vector<string> tokens = tokenize(tag,":");
		
	TiXmlHandle tagHandle = *storedHandle;
	for(int x=0;x<tokens.size();x++){
		if(x == 0)tagHandle = tagHandle.ChildElement(tokens.at(x), which);
		else tagHandle = tagHandle.FirstChildElement( tokens.at(x) );
	}

	// once we've walked, let's get that value...
	TiXmlHandle valHandle = tagHandle.Child( 0 );
    
    //now, clear that vector! 
	tokens.clear();		
	
    // if that value is really text, let's get the value out of it ! 
    if (valHandle.Text()){
    	int maxLen = MIN(MAX_TAG_VALUE_LENGTH_IN_CHARS, strlen(valHandle.Text()->Value()));
    	memcpy(valueString, valHandle.Text()->Value(), maxLen);
    	return true;	
    }  else {
		return false;
	}
}
开发者ID:LeonFedotov,项目名称:L.A.S.E.R.-TAG-GRL,代码行数:26,代码来源:ofXMLSettings.cpp

示例5: writeAttribute

//---------------------------------------------------------
int ofxXmlSettings::writeAttribute(const string& tag, const string& attribute, const string& valueString, int which){
	vector<string> tokens = tokenize(tag,":");
	TiXmlHandle tagHandle = storedHandle;
	for (int x = 0; x < (int)tokens.size(); x++) {
		if (x == 0)
			tagHandle = tagHandle.ChildElement(tokens.at(x), which);
		else
			tagHandle = tagHandle.FirstChildElement(tokens.at(x));
	}

	int ret = 0;
	if (tagHandle.ToElement()) {
		TiXmlElement* elem = tagHandle.ToElement();
		elem->SetAttribute(attribute, valueString);

        // Do we really need this?  We could just ignore this and remove the 'addAttribute' functions...
		// Now, just get the ID.
		int numSameTags;
		TiXmlElement* child = ( storedHandle.FirstChildElement( tokens.at(0) ) ).ToElement();
		for (numSameTags = 0; child; child = child->NextSiblingElement( tokens.at(0) ), ++numSameTags) {
			// nothing
		}
		ret = numSameTags;
	}
	return ret;
}
开发者ID:AnnaKolla,项目名称:openFrameworks,代码行数:27,代码来源:ofxXmlSettings.cpp

示例6: Initialise

void MaterialManager::Initialise(char *materialXMLFile)
{
	// read through the xml file and load all materials
	XmlDocument doc;
	doc.Load(materialXMLFile);

	TiXmlHandle * hdoc = doc.Handle();
	TiXmlElement * root = hdoc->FirstChildElement().Element();

	TiXmlElement * child = root->FirstChildElement();

	// loop through our materials
	while(child)
	{
		// get the name of the material 
		const char * matName = XmlUtilities::ReadAttributeAsString(child, "", "name");
		
		// create the new material
		Material* mat = new Material(matName);
		mat->ReadXml(child); // read the properties

		m_materialMap[matName] = mat; // add to the material map

		// move to the next material
		child = child->NextSiblingElement();
	}
}
开发者ID:jeromebyrne,项目名称:2DPlatformer,代码行数:27,代码来源:MaterialManager.cpp

示例7: getElementForAttribute

//---------------------------------------------------------
TiXmlElement* ofxXmlSettings::getElementForAttribute(const string& tag, int which){
	vector<string> tokens = tokenize(tag,":");
	TiXmlHandle tagHandle = storedHandle;
	for (int x = 0; x < (int)tokens.size(); x++) {
		if (x == 0)
			tagHandle = tagHandle.ChildElement(tokens.at(x), which);
		else
			tagHandle = tagHandle.FirstChildElement(tokens.at(x));
	}
    return tagHandle.ToElement();
}
开发者ID:AnnaKolla,项目名称:openFrameworks,代码行数:12,代码来源:ofxXmlSettings.cpp

示例8: if

bool CppCheck::DoCppCheckParseXMLv2(TiXmlHandle& Handle)
{
    bool ErrorsPresent = false;

    const TiXmlHandle& Errors = Handle.FirstChildElement("errors");

    for (const TiXmlElement* Error = Errors.FirstChildElement("error").ToElement();
                             Error;
                             Error = Error->NextSiblingElement("error"))
    {
        wxString Id;
        if (const char* IdValue = Error->Attribute("id"))
            Id = wxString::FromAscii(IdValue);
        wxString Severity;
        if (const char* SeverityValue = Error->Attribute("severity"))
            Severity = wxString::FromAscii(SeverityValue);
        wxString Message;
        if (const char* MessageValue = Error->Attribute("msg"))
            Message = wxString::FromAscii(MessageValue);
        wxString CWE;
        if (const char* CWEValue = Error->Attribute("cwe"))
            CWE = wxString::FromAscii(CWEValue);
        wxString Verbose;
        if (const char* VerboseValue = Error->Attribute("verbose"))
            Verbose = wxString::FromAscii(VerboseValue);
        const wxString FullMessage = Id + _T(" : ") + Severity + _T(" : ") + Verbose;

        wxString File;
        wxString Line;
        const TiXmlElement* Location = Error->FirstChildElement("location");
        if (nullptr!=Location)
        {
            if (const char* FileValue = Location->Attribute("file"))
                File = wxString::FromAscii(FileValue);
            if (const char* LineValue = Location->Attribute("line"))
                Line = wxString::FromAscii(LineValue);
        }

        if (!FullMessage.IsEmpty() && !File.IsEmpty() && !Line.IsEmpty())
        {
            wxArrayString Arr;
            Arr.Add(File);
            Arr.Add(Line);
            Arr.Add(FullMessage);
            m_ListLog->Append(Arr);
            ErrorsPresent = true;
        }
        else if (!Message.IsEmpty())
            AppendToLog(Message); // might be something important like config not found...
    }

    return ErrorsPresent;
}
开发者ID:jenslody,项目名称:codeblocks,代码行数:53,代码来源:CppCheck.cpp

示例9: readTag

//---------------------------------------------------------
bool ofxXmlSettings::readTag(const string&  tag, TiXmlHandle& valHandle, int which){

	vector<string> tokens = tokenize(tag,":");

	TiXmlHandle tagHandle = storedHandle;
	for(int x=0;x<(int)tokens.size();x++){
		if(x == 0)tagHandle = tagHandle.ChildElement(tokens.at(x), which);
		else tagHandle = tagHandle.FirstChildElement( tokens.at(x) );
	}

	// once we've walked, let's get that value...
	valHandle = tagHandle.Child( 0 );
    return (valHandle.ToText() != NULL);
}
开发者ID:AnnaKolla,项目名称:openFrameworks,代码行数:15,代码来源:ofxXmlSettings.cpp

示例10: LoadLocations

bool Recordings::LoadLocations()
{
  std::string url;
  if (Settings::GetInstance().GetRecordingsFromCurrentLocationOnly())
    url = StringUtils::Format("%s%s",  Settings::GetInstance().GetConnectionURL().c_str(), "web/getcurrlocation");
  else
    url = StringUtils::Format("%s%s",  Settings::GetInstance().GetConnectionURL().c_str(), "web/getlocations");

  const std::string strXML = WebUtils::GetHttpXML(url);

  TiXmlDocument xmlDoc;
  if (!xmlDoc.Parse(strXML.c_str()))
  {
    Logger::Log(LEVEL_ERROR, "%s Unable to parse XML: %s at line %d", __FUNCTION__, xmlDoc.ErrorDesc(), xmlDoc.ErrorRow());
    return false;
  }

  TiXmlHandle hDoc(&xmlDoc);

  TiXmlElement* pElem = hDoc.FirstChildElement("e2locations").Element();

  if (!pElem)
  {
    Logger::Log(LEVEL_ERROR, "%s Could not find <e2locations> element", __FUNCTION__);
    return false;
  }

  TiXmlHandle hRoot = TiXmlHandle(pElem);

  TiXmlElement* pNode = hRoot.FirstChildElement("e2location").Element();

  if (!pNode)
  {
    Logger::Log(LEVEL_ERROR, "%s Could not find <e2location> element", __FUNCTION__);
    return false;
  }

  for (; pNode != nullptr; pNode = pNode->NextSiblingElement("e2location"))
  {
    const std::string strTmp = pNode->GetText();

    m_locations.emplace_back(strTmp);

    Logger::Log(LEVEL_DEBUG, "%s Added '%s' as a recording location", __FUNCTION__, strTmp.c_str());
  }

  Logger::Log(LEVEL_INFO, "%s Loaded '%d' recording locations", __FUNCTION__, m_locations.size());

  return true;
}
开发者ID:ksooo,项目名称:pvr.vuplus,代码行数:50,代码来源:Recordings.cpp

示例11: removeAttribute

//---------------------------------------------------------
void ofxXmlSettings::removeAttribute(const string& tag, const string& attribute, int which){
	vector<string> tokens = tokenize(tag,":");
	TiXmlHandle tagHandle = storedHandle;
	for (int x = 0; x < (int)tokens.size(); x++) {
		if (x == 0)
			tagHandle = tagHandle.ChildElement(tokens.at(x), which);
		else
			tagHandle = tagHandle.FirstChildElement(tokens.at(x));
	}

	if (tagHandle.ToElement()) {
		TiXmlElement* elem = tagHandle.ToElement();
		elem->RemoveAttribute(attribute);
	}
}
开发者ID:AnnaKolla,项目名称:openFrameworks,代码行数:16,代码来源:ofxXmlSettings.cpp

示例12: DoInitWizard

bool wxTreeMultiXmlMapper::DoInitWizard(const wxString &start_tag)
{
    bool allok = false;
    
    // clean up the control first
    m_ctrl->DeleteAllItems();

    // reset the ID counter
    m_currentId = XMLMAP_BASE_ID;
    
    // obtain handle to document
    TiXmlHandle h(m_tiDoc);
    
    // find our first wizard declaration
    TiXmlHandle wizard = h.FirstChildElement(start_tag.c_str());

    // we expect it to be an element, and we should go from there with
    // parsing categories and other stuff..

    if(wizard.Element())
    {
        // we skip all and look for the first category element
        TiXmlElement *cat = wizard.FirstChildElement(XMLMAP_TAG_CATEGORY).Element();

        // go through the loop of creating all categories
        allok = (cat != 0);
        while(cat && allok)
        {
            // ok create a category root name, but only when we 
            // have a name to give it
            if(cat->Attribute(XMLMAP_ATTR_CAPTION))
            {
                wxTreeMultiItem item = AddCategory(cat, wxTreeMultiItem(0));
                allok = DoCreateControls(cat, item, 0, 0);
            }
            
            // find a next one
            if(allok)
                cat = cat->NextSiblingElement(XMLMAP_TAG_CATEGORY);
        }
    }

    return allok;
}
开发者ID:mp-lee,项目名称:wxdevcpp,代码行数:44,代码来源:TreeMultiXmlMapper.cpp

示例13: getAttributeNames

//---------------------------------------------------------
bool ofxXmlSettings::getAttributeNames(const string& tag, vector<string>& outNames, int which){
	vector<string> tokens = tokenize(tag,":");
	TiXmlHandle tagHandle = storedHandle;
	for (int x = 0; x < (int)tokens.size(); x++) {
		if (x == 0)
			tagHandle = tagHandle.ChildElement(tokens.at(x), which);
		else
			tagHandle = tagHandle.FirstChildElement(tokens.at(x));
	}

	if (tagHandle.ToElement()) {
		TiXmlElement* elem = tagHandle.ToElement();

		// Do stuff with the element here
		for (TiXmlAttribute* a = elem->FirstAttribute(); a; a = a->Next())
			outNames.push_back( string(a->Name()) );
	}
	return !outNames.empty();
}
开发者ID:AnnaKolla,项目名称:openFrameworks,代码行数:20,代码来源:ofxXmlSettings.cpp

示例14: attributeExists

//---------------------------------------------------------
bool ofxXmlSettings::attributeExists(const string& tag, const string& attribute, int which){
	vector<string> tokens = tokenize(tag,":");
	TiXmlHandle tagHandle = storedHandle;
	for (int x = 0; x < (int)tokens.size(); x++) {
		if (x == 0)
			tagHandle = tagHandle.ChildElement(tokens.at(x), which);
		else
			tagHandle = tagHandle.FirstChildElement(tokens.at(x));
	}

	if (tagHandle.ToElement()) {
		TiXmlElement* elem = tagHandle.ToElement();

		// Do stuff with the element here
		for (TiXmlAttribute* a = elem->FirstAttribute(); a; a = a->Next()) {
			if (a->Name() == attribute)
				return true;
		}
	}
	return false;
}
开发者ID:AnnaKolla,项目名称:openFrameworks,代码行数:22,代码来源:ofxXmlSettings.cpp

示例15: load

void TinyXmlServerConfigImp::load(FILE *fp){
	loaded = true;
	TiXmlDocument doc;
	doc.LoadFile(fp);

	TiXmlHandle docH( &doc );
	TiXmlHandle servers = docH.FirstChildElement( "conf" ).FirstChildElement( "servers" );
	if(servers.Element()){
		
		TiXmlHandle server = servers.FirstChildElement(serverElem.data());
		if(server.Element()){
			loadServer(server);
		}else{
			log(Fatal, "%s config not found", serverElem.data());
			exit(-1);
		}
	}else{
		log(Error, "servers element is NULL");
	}

	forEachWatcher0(&IServerConfigWatcher::onConfigRefresh);
}
开发者ID:NonPlayerCharactor,项目名称:serviceframe,代码行数:22,代码来源:TinyXmlServerConfigImp.cpp


注:本文中的TiXmlHandle::FirstChildElement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。