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


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

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


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

示例1: parse_predicates

void parse_predicates(pugi::xml_node node, config::config & conf) {
    size_t size = node.child("size").text().as_uint();
    //cout << "predicates size: " << size << endl;
    conf.predicates.resize(size);
    
    conf.predicate_distribution = parse_distribution(node.child("distribution"));
    
    for (pugi::xml_node alias_node : node.children("alias")) {
        size_t id = alias_node.attribute("symbol").as_uint();//
        string name = alias_node.text().get();
        //cout << "alias " << id << ", " << name  << endl;
        if (id < 0 || id >= size) {
            cerr << "id " << id << " is out of range" << endl;
            continue;
        }

        conf.predicates[id].alias = name;
    }
    
    for (pugi::xml_node proportion_node : node.children("proportion")) {
        size_t id = proportion_node.attribute("symbol").as_uint();
        double proportion = proportion_node.text().as_double();
        if (id < 0 || id >= size) {
            cerr << "id " << id << " is out of range" << endl;
            continue;
        }
        conf.predicates[id].proportion = proportion;
        conf.predicates[id].size = (size_t) (proportion * conf.nb_edges);
    }
}
开发者ID:Eloise-Yollande-Mole-Kamga,项目名称:EGSG,代码行数:30,代码来源:configparser.cpp

示例2: parseAtomAuthor

void parseAtomAuthor(FeedAuthor& author, const pugi::xml_node &authorNode) {
  string nodeName = authorNode.name();
  if (nodeName != "author") {
    throw ParseError("expected author node.");
  }
  bool haveDetailedAuthor = false;
  for (auto child: authorNode.children()) {
    haveDetailedAuthor = true;
    nodeName = child.name();
    if (nodeName == "name") {
      getNodeContent(author.name, child);
    } else if (nodeName == "email") {
      getNodeContent(author.email, child);
    } else if (nodeName == "uri") {
      getNodeContent(author.link.url, child);
    } else if (nodeName == "link") {
      if (author.link.url.empty()) {
        getNodeContent(author.link.url, child);
      }
    }
  }
  if (!haveDetailedAuthor) {
    // the node is just a bare <author>NAME</author> element.
    getNodeContent(author.name, authorNode);
  }
}
开发者ID:CurataEng,项目名称:cyrss,代码行数:26,代码来源:atom.cpp

示例3: parse_schema

void parse_schema(pugi::xml_node node, config::config & conf) {
    for (pugi::xml_node source_node : node.children("source")) {
        size_t source_type = source_node.attribute("type").as_uint();
        for (pugi::xml_node target_node : source_node.children("target")) {
            char multiplicity = '*';
            size_t target_type = target_node.attribute("type").as_uint();
            size_t symbol = target_node.attribute("symbol").as_uint();
            string mult_string = target_node.attribute("multiplicity").value();
            if (mult_string.size() > 0 && (mult_string[0] == '?' || mult_string[0] == '+' || mult_string[0] == '1')) {
                multiplicity = mult_string[0];
            }
            pugi::xml_node outdistribution_node = target_node.child("outdistribution");
            distribution outdistribution = parse_distribution(outdistribution_node);
            pugi::xml_node indistribution_node = target_node.child("indistribution");
            distribution indistribution = parse_distribution(indistribution_node);
            
            if (multiplicity == '1') { // && outdistribution.type == DISTRIBUTION::UNDEFINED) {
                outdistribution = distribution(DISTRIBUTION::UNIFORM, 1, 1);
            }
            else if (multiplicity == '?') {// && outdistribution.type == DISTRIBUTION::UNDEFINED) {
                outdistribution = distribution(DISTRIBUTION::UNIFORM, 0, 1);
            }
            
            if(outdistribution.type == DISTRIBUTION::UNDEFINED) {
                outdistribution = distribution(DISTRIBUTION::ZIPFIAN, 0, 2.5);
            }
            
            
            
            conf.schema.add_edge(source_type, symbol, target_type, multiplicity, outdistribution, indistribution);
            //cout << "conf.add_edge "  << source_type << " " << symbol << " " << target_type << " " << multiplicity << " " << outdistribution << " " << indistribution <<endl;
            
        }
    }
}
开发者ID:Eloise-Yollande-Mole-Kamga,项目名称:EGSG,代码行数:35,代码来源:configparser.cpp

示例4: catch

std::unordered_map<std::string, gal::SensorResource> load_sensors(const pugi::xml_node& root)
{
    std::unordered_map<std::string, gal::SensorResource> sensors;

    for (const auto& r : root.children("SensorResource"))
    {
        gal::SensorResource res;

        res.id = r.attribute("id").as_string();
        res.type = static_cast<gal::EntitySensorDataType>(r.attribute("type").as_int());
        res.description = r.child("Description").child_value();
        res.scale = static_cast<gal::EntitySensorDataScale>(r.attribute("scale").as_int());
        res.precision = static_cast<gal::EntitySensorPrecision>(r.attribute("precision").as_int());
        res.refresh_rate = static_cast<gal::EntitySensorValueUpdateRate>(r.attribute("refresh_rate").as_int());

        try
        {
            res.max_value = std::stoll(r.attribute("max").as_string());
        }
        catch (std::exception& ex)
        {
            tnt::Log::error("load_sensors error (", res.id, "): ", ex.what(), " - attribute: ==>", r.attribute("max").as_string(), "<==");
        }
        
        sensors.emplace(res.id, res);
    }

    return sensors;
}
开发者ID:carriercomm,项目名称:dropgit,代码行数:29,代码来源:load_sensors.cpp

示例5: parseTerrainNode

void Tileset::parseTerrainNode(const pugi::xml_node& node)
{
    const auto& children = node.children();
    for (const auto& child : children)
    {
        std::string name = child.name();
        if (name == "terrain")
        {
            m_terrainTypes.emplace_back();
            auto& terrain = m_terrainTypes.back();
            terrain.name = child.attribute("name").as_string();
            terrain.tileID = child.attribute("tile").as_int();
            auto properties = child.child("properties");
            if (properties)
            {
                for (const auto& p : properties)
                {
                    name = p.name();
                    if (name == "property")
                    {
                        terrain.properties.emplace_back();
                        terrain.properties.back().parse(p);
                    }
                }
            }
        }
    }
}
开发者ID:fallahn,项目名称:xygine,代码行数:28,代码来源:Tileset.cpp

示例6: readNodes

bool GraphMLParser::readNodes(
	Graph &G,
	GraphAttributes *GA,
	const pugi::xml_node rootTag)
{
	for(pugi::xml_node nodeTag : rootTag.children("node")) {
		pugi::xml_attribute idAttr = nodeTag.attribute("id");
		if(!idAttr) {
			GraphIO::logger.lout() << "Node is missing id attribute." << endl;
			return false;
		}

		const node v = G.newNode();
		m_nodeId[idAttr.value()] = v;

		// Search for data-key attributes if GA given.
		if(GA && !readAttributes(*GA, v, nodeTag)) {
			return false;
		}

		pugi::xml_node clusterTag = nodeTag.child("graph");
		if (clusterTag) {
			GraphIO::logger.lout(Logger::LL_MINOR) << "Nested graphs are not fully supported." << endl;
			return readNodes(G, GA, clusterTag);
		}
	}

	return readEdges(G, GA, rootTag);
}
开发者ID:marvin2k,项目名称:ogdf,代码行数:29,代码来源:GraphMLParser.cpp

示例7: parseAtomFeed

void parseAtomFeed(Feed &feed, const pugi::xml_node &rootNode) {
  getNodeAttr(feed.metadata.language.name, rootNode, "lang");
  string globalBase = getNodeAttr(rootNode, "base");

  string name;
  for (auto node: rootNode.children()) {
    name = node.name();
    if (name == "title") {
      feed.metadata.title = std::move(FeedData::fromXmlNode(node));
    } else if (name == "id") {
      getNodeContent(feed.metadata.guid.id, node);
    } else if (name == "author") {
      parseAtomAuthor(feed.metadata.author, node);
    } else if (name == "subtitle") {
      feed.metadata.description = std::move(FeedData::fromXmlNode(node));
    } else if (name == "link") {
      string rel = getNodeAttr(node, "rel");
      if (rel == "alternate") {
        feed.metadata.link.url = url_util::make_absolute_url(globalBase, getNodeAttr(node, "href"));
      }
    } else if (name == "updated") {
      feed.metadata.pubDate = FeedDateTime::fromW3cDtf(node);
    } else if (name == "modified" || name == "created" || name == "issued") {
      if (feed.metadata.pubDate.empty()) {
        feed.metadata.pubDate = FeedDateTime::fromRfc822(node);
      }
    } else if (name == "entry") {
      feed.items.push_back(parseAtomFeedItem(node, globalBase));
    }
  }
}
开发者ID:CurataEng,项目名称:cyrss,代码行数:31,代码来源:atom.cpp

示例8: accept

void XMLSerializer::accept(std::function<void(const Node &)> visitor, const pugi::xml_node &node) {
	XMLNode xmlnode{node};
	visitor(xmlnode);

	for (const auto &child : node.children()) {
		accept(visitor, child);
	}
}
开发者ID:Valtis,项目名称:sdl_gui,代码行数:8,代码来源:XMLSerializer.cpp

示例9: parsePropertyNode

void Tileset::parsePropertyNode(const pugi::xml_node& node)
{
    const auto& children = node.children();
    for (const auto& child : children)
    {
        m_properties.emplace_back();
        m_properties.back().parse(child);
    }
}
开发者ID:fallahn,项目名称:xygine,代码行数:9,代码来源:Tileset.cpp

示例10: loadLootContainer

void Monsters::loadLootContainer(const pugi::xml_node& node, LootBlock& lBlock)
{
	for (auto subNode : node.children()) {
		LootBlock lootBlock;
		if (loadLootItem(subNode, lootBlock)) {
			lBlock.childLoot.emplace_back(std::move(lootBlock));
		}
	}
}
开发者ID:brewsterl,项目名称:maruim_server,代码行数:9,代码来源:monsters.cpp

示例11: parse_types

void parse_types(pugi::xml_node node, config::config & conf) {
    size_t size = node.child("size").text().as_uint();
    //cout << "type size: " << size << endl;
    conf.types.resize(size);
    
    for (pugi::xml_node alias_node : node.children("alias")) {
        size_t id = alias_node.attribute("type").as_uint();//
        string name = alias_node.text().get();
        //cout << "alias " << id << ", " << name  << endl;
        if (id < 0 || id >= size) {
            cerr << "id " << id << " is out of range" << endl;
            continue;
        }
        conf.types[id].alias = name;
    }
    
    for (pugi::xml_node proportion_node : node.children("proportion")) {
        size_t id = proportion_node.attribute("type").as_uint();
        double proportion = proportion_node.text().as_double();
        //cout << "proportion " << id << ", " << proportion  << endl;
        if (id < 0 || id >= size) {
            cerr << "id " << id << " is out of range" << endl;
            continue;
        }
        conf.types[id].size = (size_t) (proportion * conf.nb_nodes);
        conf.types[id].scalable = true;
        
        if (proportion * conf.nb_nodes > 0 &&  conf.types[id].size == 0) {
            conf.types[id].size = 1;
        }
    }
    
    for (pugi::xml_node fixed_node : node.children("fixed")) {
        size_t id = fixed_node.attribute("type").as_uint();
        size_t size2 = fixed_node.text().as_uint();
        //cout << "fixed " << id << ", " << size  << endl;
        if (id < 0 || id >= size) {
            cerr << "id " << id << " is out of range" << endl;
            continue;
        }
        conf.types[id].size = size2;
        conf.types[id].scalable = false;
    }    
}
开发者ID:Eloise-Yollande-Mole-Kamga,项目名称:EGSG,代码行数:44,代码来源:configparser.cpp

示例12: ParseKeyRemapData

        void ParseKeyRemapData( pugi::xml_node curnode, SMDLPresetConversionInfo::PresetConvData & pconv, dsepresetid_t preset, const string & trkname )
        {
            using namespace pugi;
            using namespace cvinfoXML;

            for( auto & keyremap : curnode.children() )
            {
                if( keyremap.name() == NODE_KeyRemap )
                    ParseAKeyRemap( keyremap, pconv, preset, trkname );
            }
        }
开发者ID:PsyCommando,项目名称:ppmdu,代码行数:11,代码来源:dse_conversion_info.cpp

示例13: ParsePrograms

        void ParsePrograms( pugi::xml_node curnode, SMDLPresetConversionInfo & convinf, const string & trkname )
        {
            using namespace pugi;
            using namespace cvinfoXML;

            for( auto & prgnode : curnode.children() )
            {
                if( prgnode.name() == NODE_Program )
                    ParseAProgram( prgnode, convinf, trkname );
            }
        }
开发者ID:PsyCommando,项目名称:ppmdu,代码行数:11,代码来源:dse_conversion_info.cpp

示例14: ParseAKeyRemap

        void ParseAKeyRemap( pugi::xml_node curnode, SMDLPresetConversionInfo::PresetConvData & pconv, dsepresetid_t preset, const string & trkname )
        {
            using namespace pugi;
            using namespace cvinfoXML;
            midinote_t inkey     = InvalidMIDIKey;
            midinote_t outkey    = InvalidMIDIKey;
            presetid_t midprg    = InvalidPresetID;
            bankid_t   midbnk    = InvalidBankID;
            uint8_t    idealchan = UCHAR_MAX;

            for( auto & keyprop : curnode.children() )
            {
                if( keyprop.name() == PROP_InKey )
                    inkey = utils::parseByte( keyprop.child_value() );
                else if( keyprop.name() == PROP_OutKey )
                    outkey = utils::parseByte( keyprop.child_value() );
                else if( keyprop.name() == PROP_MIDIPrg )
                    midprg = utils::parseByte( keyprop.child_value() ) - 1; //Bring back onto 0-127
                else if( keyprop.name() == PROP_MIDIBnk )
                    utils::parseHexaValToValue(  keyprop.child_value(), midbnk );
                else if( keyprop.name() == PROP_ForceChan )
                    idealchan = ( utils::parseByte( keyprop.child_value() ) - 1); //Bring back to 0-15
            }

            if( inkey != InvalidMIDIKey && outkey != InvalidMIDIKey )
            {
                SMDLPresetConversionInfo::NoteRemapData rmap;
                rmap.destnote = outkey;

                if( midprg != InvalidPresetID )
                {
                    if( midprg >= 0 && midprg <= CHAR_MAX )
                        rmap.destpreset = midprg;
                    else
                        clog << "#CVInfoParser : Forced preset for preset " <<preset <<" for key " <<inkey << " for track " <<trkname << " was not one of the valid 127 MIDI presets! Ignoring!\n";
                }

                if( midbnk != InvalidBankID )
                {
                    rmap.destbank = midbnk;
                }

                if( idealchan != UCHAR_MAX )
                {
                    if( idealchan < NbMidiChannels )
                        rmap.idealchan = idealchan;
                    else
                        clog << "#CVInfoParser : Forced channel for preset " <<preset <<" for key " <<inkey <<" for track " <<trkname << " was not one of the valid 16 MIDI channel! Ignoring!\n";
                }

                pconv.remapnotes.insert( make_pair( inkey, rmap ) );
            }
        }
开发者ID:PsyCommando,项目名称:ppmdu,代码行数:53,代码来源:dse_conversion_info.cpp

示例15: ParseAProgram

        void ParseAProgram( pugi::xml_node curnode, SMDLPresetConversionInfo & convinf, const string & trkname )
        {
            using namespace pugi;
            using namespace cvinfoXML;

            SMDLPresetConversionInfo::PresetConvData pconv;
            stringstream                             sstrparse;
            dsepresetid_t                            dseid = InvalidDSEPresetID;

            for( auto & progprop : curnode.children() )
            {
                if( progprop.name() == PROP_DSEID )
                    utils::parseHexaValToValue(  progprop.child_value(), dseid );
                else if( progprop.name() == PROP_MIDIPrg )
                    pconv.midipres = utils::parseByte( progprop.child_value() ) - 1; //Bring back onto 0-127
                else if( progprop.name() == PROP_MIDIBnk )
                    utils::parseHexaValToValue(  progprop.child_value(), pconv.midibank );
                else if( progprop.name() == PROP_MaxKeyDown )
                    utils::parseHexaValToValue( progprop.child_value(), pconv.maxkeydowndur );
                else if( progprop.name() == PROP_Transpose )
                    pconv.transpose = utils::parseSignedByte( progprop.child_value() );
                else if( progprop.name() == PROP_ForceChan )
                    pconv.idealchan = (utils::parseByte( progprop.child_value() ) - 1); //Bring back to 0-15 from 1-16
                else if( progprop.name() == NODE_KeyRemaps )
                {
                    ParseKeyRemapData( progprop, pconv, dseid, trkname );
                }
            }

            if( dseid != InvalidDSEPresetID )
            {
                if( pconv.midipres != InvalidPresetID && pconv.midipres > CHAR_MAX )
                {
                    clog << "#CVInfoParser : Forced preset for preset " <<dseid << " for track " <<trkname << " was not one of the valid 127 MIDI presets! Ignoring!\n";
                    pconv.midipres = InvalidPresetID;
                }

                if( pconv.idealchan != UCHAR_MAX && pconv.idealchan >= NbMidiChannels )
                {
                    clog << "#CVInfoParser : Forced channel for preset " <<dseid <<" for track " <<trkname << " was not one of the valid 16 MIDI channel! Ignoring!\n";
                    pconv.idealchan = UCHAR_MAX;
                }
            }

            if( dseid != InvalidDSEPresetID )
                convinf.AddPresetConvInfo( dseid, move(pconv) );
            else 
                clog << "<!>- Ignored a " <<NODE_Program <<" node because there was no DSE program ID specified!\n";
        }
开发者ID:PsyCommando,项目名称:ppmdu,代码行数:49,代码来源:dse_conversion_info.cpp


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