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


C++ TiXmlHandle类代码示例

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


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

示例1: pushTag

//---------------------------------------------------------
bool ofxXmlSettings::pushTag(string  tag, int which){

	int pos = tag.find(":");

	if(pos > 0){
		tag = tag.substr(0,pos);
	}

	//we only allow to push one tag at a time.
	TiXmlHandle isRealHandle = storedHandle->ChildElement(tag, which);

	if( isRealHandle.Node() ){
		*storedHandle = isRealHandle;
		level++;
		return true;
	}else{
		printf("pushTag - tag not found\n");
	}

	return false;
}
开发者ID:Ahmedn1,项目名称:ccv-hand,代码行数:22,代码来源:ofxXmlSettings.cpp

示例2: tokenize

//---------------------------------------------------------
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:m9dfukc,项目名称:Motion-Sensing-Toolkit,代码行数:22,代码来源:ofxXmlSettings.cpp

示例3: tokenize

//---------------------------------------------------------
void ofXMLSettings::removeTag(string  tag, int which){
	
	vector<string> tokens = tokenize(tag,":");
	
	//no tags so we return
	if( tokens.size() == 0 ) return;
		
	//grab the handle from the level we are at
	//normally this is the doc but could be a pushed node
	TiXmlHandle tagHandle = *storedHandle;
	
	if(which < 0) which = 0;
	
	for(int x=0;x<tokens.size();x++){
	
		//we only support multi tags
		//with same name at root level
		if(x > 0) which = 0;
			
		TiXmlHandle isRealHandle = tagHandle.ChildElement( tokens.at(x), which);
		
		if ( !isRealHandle.Node() ) break;
		else{
			if (x == tokens.size()-1){
				//if we are at the last tag and it exists 
				//we use its parent to remove it - haha
				tagHandle.ToNode()->RemoveChild( isRealHandle.ToNode() );
			}
			tagHandle = isRealHandle;
		}
	}
	
	tokens.clear();
}
开发者ID:LeonFedotov,项目名称:L.A.S.E.R.-TAG-GRL,代码行数:35,代码来源:ofXMLSettings.cpp

示例4: root

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;
}
开发者ID:ConstantinV,项目名称:Mauve-Analysis,代码行数:45,代码来源:outputfile.cpp

示例5: 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

示例6: docH

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

示例7: userCheck

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++;
	}
    }
开发者ID:nt-complete,项目名称:twitSpam,代码行数:22,代码来源:ptTwitSpam.cpp

示例8: tagToFind

//---------------------------------------------------------
bool ofxXmlSettings::pushTag(const string&  tag, int which){

	int pos = tag.find(":");

    // Either find the tag specified, or the first tag if colon-seperated.
    string tagToFind((pos > 0) ? tag.substr(0,pos) :tag);
    
	//we only allow to push one tag at a time.
	TiXmlHandle isRealHandle = storedHandle.ChildElement(tagToFind, which);

	if( isRealHandle.ToNode() ){
		storedHandle = isRealHandle;
		level++;
		return true;
	}else{
		printf("pushTag - <");
		printf("%s",tag.c_str());
		printf("> tag not found\n");
	}

	return false;
}
开发者ID:AinurBegalinova,项目名称:TreasureHuntingRobot,代码行数:23,代码来源:ofxXmlSettings.cpp

示例9: statusCheck

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;
}
开发者ID:nt-complete,项目名称:twitSpam,代码行数:14,代码来源:ptTwitSpam.cpp

示例10: initFromXML

void PointLumiere::initFromXML(TiXmlHandle hObj){
	double x,y,z;
	TiXmlElement* pElem=hObj.Element();
	Lumiere::initFromXML(hObj);
	pElem->QueryDoubleAttribute("x", &x);
	pElem->QueryDoubleAttribute("y", &y);
	pElem->QueryDoubleAttribute("z", &z);

	this->position.Set(x,y,z);
	this->falloff[0]=1.0;
	this->falloff[1]=0.0;
	this->falloff[2]=0.0;

}
开发者ID:etchevery,项目名称:MonteCarlo,代码行数:14,代码来源:PointLumiere.cpp

示例11: in

    bool TinyDemarshaller::deserialize( PropertyBag &v )
    {
        Logger::In in("TinyDemarshaller");

        if ( !d->loadOkay )
            return false;

		TiXmlHandle docHandle( &d->doc );
		TiXmlHandle propHandle = docHandle.FirstChildElement( "properties" );

        if ( ! propHandle.Node() ) {
            log(Error) << "No <properties> element found in document!"<< endlog();
            return false;
        }

        detail::Tiny2CPFHandler proc( v );

        if ( proc.populateBag( propHandle.Node() ) == false) {
            deleteProperties( v );
            return false;
        }
        return true;
    }
开发者ID:jsreng,项目名称:orocos-rtt,代码行数:23,代码来源:TinyDemarshaller.cpp

示例12: LoadGangXML

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;
}
开发者ID:EnterTheNameHere,项目名称:WhoreMasterRenewal,代码行数:37,代码来源:cGangs.cpp

示例13: LoadStatsXML

bool LoadStatsXML(TiXmlHandle hStats, int stats[], int statMods[], int tempStats[])
{
	TiXmlElement* pStats = hStats.ToElement();
	if (pStats == 0) return false;

	for (int i = 0; i < NUM_STATS; i++)
	{
		TiXmlElement* pStat = pStats->FirstChildElement(XMLifyString(sGirl::stat_names[i]));
		if (pStat)
		{
			int tempInt = 0;
			if (pStat->Attribute("Value"))	pStat->QueryIntAttribute("Value", &tempInt);

			int min = 0, max = 100;
			switch (i)
			{
			case STAT_AGE:
				if (tempInt > 99)		tempInt = 100;
				else if (tempInt > 80)		tempInt = 80;
				else if (tempInt < 18)		tempInt = 18;	// `J` Legal Note: 18 is the Legal Age of Majority for the USA where I live 
				break;
			case STAT_EXP:		max = 32000;	break;
			case STAT_LEVEL:	max = 255;		break;
			case STAT_PCFEAR:		case STAT_PCHATE:	case STAT_PCLOVE:	case STAT_MORALITY:
			case STAT_REFINEMENT:	case STAT_DIGNITY:	case STAT_LACTATION:
				min = -100;		break;
			default:	break;
			}
			if (tempInt < -1000)	tempInt = -1;	// test for null stats and set them to 0
			if (tempInt > max) tempInt = max;
			else if (tempInt < min) tempInt = min;
			stats[i] = tempInt;

			if (statMods)
			{
				tempInt = 0;
				if (pStat->Attribute("Mod"))	pStat->QueryIntAttribute("Mod", &tempInt);
				statMods[i] = tempInt;
			}
			if (tempStats)
			{
				tempInt = 0;
				if (pStat->Attribute("Temp"))	pStat->QueryIntAttribute("Temp", &tempInt);
				tempStats[i] = tempInt;
			}
		}
	}
	return true;
}
开发者ID:mjsmagalhaes,项目名称:crazys-wm-mod,代码行数:49,代码来源:XmlMisc.cpp

示例14: fopen

int MetaConfig::reload()
{
	
	FILE *fp = fopen(fname.c_str(), "r");
	if(!fp){
		log(Warn, "reload file %s error", fname.c_str());
		return -1;
	}

	TiXmlDocument doc;
	doc.LoadFile(fp);

	TiXmlHandle docH( &doc );
	TiXmlHandle meta = docH.FirstChildElement( "conf" ).FirstChildElement( "servers" ).FirstChildElement("meta");
	if(meta.Element()){
		loadBool(&meta, "sync", bsync, false);
		TiXmlHandle daemon = meta.FirstChildElement("daemon");
		int ret = flushNodeSrvs(&daemon);
		return ret;
	}else{
		fclose(fp);
		return -1;
	}
}
开发者ID:zhangchuhu,项目名称:s2s,代码行数:24,代码来源:MetaConfig.cpp

示例15: tokenize

//---------------------------------------------------------
int ofxXmlSettings::getNumAttributes(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));
	}

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

		// Do stuff with the element here
		TiXmlAttribute* first = elem->FirstAttribute();
		if (first) {
			int count = 1;
			for (TiXmlAttribute* curr = first; curr != elem->LastAttribute(); curr = curr->Next())
				count++;
			return count;
		}
	}
	return 0;
}
开发者ID:AnnaKolla,项目名称:openFrameworks,代码行数:25,代码来源:ofxXmlSettings.cpp


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