本文整理汇总了C++中pugi::xml_node::first_child方法的典型用法代码示例。如果您正苦于以下问题:C++ xml_node::first_child方法的具体用法?C++ xml_node::first_child怎么用?C++ xml_node::first_child使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pugi::xml_node
的用法示例。
在下文中一共展示了xml_node::first_child方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseContainer
void EmmaParser::parseContainer(EmmaDoc &doc, pugi::xml_node containerNode)
{
std::string containerName = containerNode.name();
if(containerName == "emma:interpretation")
{
doc.setContainerType("interpretation");
parseInterpretation(doc, containerNode);
}
else if(containerName == "emma:sequence")
{
doc.setContainerType("sequence");
for (pugi::xml_node interpretation = containerNode.first_child(); interpretation; interpretation = interpretation.next_sibling())
{
parseInterpretation(doc, interpretation);
}
}
else if(containerName == "emma:one-of")
{
doc.setContainerType("one-of");
for (pugi::xml_node interpretation = containerNode.first_child(); interpretation; interpretation = interpretation.next_sibling())
{
parseInterpretation(doc, interpretation);
}
}
doc.sortInputs();
}
示例2: parseInterpretation
void EmmaParser::parseInterpretation(EmmaDoc &doc, pugi::xml_node interpretationNode)
{
std::string id = interpretationNode.attribute("id").value();
std::string medium = interpretationNode.attribute("emma:medium").value();
std::string mode = interpretationNode.attribute("emma:mode").value();
std::string start = interpretationNode.attribute("emma:start").value();
std::string end = interpretationNode.attribute("emma:end").value();
std::string confidence = interpretationNode.attribute("emma:confidence").value();
double numericConfidence = 0;
double numericStart = 0;
double numericEnd = 0;
if(confidence == "") //No confidence value was provided for input, assuming max confidence
numericConfidence = 1;
else
numericConfidence = atof(confidence.c_str()); //CAREFUL: NOT CHECKING IF THIS STRING IS ACTUALLY A DOUBLE
if(start != "") //Start value was provided for input
numericStart = atof(start.c_str()); //CAREFUL: NOT CHECKING IF THIS STRING IS ACTUALLY A DOUBLE
if(end != "") //End value was provided for input
numericEnd = atof(end.c_str()); //CAREFUL: NOT CHECKING IF THIS STRING IS ACTUALLY A DOUBLE
std::string inputEventTokens = "";
std::string noInput = interpretationNode.attribute("emma:no-input").value();
std::string uninterpretedInput = interpretationNode.attribute("emma:uninterpreted").value();
if((noInput == "true") || (uninterpretedInput == "true"))
numericConfidence = 0;
else
{
//Fetching the tokens from the literal element (if it exists)
//pugi::xml_node interpretationChild = interpretationNode.first_child();
std::string interpretationChildName = interpretationNode.first_child().name();
if(interpretationChildName == "emma:literal")
{
inputEventTokens = interpretationNode.first_child().child_value();
}
else if(interpretationChildName == "x" )//&& interpretationNode.first_child().next_sibling().name() == "y")
{
std::stringstream tokens;
tokens << interpretationNode.first_child().child_value() << "," << interpretationNode.first_child().next_sibling().child_value();
inputEventTokens = tokens.str();
}
}
InputEvent input(id, medium, mode, numericStart, numericEnd, numericConfidence, inputEventTokens);
doc.addInputEvent(input);
}
示例3: switch
boost::shared_ptr<Action> Root::loadAction(const pugi::xml_node &node) {
// XXX: This needs to be kept synchronized with the editor
enum NodeType {
Empty,
Speech,
Emote,
Sequence,
Concurrent,
Conditional,
Jump,
EndConversation
};
NodeType type = (NodeType)node.attribute("type").as_int();
switch(type) {
case Empty:
Message3(Game, Debug, "Empty action found!");
return boost::shared_ptr<Action>();
case Speech:
/*Message3(Game, Debug, "Speech action found! ["
<< node.attribute("speaker").as_string() << "]: "
<< node.attribute("speech").as_string());*/
return boost::shared_ptr<Action>();
case Emote:
return boost::shared_ptr<Action>();
case Sequence: {
auto ret = boost::make_shared<SequenceAction>();
for(auto n = node.first_child(); n; n = n.next_sibling()) {
ret->addAction(loadAction(n));
}
return ret;
}
case Concurrent: {
auto ret = boost::make_shared<ConcurrentAction>();
for(auto n = node.first_child(); n; n = n.next_sibling()) {
ret->addAction(loadAction(n));
}
return ret;
}
case Conditional:
case Jump:
case EndConversation:
break;
}
return boost::shared_ptr<Action>();
}
示例4: buildTextures
void buildTextures(ogl::CShape* const& pShape, const pugi::xml_node& _textures)
{
ogl::CTgaTextureBuilder* pTgaTextureBuilder = new ogl::CTgaTextureBuilder;
for(pugi::xml_node _texture = _textures.first_child(); _texture; _texture = _texture.next_sibling())
{
pugi::xml_attribute _scope = _texture.attribute("scope");
pugi::xml_attribute _src = _texture.attribute("src");
if(!_scope || !_src)
throw EXCEPTION << "<texture scope=\"?\" src=\"?\"> attributes are mandatory!";
pTgaTextureBuilder->setFile(_src.value());
if(strncmp(_scope.value(), "diffuse", 7) == 0)
{
pShape->getMaterial()->setTexture(ogl::CTexture::EScope::DIFFUSE, pTgaTextureBuilder->build());
}
else if(strncmp(_scope.value(), "normals", 7) == 0)
{
pShape->getMaterial()->setTexture(ogl::CTexture::EScope::NORMALS, pTgaTextureBuilder->build());
}
else if(strncmp(_scope.value(), "height", 5) == 0)
{
pShape->getMaterial()->setTexture(ogl::CTexture::EScope::HEIGHT, pTgaTextureBuilder->build());
}
else
{
throw EXCEPTION << "<texture scope=\"" << _scope.value() << "\" > Not supported!";
}
}
_DELETE(pTgaTextureBuilder);
}
示例5: findSimilarNode
static pugi::xml_node findSimilarNode(pugi::xml_node searchNode, pugi::xml_node searchRoot, unsigned maxDistance)
{
std::string searchNodeName = searchNode.name();
pugi::xml_node match;
// Examine children of searchRoot that have matching names to searchNode
unsigned i = 0;
pugi::xml_node child = searchRoot.first_child();
for (; child && i < maxDistance && !match; child = child.next_sibling(), i++) {
// Ignore nodes with non-matching names
if (searchNodeName != child.name())
continue;
// Assume child is a match, until shown otherwise
match = child;
// Check that all attributes of searchNode match the child node's attributes
for (pugi::xml_attribute attr : searchNode.attributes()) {
std::string searchNodeAttr = attr.value();
std::string matchAttr = child.attribute(attr.name()).value();
if (searchNodeAttr != matchAttr) {
match = pugi::xml_node();
break;
}
}
}
return match;
}
示例6: mergeNodes
void mergeNodes(pugi::xml_node toNode, pugi::xml_node& fromNode)
{
// Base case = both nodes are text nodes
pugi::xml_text fromNodeText = fromNode.text();
pugi::xml_text toNodeText = toNode.text();
if (fromNodeText && toNodeText) {
SBLog::info() << "Overwriting template value of \"" << toNode.name() << "\" from \"" << toNodeText.get() << "\" to \"" << fromNodeText.get() << "\"." << std::endl;
toNodeText.set(fromNodeText.get());
return;
}
// Calculate number of children in toNode
unsigned maxDistance = std::distance(toNode.begin(), toNode.end());
// Merge children
for (pugi::xml_node fromNodeChild = fromNode.first_child(); fromNodeChild; fromNodeChild = fromNodeChild.next_sibling()) {
// Find appropriate merge point
pugi::xml_node toNodeChild = findSimilarNode(fromNodeChild, toNode, maxDistance);
if (toNodeChild) {
mergeNodes(toNodeChild, fromNodeChild);
} else {
toNode.append_copy(fromNodeChild);
}
}
// Erase fromNode
removeNode(fromNode);
}
示例7: parseBuildAction
void XCScheme::parseBuildAction(const pugi::xml_node& node, const ErrorReporter& reporter)
{
// Get the BuildableReference node
BuildRef br;
const pugi::xml_node brNode = node.first_child();
// Get the product name
getXMLProperty(brNode, "BuildableName", br.productName, VALUE_REQUIRED, reporter);
// Get the target name
getXMLProperty(brNode, "BlueprintName", br.targetName, VALUE_REQUIRED, reporter);
// Get the container (project) for the target
getXMLProperty(brNode, "ReferencedContainer", br.container, VALUE_REQUIRED, reporter);
br.container = br.container.substr(10);
// Get target id
getXMLProperty(brNode, "BlueprintIdentifier", br.id, VALUE_REQUIRED, reporter);
// Check that all fields were read
if (br.productName.empty() || br.targetName.empty() ||
br.container.empty() || br.id.empty()) {
reporter.reportError("BuildableReference is incomplete.");
return;
}
// Get the value of buildForArchiving
String shouldArchive;
getXMLProperty(node, "buildForArchiving", shouldArchive, VALUE_REQUIRED, reporter);
if (shouldArchive == "YES") {
m_targets.push_back(br);
} else {
SBLog::info() << "Ignoring BuildableReference to \"" << br.targetName << "\" target because it is not archivable." << std::endl;
}
}
示例8: AddAttribute
void XMLFile::AddAttribute(const pugi::xml_node& patch, const pugi::xpath_node& original) const
{
pugi::xml_attribute attribute = patch.attribute("type");
if (!patch.first_child() && patch.first_child().type() != pugi::node_pcdata)
{
URHO3D_LOGERRORF("XML Patch failed calling Add due to attempting to add non text to an attribute for %s.", attribute.value());
return;
}
String name(attribute.value());
name = name.Substring(1);
pugi::xml_attribute newAttribute = original.node().append_attribute(name.CString());
newAttribute.set_value(patch.child_value());
}
示例9: print_entry
void RainbowTable::print_entry(pugi::xml_node &entry) {
//prints all data associated with node entry
cout << endl;//redability
//print attributes of entry node
for (pugi::xml_attribute attr = entry.first_attribute();
attr;
attr = attr.next_attribute()) {
if (strcmp("key" , attr.name()) != 0 ) { //ignore key
cout << attr.name() << ": " << attr.value() << endl;
}
}
//search through child nodes
for (pugi::xml_node child = entry.first_child();
child;
child = child.next_sibling()) {
cout << child.name() << endl;
//is there text outside of the attrubutes?
if (child.text()) {
cout << '\t' << child.first_child().value() << endl;
}
//print attributes of child
for (pugi::xml_attribute attr = child.first_attribute();
attr;
attr = attr.next_attribute()) {
cout << '\t' << attr.name() << ": " << attr.value() << endl;
}
}
}
示例10: ParseBackpacks
void CUserProfile::ParseBackpacks(pugi::xml_node& xmlItem)
{
// enter into items list
xmlItem = xmlItem.first_child();
while(!xmlItem.empty())
{
uint32_t CharID = xmlItem.attribute("CharID").as_uint();
r3d_assert(CharID);
bool found = true;
for(int i=0; i<ProfileData.NumSlots; i++)
{
if(ProfileData.ArmorySlots[i].LoadoutID == CharID)
{
parseCharBackpack(xmlItem, ProfileData.ArmorySlots[i]);
found = true;
break;
}
}
if(!found)
r3dError("bad backpack data for charid %d", CharID);
xmlItem = xmlItem.next_sibling();
}
}
示例11: makeChildren
void TwXmlDocument::makeChildren(pugi::xml_node& elem, TwXmlElement* parent)
{
pugi::xml_node childElem = elem.first_child();
while (childElem)
{
if (childElem.type() == pugi::node_element)
{
TwXmlElement* child = new TwXmlElement(childElem.name());
child->setText(childElem.text().get());
pugi::xml_attribute attr = childElem.first_attribute();
while (attr)
{
child->setAttribute(attr.name(), attr.value());
attr = attr.next_attribute();
}
parent->addChild(child);
makeChildren(childElem, child);
}
childElem = childElem.next_sibling();
}
}
示例12: read_xml_node
void read_xml_node( pugi::xml_node node, Ptree &pt, int flags)
{
typedef typename Ptree::key_type::value_type Ch;
switch ( node.type() )
{
case pugi::node_element:
{
Ptree &tmp = pt.push_back(std::make_pair( node.name(), Ptree()))->second;
for ( pugi::xml_attribute attr = node.first_attribute(); attr; attr = attr.next_attribute() )
tmp.put( xmlattr<Ch>() + "." + attr.name(), attr.value());
for ( pugi::xml_node child = node.first_child(); child; child = child.next_sibling())
read_xml_node(child, tmp, flags);
}
break;
case pugi::node_pcdata:
{
if (flags & no_concat_text)
pt.push_back(std::make_pair(xmltext<Ch>(), Ptree( node.value() )));
else
pt.data() += node.value();
}
break;
case pugi::node_comment:
{
if (!(flags & no_comments))
pt.push_back(std::make_pair(xmlcomment<Ch>(), Ptree( node.value() )));
}
break;
default:
// skip other types
break;
}
}
示例13: loadText
/*
* reads in sentences within the <s></s> tags and adds each sentence,
* converted into a WordID vector.
*/
void Patent::loadText(const pugi::xml_node& node) {
for (pugi::xml_node s = node.first_child(); s; s = s.next_sibling()) {
std::vector<WordID> ids;
TD::ConvertSentence(s.text().as_string(), &ids);
text.push_back(ids);
}
}
示例14: loadLootContainer
void Monsters::loadLootContainer(const pugi::xml_node& node, LootBlock& lBlock)
{
for (pugi::xml_node subNode = node.first_child(); subNode; subNode = subNode.next_sibling()) {
LootBlock lootBlock;
if (loadLootItem(subNode, lootBlock)) {
lBlock.childLoot.push_back(lootBlock);
}
}
}
示例15: BuildMenu
void SMenu::BuildMenu( HMENU menuPopup,pugi::xml_node xmlNode )
{
pugi::xml_node xmlItem=xmlNode.first_child();
while(xmlItem)
{
if(wcscmp(L"item",xmlItem.name())==0)
{
SMenuItemData *pdmmi=new SMenuItemData;
pdmmi->hMenu=menuPopup;
pdmmi->itemInfo.iIcon=xmlItem.attribute(L"icon").as_int(-1);
SStringW strText = xmlItem.text().get();
strText.TrimBlank();
InitMenuItemData(pdmmi->itemInfo,strText);
int nID=xmlItem.attribute(L"id").as_int(0);
BOOL bCheck=xmlItem.attribute(L"check").as_bool(false);
BOOL bRadio=xmlItem.attribute(L"radio").as_bool(false);
BOOL bDisable=xmlItem.attribute(L"disable").as_bool(false);
pugi::xml_writer_buff writer;
xmlItem.print(writer,L"\t",pugi::format_default,pugi::encoding_utf16);
SStringW str(writer.buffer(),writer.size());
pugi::xml_node xmlChild=xmlItem.first_child();
while(xmlChild && xmlChild.type()==pugi::node_pcdata) xmlChild=xmlChild.next_sibling();
if(!xmlChild)
{
pdmmi->nID=nID;
UINT uFlag=MF_OWNERDRAW;
if(bCheck) uFlag|=MF_CHECKED;
if(bDisable) uFlag |= MF_GRAYED;
if(bRadio) uFlag |= MFT_RADIOCHECK|MF_CHECKED;
AppendMenu(menuPopup,uFlag,(UINT_PTR)pdmmi->nID,(LPCTSTR)pdmmi);
}
else
{
HMENU hSubMenu=::CreatePopupMenu();
pdmmi->nID=(UINT_PTR)hSubMenu;
UINT uFlag=MF_OWNERDRAW|MF_POPUP;
if(bDisable) uFlag |= MF_GRAYED;
AppendMenu(menuPopup,uFlag,(UINT_PTR)hSubMenu,(LPCTSTR)pdmmi);
BuildMenu(hSubMenu,xmlItem);//build sub menu
}
m_arrDmmi.Add(pdmmi);
}
else if(wcscmp(L"sep",xmlItem.name())==0)
{
AppendMenu(menuPopup,MF_SEPARATOR|MF_OWNERDRAW,(UINT_PTR)0,(LPCTSTR)NULL);
}
xmlItem=xmlItem.next_sibling();
}
}