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


C++ xml_node::child方法代码示例

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


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

示例1: _configure

            /**
            * @brief Configures the block: defines the input file.
            * @param n The configuration parameters
            */
            virtual void _configure(const xml_node& n)
            {
                xml_node source = n.child("source");
                xml_node gates_node = n.child("gates");
                if( (!source)  || (!gates_node) )
                    throw std::runtime_error("TweetReader: missing parameter");
                std::string gates_s = gates_node.attribute("number").value();
                std::string type = source.attribute("type").value();
                std::string ip = source.attribute("ip").value();
                file_name = source.attribute("name").value();
                if(!type.length() || !file_name.length() || !gates_s.length())
                    throw std::runtime_error("TweetReader: missing attribute");
                if(type.compare("offline") != 0)
                    throw std::runtime_error("TweetReader: invalid type parameter");

                num_gates = atoi(gates_s.c_str());

                file.open(file_name);
                if(!file.is_open()) {
                    throw std::runtime_error("TweetReader: cannot open source file");
                }

                // Create and register the output gates
                m_outgate_ids = new int[num_gates];
                for(int i=0; i<num_gates; i++){
                    std::string ogate = outgate_basename + boost::lexical_cast<std::string>(i);
                    m_outgate_ids[i] = register_output_gate(ogate.c_str());
                }
            }
开发者ID:cnplab,项目名称:blockmon,代码行数:33,代码来源:TweetReader.cpp

示例2: processInputVariable

bool XMLFPParser::processInputVariable(const xml_node& var_root,
		MamdaniFuzzyObject* object) {

	InputLinguisticVariable *variable = new InputLinguisticVariable(var_root.child(LINGUISTIC_VARIABLE_ID_TAG).first_child().value(),
																	parsing::extractFloat(var_root.child(LINGUISTIC_VARIABLE_LOW_BOUND_TAG).child(LINGUISTIC_VARIABLE_VALUE_TAG).first_child().value()),
																	parsing::extractFloat(var_root.child(LINGUISTIC_VARIABLE_UP_BOUND_TAG).child(LINGUISTIC_VARIABLE_VALUE_TAG).first_child().value()));
	if(!loopFuzzySets(var_root.child(LINGUISTIC_VARIABLE_SETS_TAG),variable)){
		LERROR << "Error in parsing the fuzzy set for the variable : " << std::string(var_root.child(LINGUISTIC_VARIABLE_ID_TAG).first_child().value());
		return false;
	}

	return object->addInputVar(variable);
}
开发者ID:pablosproject,项目名称:FuzzyBrain-Release,代码行数:13,代码来源:XMLFPParser.cpp

示例3: _configure

		 /**
		   * configures the filter
		   * @param n the xml subtree
		   */
		 virtual void _configure(const xml_node&  n )
		 {
		     xml_node config = n.child("config");
		     xml_node log = n.child("logdir");
		     if(!config or !log)
	                 throw std::runtime_error("TstatAnalyzer: missing parameter");
             std::string cname=config.attribute("name").value();
		     tstat_init((char*)cname.c_str());
             std::string lname=config.attribute("name").value();
		     struct timeval cur_time;
		     gettimeofday(&cur_time,NULL);
		     tstat_new_logdir((char*)lname.c_str(), &cur_time);
		 }
开发者ID:carriercomm,项目名称:blockmon,代码行数:17,代码来源:TstatAnalyzer.cpp

示例4: parseRule

bool XMLFPParser::parseRule (const xml_node& rule, MamdaniFuzzyObject* object){

	string rule_string = rule.child(RULE_CONSEQUENT_TAG).child(RULE_VALUE_TAG).first_child().value();
	uniformRuleSintax(rule_string);
	MamdaniRule* toAdd = new MamdaniRule(rule_string);
	return object->addRule(toAdd);
}
开发者ID:pablosproject,项目名称:FuzzyBrain-Release,代码行数:7,代码来源:XMLFPParser.cpp

示例5: domain_error

vector<Light> Scene::readLights(const xml_node &scene)
{
	xml_node lightsNode = scene.child("lights");
	if(!lightsNode)
		throw domain_error("readLights: Couldn't found <lights> node");

	vector<Light> res;

	for (xml_node node = lightsNode.first_child(); node; node = node.next_sibling())
	{
		if(string(node.name()) != "light")
		{
			stringstream ss;
			ss << "Encountered an invalid <" << node.name() << "> element in the lights element.";
			throw domain_error(ss.str().c_str());
		}

		Light light(
			vectorFromChild(node, "position"),
			colorFromChild(node, "ambientColor"),
			colorFromChild(node, "diffuseColor"),
			floatFromChild(node, "linearAttenuation"),
			floatFromChild(node, "quadAttenuation")
			);

		res.push_back(light);
	}

	if(res.empty()){
		throw domain_error("No lights found. The scene must have at least one light.");
	}

	return res;
}
开发者ID:mvignale1987,项目名称:computer-graphics,代码行数:34,代码来源:Scene.cpp

示例6: parseLinguisticVariable

bool XMLFPParser::parseLinguisticVariable(const xml_node& node,
		MamdaniFuzzyObject* object, const string& outputName) {

	string variable_name = node.child(LINGUISTIC_VARIABLE_ID_TAG).first_child().value();
	if (variable_name == outputName) // it's the output variable
		return processOutputVariable(node, object);
	else
		return processInputVariable(node, object);
}
开发者ID:pablosproject,项目名称:FuzzyBrain-Release,代码行数:9,代码来源:XMLFPParser.cpp

示例7: intFromChild

int Scene::intFromChild(const xml_node &node, const string &child)
{
	xml_node childNode = node.child(child.c_str());
	if(!childNode){
		stringstream ss;
		ss << "node <"<< node.name() << "> has no child named '" << child << "'";
		throw invalid_argument(ss.str().c_str());
	}
	return childNode.text().as_int();
}
开发者ID:mvignale1987,项目名称:computer-graphics,代码行数:10,代码来源:Scene.cpp

示例8:

static void
get_channelnames (const xml_node &n, std::vector<std::string> &channelnames)
{
    xml_node channel_node = n.child ("channelnames");

    for (xml_node n = channel_node.child ("channelname"); n;
            n = n.next_sibling ("channelname")) {
        channelnames.push_back (n.child_value ());
    }
}
开发者ID:nerd93,项目名称:oiio,代码行数:10,代码来源:formatspec.cpp

示例9: add_layer

   void Tilemap::add_layer(std::map<unsigned, Surface>& tiles, xml_node node,
         int tilewidth, int tileheight)
   {
      Layer layer;
      int width  = node.attribute("width").as_int();
      int height = node.attribute("height").as_int();

      if (!width || !height)
         throw std::logic_error("Layer is empty.");

#if 0
      std::cerr << "Adding layer:" <<
         " Name: " << node.attribute("name").value() <<
         " Width: " << width <<
         " Height: " << height << std::endl;
#endif

      Utils::xml_node_walker walk{node.child("data"), "tile", "gid"};
      int index = 0;
      for (auto& gid_str : walk)
      {
         Pos pos = Pos(index % width, index / width);

         unsigned gid = Utils::stoi(gid_str);
         if (gid)
         {
            Blit::Surface surf = tiles[gid];
            surf.rect().pos = pos * Pos(tilewidth, tileheight);

            layer.cluster.vec().push_back({surf, Pos()});

            if (Utils::find_or_default(surf.attr(), "collision", "") == "true")
               collisions.insert(pos);
         }

         index++;
      }

      layer.attr = get_attributes(node.child("properties"), "property");
      layer.name = node.attribute("name").value();
      m_layers.push_back(std::move(layer));
   }
开发者ID:libretro,项目名称:Dinothawr,代码行数:42,代码来源:tilemap.cpp

示例10: Load

bool BoneTimelineKey::Load(const xml_node& node)
{
    if (!SpatialTimelineKey::Load(node))
        return false;

    xml_node boneNode = node.child("bone");
    length_ = boneNode.attribute("length").as_float(200.0f);
    width_ = boneNode.attribute("width").as_float(10.0f);

    return true;
}
开发者ID:TheComet93,项目名称:Urho3D,代码行数:11,代码来源:SpriterData2D.cpp

示例11: loopRules

bool XMLFPParser::loopRules(const xml_node& rules_root,
		MamdaniFuzzyObject* object) {

	for (xml_node rule = rules_root.child(RULE_TAG); rule; rule = rule.next_sibling(RULE_TAG)){
		if(!parseRule(rule, object)){
			LERROR << "Error during parse rule for object: " << object->getName();
			return false;
		}
	}
	return true;
}
开发者ID:pablosproject,项目名称:FuzzyBrain-Release,代码行数:11,代码来源:XMLFPParser.cpp

示例12: EnemyWeaponSystem

FrogShip::FrogShip(xml_node mirrorNode) {

	xml_node shipNode = mirrorNode.parent().parent();

	xml_node startNode = mirrorNode.child("start");
	xml_node controlNode = mirrorNode.child("controlPoint");
	xml_node climaxNode = mirrorNode.child("climax");
	xml_node endNode = mirrorNode.child("end");
	startPos = Vector2(
		getFloatFrom(startNode.attribute("x")) + camera.viewportPosition.x,
		getFloatFrom(startNode.attribute("y")));
	controlPoint = Vector2(
		getFloatFrom(controlNode.attribute("x")) + camera.viewportPosition.x,
		getFloatFrom(controlNode.attribute("y")));
	climaxPos = Vector2(
		getFloatFrom(climaxNode.attribute("x")) + camera.viewportPosition.x,
		getFloatFrom(climaxNode.attribute("y")));;
	endPos = Vector2(
		getFloatFrom(endNode.attribute("x")) + camera.viewportPosition.x,
		getFloatFrom(endNode.attribute("y")));


	xml_node weaponPointsNode = shipNode.child("weaponPoints");
	xml_node weaponSystemsNode = shipNode.parent().child("weaponSystems");

	for (xml_node weaponNode = weaponPointsNode.child("weapon");
		weaponNode; weaponNode = weaponNode.next_sibling()) {

		weaponSystems.push_back(unique_ptr<EnemyWeaponSystem>(
			new EnemyWeaponSystem(weaponNode, weaponSystemsNode)));

	}


	maxHealth = shipNode.child("health").text().as_int();
	health = maxHealth;

	position = Globals::SHIP_STORE_POSITION;


}
开发者ID:TheDizzler,项目名称:TenderTorrent,代码行数:41,代码来源:FrogShip.cpp

示例13: readSceneResolution

void Scene::readSceneResolution(const xml_node &scene, int& outWidth, int& outHeight)
{
	xml_node node = scene.child("resolution");
	if(!node)
		throw domain_error("readSceneResolution: Couldn't found <resolution> node");

	stringstream ss;
	ss << node.text().as_string();
	ss >> outWidth >> outHeight;
	if(ss.fail())
		throw domain_error("Bad resolution format. Couldn't read resolution x & y");
}
开发者ID:mvignale1987,项目名称:computer-graphics,代码行数:12,代码来源:Scene.cpp

示例14:

ConfigManager::ConfigManager( xml_node n)
{
	activeLineIndicator=n.child("LineIndicator").attribute("active").value();
	lineIndicator=n.child("LineIndicator").attribute("default").value();
	int l= activeLineIndicator.length() - lineIndicator.length();

	if( l>0 ){ //active is longer
		for( int i=0;i<l;i++)
			lineIndicator+=" ";
	}else{
		for( int i=0;i<l;i++)
			lineIndicator+=" ";
	}
	maxLines=n.child("maxLines").text().as_int();
	maxChar=n.child("maxChar").text().as_int();
	if( activeLineIndicator.length() >  lineIndicator.length() ){
		maxLineIndicatorLength=activeLineIndicator.length();
	}else{
		maxLineIndicatorLength=lineIndicator.length();
	}
}
开发者ID:kiranrajmohan,项目名称:lcd-menu-creator,代码行数:21,代码来源:ConfigManager.cpp

示例15: loopLinguisticVariables

bool XMLFPParser::loopLinguisticVariables(const xml_node& node,
	MamdaniFuzzyObject* object, const string& outputName) {

	for (xml_node lang_var_root = node.child(LINGUISTIC_VARIABLE_TAG) ; lang_var_root ; lang_var_root = lang_var_root.next_sibling(LINGUISTIC_VARIABLE_TAG)){
			if(!parseLinguisticVariable(lang_var_root, object, outputName)){
				LERROR << "Error parsing the object " +  outputName;
				return false;
			}
		}

	return true;
}
开发者ID:pablosproject,项目名称:FuzzyBrain-Release,代码行数:12,代码来源:XMLFPParser.cpp


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