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


C++ TiXmlElement::QueryStringAttribute方法代码示例

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


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

示例1: extractWalls

void MapLoader::extractWalls() {
  TiXmlElement *textureElement = rootHandle.FirstChild("texture").ToElement();
  string texturePath("none");
  string surfaceType("none");

  if (textureElement) {
    do {
      textureElement->QueryStringAttribute("source", &texturePath);
      textureElement->QueryStringAttribute("type", &surfaceType);
      TiXmlElement *wallBoxElement = textureElement->FirstChildElement("wall");

      if (wallBoxElement) {
        do {
          scene->walls.emplace_back();
          PhysicsEntity &wall = scene->walls.back();
          
          XmlHelper::extractPosition(wallBoxElement, wall.position);
          XmlHelper::extractRotation(wallBoxElement, wall.rotation);
          XmlHelper::extractScale(wallBoxElement, wall.scale);

          wall.texture = TextureLoader::getTexture(texturePath);
          wall.texture.xTiling = 0.5f;
          wall.texture.yTiling = 0.5f;
          wall.mesh = MeshLoader::getPortalBox(wall);
          wall.physBody = BoxCollider::generateCage(wall);
        } while ((wallBoxElement = wallBoxElement->NextSiblingElement("wall")) != nullptr);
      }

      texturePath = "none";
    } while ((textureElement = textureElement->NextSiblingElement("texture")) != nullptr);
  }
}
开发者ID:JulianThijssen,项目名称:glPortal,代码行数:32,代码来源:MapLoader.cpp

示例2: runtime_error

OSMNode::OSMNode(TiXmlElement *element) :
  id(0),
  x(0),
  y(0),
  x_string(0),
  y_string(0)
{
   if (element->Value() != std::string("node"))
   {
      std::cerr << "Unexpected '" << element->Value() << "' XML node, expected 'node'" << std::endl;
      throw std::runtime_error("wrong node");
   }
   
   std::string id_string;
   
   element->QueryStringAttribute("id", &id_string);
   
   std::stringstream ss;
   
   ss << id_string;
   ss >> id;
   
   element->QueryDoubleAttribute("lat", &y);
   element->QueryDoubleAttribute("lon", &x);
   
   std::string lx_string, ly_string;
   element->QueryStringAttribute("lat", &ly_string);
   element->QueryStringAttribute("lon", &lx_string);
   
   element->QueryStringAttribute("timestamp", &timestamp);
   element->QueryStringAttribute("uid",       &uid);
   element->QueryStringAttribute("user",      &user);
   element->QueryStringAttribute("version",   &version);
   element->QueryStringAttribute("changeset", &changeset);
   
   x_string = new std::string(lx_string);
   y_string = new std::string(ly_string);
   
   //std::cout << "id: " << id << " lat_precision: " << y_string.size()-1 << std::endl;
   //std::cout << "id: " << m_id  << " x: " <<x << " y: " << y << std::endl;
   
   TiXmlHandle refH(element);
   TiXmlElement *ref = refH.FirstChild().Element();
   
   for (; ref; ref=ref->NextSiblingElement())
   {   
      if (ref->Value() == std::string("tag"))
      {
         std::string key, value;
         ref->QueryStringAttribute("k", &key);
         ref->QueryStringAttribute("v", &value);      
         
         if (!key.empty() && !value.empty())
         {
            //std::cout << "Reading key: " << key << " value: " << value << std::endl;
           tags[key] = value;
         }
      }
   }
}
开发者ID:jecor,项目名称:bati-fusion,代码行数:60,代码来源:OSMNode.cpp

示例3: extractButtons

void MapLoader::extractButtons() {
  TiXmlElement *textureElement = rootHandle.FirstChild("texture").ToElement();
  string texturePath("none");
  string surfaceType("none");
  Vector2f position;
  Vector2f size;

  if (textureElement) {
    do {
      textureElement->QueryStringAttribute("source", &texturePath);
      textureElement->QueryStringAttribute("type", &surfaceType);
      TiXmlElement *buttonElement = textureElement->FirstChildElement("GUIbutton");

      if (buttonElement) {
        do {
          scene->buttons.emplace_back();
          GUIButton &button = scene->buttons.back();

          buttonElement->QueryFloatAttribute("x", &position.x);
          buttonElement->QueryFloatAttribute("y", &position.y);

          buttonElement->QueryFloatAttribute("w", &size.x);
          buttonElement->QueryFloatAttribute("h", &size.y);

          button.texture = TextureLoader::getTexture(texturePath);
          button.texture.xTiling = 0.5f;
          button.texture.yTiling = 0.5f;
        } while ((buttonElement = buttonElement->NextSiblingElement("GUIbutton")) != nullptr);
      }

      texturePath = "none";
    } while ((textureElement = textureElement->NextSiblingElement("texture")) != nullptr);
  }
}
开发者ID:JulianThijssen,项目名称:glPortal,代码行数:34,代码来源:MapLoader.cpp

示例4: read

	bool SVG::read( const char* data ) {
        
		TiXmlDocument doc;
		doc.Parse( data );
        
        if (doc.Error()) {
            return false;
        }
		
		TiXmlElement* root = doc.FirstChild( "svg" )->ToElement();
		recursive_parse( root );        
        
        // get bounds information from the svg file, ignoring non-pixel values
        
        string numberWithUnitString;
        regex numberWithUnitPattern( "^(-?\\d+)(px)?$" );
        
        _handler->_minX = 0.0f;
        if ( root->QueryStringAttribute( "x", &numberWithUnitString ) == TIXML_SUCCESS ) {
            match_results<string::const_iterator> matches;
            if ( regex_search( numberWithUnitString, matches, numberWithUnitPattern ) ) {
                _handler->_minX = ::atof( matches[1].str().c_str() );
            }
        }
        
        _handler->_minY = 0.0f;
        if ( root->QueryStringAttribute( "y", &numberWithUnitString ) == TIXML_SUCCESS ) {
            match_results<string::const_iterator> matches;
            if ( regex_search( numberWithUnitString, matches, numberWithUnitPattern ) ) {
                _handler->_minY = ::atof( matches[1].str().c_str() );
            }
        }
        
        _handler->_width = 0.0f;
        if ( root->QueryStringAttribute( "width", &numberWithUnitString ) == TIXML_SUCCESS ) {
            match_results<string::const_iterator> matches;
            if ( regex_search( numberWithUnitString, matches, numberWithUnitPattern ) ) {
                _handler->_width = ::atof( matches[1].str().c_str() );
            }
        }
        
        _handler->_height = 0.0f;
        if ( root->QueryStringAttribute( "height", &numberWithUnitString ) == TIXML_SUCCESS ) {
            match_results<string::const_iterator> matches;
            if ( regex_search( numberWithUnitString, matches, numberWithUnitPattern ) ) {
                _handler->_height = ::atof( matches[1].str().c_str() );
            }
        }
		
		return true;
		
	}
开发者ID:lukelutman,项目名称:MonkSVG,代码行数:52,代码来源:mkSVG.cpp

示例5: extractTriggers

void MapLoader::extractTriggers() {
  TiXmlElement *triggerElement = rootHandle.FirstChild("trigger").ToElement();
  string triggerType("none");

  if (triggerElement) {
    do {
      TiXmlElement *triggerTypeElement;

      scene->triggers.emplace_back();
      Trigger &trigger = scene->triggers.back();

      if (triggerElement) {
        triggerElement->QueryStringAttribute("type", &trigger.type);
      }
      
      if (triggerType == "none") {
        throw std::runtime_error("Trigger must define a type attribute.");
      }

      XmlHelper::extractPosition(triggerElement, trigger.position);
      XmlHelper::extractScale(triggerElement, trigger.scale);

    } while ((triggerElement = triggerElement->NextSiblingElement()) != nullptr);
  }
}
开发者ID:JulianThijssen,项目名称:glPortal,代码行数:25,代码来源:MapLoader.cpp

示例6: importTemplate

void Graphe::importTemplate(QString & filename){

    TiXmlDocument doc(filename.toStdString());
    if(doc.LoadFile()){
        //TiXmlHandle hDoc(&doc);
        TiXmlElement * pRoot;
        TiXmlElement * pChildren;
        std::string temps;
        TiXmlElement * pGraph;
        pGraph = doc.FirstChildElement("Graph");
        if(pGraph){
            pRoot = pGraph->FirstChildElement("Nodes");
            int i, x, y;
            if(pRoot){
                pChildren = pRoot->FirstChildElement("Node");
                while(pChildren){
                    pChildren->QueryIntAttribute("id", &i);
                    if(i<n){
                        pChildren->QueryIntAttribute("x", &x);
                        pChildren->QueryIntAttribute("y", &y);
                        noeuds[i]= Noeud(x,y);
                        //qDebug()<<i;
                        if(pChildren->QueryStringAttribute("Label", &temps) == TIXML_SUCCESS){
                            //qDebug()<<QString(temps.c_str());
                            labels[i]= QString(temps.c_str());

                        }
                    }
                    pChildren = pChildren->NextSiblingElement("Node");
                }
            }
        }
    }
}
开发者ID:dtbinh,项目名称:qdirweigraph,代码行数:34,代码来源:graphe.cpp

示例7: getAttribute

std::string Loader::getAttribute(const TiXmlElement &element, const std::string &attribute) const
{
  std::string value = "";
  if (element.QueryStringAttribute(attribute.c_str(), &value) != TIXML_SUCCESS) {
    throw std::invalid_argument("attribute " + attribute + " not defined");
  }
  return value;
}
开发者ID:ursfassler,项目名称:evdraw,代码行数:8,代码来源:XmlReader.cpp

示例8: loadVector

Vector ParticleComponentLoader::loadVector(const TiXmlElement& xmlElement, const char* pname)
{
   Vector result;
   std::string value;
   if ( xmlElement.QueryStringAttribute(pname, &value) == TIXML_SUCCESS )
   {
      result = parseVector(value);
   }

   return result;
}
开发者ID:crafter2d,项目名称:crafter2d,代码行数:11,代码来源:particlecomponentloader.cpp

示例9: extractModels

void MapLoader::extractModels() {
  Vector3f modelPos;
  string texture("none");
  string mesh("none");
  TiXmlElement *modelElement = rootHandle.FirstChild("model").ToElement();
  if (modelElement){
    do {
      modelElement->QueryStringAttribute("texture", &texture);
      modelElement->QueryStringAttribute("mesh", &mesh);
      XmlHelper::pushAttributeVertexToVector(modelElement, modelPos);

      scene->models.emplace_back();
      VisualEntity &model = scene->models.back();
      XmlHelper::extractPosition(modelElement, model.position);
      XmlHelper::extractRotation(modelElement, model.rotation);
      model.texture = TextureLoader::getTexture(texture);
      model.mesh = MeshLoader::getMesh(mesh);
    } while ((modelElement = modelElement->NextSiblingElement("model")) != nullptr);
  }
}
开发者ID:JulianThijssen,项目名称:glPortal,代码行数:20,代码来源:MapLoader.cpp

示例10:

std::unique_ptr<ISkill> DamageSkillLoader::mt_Load_Element(const TiXmlElement& element)
{
	std::unique_ptr<ISkill> l_ret(nullptr);
	std::string l_skill_name, l_tmp;
	int l_skill_damages;
	DamageSkill::DamageSkillOperator l_skill_operator;

	/** name **/
	element.QueryStringAttribute("name", &l_skill_name);

	/** damages **/
	element.QueryIntAttribute("damages", &l_skill_damages);

	/** operator **/
	element.QueryStringAttribute("operator", &l_tmp);
	l_skill_operator = DamageSkill::mt_String_To_Operator(l_tmp);

	/** new object **/
	//if (l_fn_returned == TIXML_SUCCESS) l_ret = new DamageSkill(l_skill_name, l_skill_damages, l_skill_operator);

	return l_ret;
}
开发者ID:Tigole,项目名称:rpg_engine,代码行数:22,代码来源:DamageSkillLoader.cpp

示例11: load

void playlist::load(std::string filename)
{
	music.clear();

	if (access(filename.c_str(), F_OK)==-1) {
		printf("No playlist found(%s).  No music will played.\n",
			filename.c_str());
		return;
	}

	TiXmlDocument doc(filename.c_str());
	doc.LoadFile();

	TiXmlHandle hDoc(&doc);
	TiXmlElement* pElem;
	TiXmlHandle hRoot(0);

	pElem=hDoc.FirstChildElement().Element();
	// should always have a valid root but handle gracefully if it doesn't
	if (!pElem) {
		printf("Error opening: %s.  No music will played.\n", filename.c_str());
		return;
	}
//	printf("name: %s\n", pElem->Value());
	hRoot=TiXmlHandle(pElem);
	TiXmlElement * songs = hRoot.FirstChild().Element();

	for (; songs!=NULL; songs=songs->NextSiblingElement()) {
		const char *pKey=songs->Value();
		const char *pText=songs->GetText();

		if (!pKey || !pText)
			continue;
//	printf("loop: %s %s\n", pKey, pText);

		std::string file = pText;
		std::string disp;
//	songs->QueryStringAttribute("display", &disp);
		if (songs->QueryStringAttribute("display", &disp)!= TIXML_SUCCESS)
			disp = file;
//	printf("%s: %s\n", disp.c_str(), file.c_str());
		if (access(file.c_str(), F_OK)==-1) {
			//no file found
		}
		else {
			music.push_back(std::make_pair(disp, file));
		}
	}


}
开发者ID:zurn,项目名称:Zakes,代码行数:51,代码来源:playlist.cpp

示例12:

RobotInterface::ParamList RobotInterface::XMLReader::Private::readParamListTag(TiXmlElement* paramListElem)
{
    if (paramListElem->ValueStr().compare("paramlist") != 0) {
        SYNTAX_ERROR(paramListElem->Row()) << "Expected \"paramlist\". Found" << paramListElem->ValueStr();
    }

    ParamList params;
    Param mainparam;

    if (paramListElem->QueryStringAttribute("name", &mainparam.name()) != TIXML_SUCCESS) {
        SYNTAX_ERROR(paramListElem->Row()) << "\"paramlist\" element should contain the \"name\" attribute";
    }

    params.push_back(mainparam);

    // yDebug() << "Found paramlist [" << params.at(0).name() << "]";

    for (TiXmlElement* childElem = paramListElem->FirstChildElement(); childElem != 0; childElem = childElem->NextSiblingElement()) {
        if (childElem->ValueStr().compare("elem") != 0) {
            SYNTAX_ERROR(childElem->Row()) << "Expected \"elem\". Found" << childElem->ValueStr();
        }

        Param childParam;

        if (childElem->QueryStringAttribute("name", &childParam.name()) != TIXML_SUCCESS) {
            SYNTAX_ERROR(childElem->Row()) << "\"elem\" element should contain the \"name\" attribute";
        }

        const char *valueText = childElem->GetText();
        if (!valueText) {
            SYNTAX_ERROR(childElem->Row()) << "\"elem\" element should have a value [ \"name\" = " << childParam.name() << "]";
        }
        childParam.value() = valueText;

        params.push_back(childParam);
    }

    if (params.empty()) {
        SYNTAX_ERROR(paramListElem->Row()) << "\"paramlist\" cannot be empty";
    }

    // +1 skips the first element, that is the main param
    for (ParamList::iterator it = params.begin() + 1; it != params.end(); ++it) {
        Param &param = *it;
        params.at(0).value() += (params.at(0).value().empty() ? "(" : " ") + param.name();
    }
    params.at(0).value() += ")";

    // yDebug() << params;
    return params;
}
开发者ID:AbuMussabRaja,项目名称:icub-main,代码行数:51,代码来源:XMLReader.cpp

示例13: loadCache

void HierClassifier::loadCache(boost::filesystem::path file){
	cout << "Loading cache from file " << file.string() << endl;
	TiXmlDocument doc(file.c_str());
	if(!doc.LoadFile()){
		cout << "Could not load cache file" << endl;
		throw "Could not load cache file";
	}
	TiXmlElement* pWeakClassifiers = doc.FirstChildElement("weak_classifiers");
	if(!pWeakClassifiers){
		throw "Bad cache file - no weak_classifiers";
	}
	int numClassifiers;
	pWeakClassifiers->QueryIntAttribute("num", &numClassifiers);
	pWeakClassifiers->QueryIntAttribute("num_labels", &numLabels);
	TiXmlElement* pClassifier = pWeakClassifiers->FirstChildElement("classifier");
	while(pClassifier){
		string cacheFile;
		double weight;
		WeakClassifierInfo info;
		string classifierType;
		pClassifier->QueryStringAttribute("type", &classifierType);
		pClassifier->QueryStringAttribute("cache_file", &cacheFile);
		pClassifier->QueryDoubleAttribute("weight", &weight);
		pClassifier->QueryIntAttribute("desc_beg", &(info.descBeg));
		pClassifier->QueryIntAttribute("desc_end", &(info.descEnd));
		weights.push_back(weight);
		classifiersInfo.push_back(info);
		if(classifierType == "SVM"){
			classifiers.push_back(new ClassifierSVM());
		}
		else if(classifierType == "RF"){
			classifiers.push_back(new ClassifierRF());
		}
		classifiers.back()->loadCache(pClassifier, cacheFile);

		pClassifier = pClassifier->NextSiblingElement("classifier");
	}
}
开发者ID:jakub-tomczak,项目名称:TAPAS,代码行数:38,代码来源:HierClassifier.cpp

示例14: handle

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);
	}
}
开发者ID:monthero,项目名称:nau,代码行数:23,代码来源:stateLoader.cpp

示例15: read

	bool SVG::read( const char* data ) {
        
		TiXmlDocument doc;
		doc.Parse( data );
        
        if (doc.Error()) {
            return false;
        }
		
		TiXmlElement* root = doc.FirstChild( "svg" )->ToElement();
		recursive_parse( root );        
        
        // get bounds information from the svg file, ignoring non-pixel values
        string numberWithUnitString;

        _handler->_minX = 0.0f;
        if ( root->QueryStringAttribute( "x", &numberWithUnitString ) == TIXML_SUCCESS ) {
			_handler->_minX = findNumberWithUnit( numberWithUnitString, _handler->_minX );
        }
        
        _handler->_minY = 0.0f;
        if ( root->QueryStringAttribute( "y", &numberWithUnitString ) == TIXML_SUCCESS ) {
			_handler->_minY = findNumberWithUnit( numberWithUnitString, _handler->_minY );
        }
        
        _handler->_width = 0.0f;
        if ( root->QueryStringAttribute( "width", &numberWithUnitString ) == TIXML_SUCCESS ) {
			_handler->_width = findNumberWithUnit( numberWithUnitString, _handler->_width );
        }
        
        _handler->_height = 0.0f;
        if ( root->QueryStringAttribute( "height", &numberWithUnitString ) == TIXML_SUCCESS ) {
			_handler->_height = findNumberWithUnit( numberWithUnitString, _handler->_height );
        }
		return true;
		
	}
开发者ID:gavofyork,项目名称:MonkSVG,代码行数:37,代码来源:mkSVG.cpp


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