本文整理汇总了C++中xml::gcXMLElement::for_each_child方法的典型用法代码示例。如果您正苦于以下问题:C++ gcXMLElement::for_each_child方法的具体用法?C++ gcXMLElement::for_each_child怎么用?C++ gcXMLElement::for_each_child使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xml::gcXMLElement
的用法示例。
在下文中一共展示了gcXMLElement::for_each_child方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseNewsAndGifts
void User::parseNewsAndGifts(const XML::gcXMLElement &xmlNode, const char* szChildName, Event<std::vector<UserCore::Misc::NewsItem*> > &onEvent)
{
if (!xmlNode.IsValid())
return;
std::vector<UserCore::Misc::NewsItem*> itemList;
xmlNode.for_each_child(szChildName, [&itemList](const XML::gcXMLElement &itemElem)
{
const std::string szId = itemElem.GetAtt("id");
gcString szTitle;
gcString szUrl;
itemElem.GetChild("title", szTitle);
itemElem.GetChild("url", szUrl);
if (szId.empty() || szTitle.empty() || szUrl.empty())
return;
uint32 id = (uint32)Safe::atoi(szId.c_str());
UserCore::Misc::NewsItem *temp = new UserCore::Misc::NewsItem(id, 0, szTitle.c_str(), szUrl.c_str());
itemList.push_back(temp);
});
if (itemList.size() > 0)
onEvent(itemList);
safe_delete(itemList);
}
示例2: extractInstallChecks
void BranchInstallInfo::extractInstallChecks(const XML::gcXMLElement &icsNode, gcRefPtr<WildcardManager> &pWildCard, std::vector<InsCheck> &vInsChecks)
{
icsNode.for_each_child("installlocation", [&vInsChecks, pWildCard, this](const XML::gcXMLElement &icNode)
{
const gcString iCheck = icNode.GetChild("check");
const gcString iPath = icNode.GetChild("path");
if (iCheck.empty() || iPath.empty())
return;
try
{
gcString strCheckRes = pWildCard->constructPath(iCheck.c_str());
if (isInstalled())
{
if (!updateInstallCheck(strCheckRes, iPath))
return;
vInsChecks.push_back(InsCheck(strCheckRes.c_str(), m_szPath.c_str()));
}
else
{
vInsChecks.push_back(InsCheck(strCheckRes.c_str(), iPath.c_str()));
}
}
catch (...)
{
}
});
}
示例3: LoadSprites
void Theme::LoadSprites(const XML::gcXMLElement &xmlEl)
{
xmlEl.for_each_child("sprite", [this](const XML::gcXMLElement &xmlChild)
{
const std::string name = xmlChild.GetAtt("name");
if (name.empty())
return;
auto sprite = SpriteList::findItem(name.c_str());
if (!sprite)
{
sprite = gcRefPtr<ThemeSpriteInfo>::create(name.c_str());
addItem(sprite);
}
xmlChild.for_each_child("rect", [sprite](const XML::gcXMLElement &xmlRect)
{
const std::string rName = xmlRect.GetAtt("name");
const XML::gcXMLElement pos = xmlRect.FirstChildElement("pos");
const XML::gcXMLElement size = xmlRect.FirstChildElement("size");
if (rName.empty() || !pos.IsValid() || !size.IsValid())
return;
const std::string x = pos.GetAtt("x");
const std::string y = pos.GetAtt("y");
const std::string w = size.GetAtt("w");
const std::string h = size.GetAtt("h");
if (x.empty() || y.empty() || w.empty() || h.empty())
return;
auto rect = sprite->findItem(rName.c_str());
if (!rect)
{
rect = gcRefPtr<SpriteRect>::create(rName.c_str());
sprite->addItem(rect);
}
rect->x = Safe::atoi(x.c_str());
rect->y = Safe::atoi(y.c_str());
rect->w = Safe::atoi(w.c_str());
rect->h = Safe::atoi(h.c_str());
});
});
}
示例4: parseXml
uint8 UMcf::parseXml(const XML::gcXMLElement &xmlElement)
{
if (!xmlElement.IsValid())
return UMCF_ERR_XML_NOPRIMENODE;
xmlElement.for_each_child("file", [this](const XML::gcXMLElement &xmlChild)
{
auto temp = std::make_shared<UMcfFile>();
if (temp->loadXmlData(xmlChild) == UMCF_OK)
m_pFileList.push_back(temp);
});
return UMCF_OK;
}
示例5: parseXML
uint8 WildcardManager::parseXML(const XML::gcXMLElement &xmlElement)
{
if (!xmlElement.IsValid())
return WCM_ERR_BADXML;
xmlElement.for_each_child("wcard", [this](const XML::gcXMLElement &xmlChild)
{
const std::string name = xmlChild.GetAtt("name");
const std::string type = xmlChild.GetAtt("type");
const std::string string = xmlChild.GetText();
if (!name.empty() && !type.empty() && !string.empty())
{
addItem(new WildcardInfo(name, string, type));
}
});
return WCM_OK;
}
示例6: LoadImages
void Theme::LoadImages(const UTIL::FS::Path& path, const XML::gcXMLElement &xmlEl)
{
xmlEl.for_each_child("image", [this, &path](const XML::gcXMLElement &xmlChild)
{
const std::string name = xmlChild.GetAtt("name");
const std::string val = xmlChild.GetText();
if (name.empty() || val.empty())
return;
std::string outVal = UTIL::STRING::sanitizeFileName(val);
auto img = ImageList::findItem(name.c_str());
if (!img)
{
img = gcRefPtr<ThemeImageInfo>::create(name.c_str());
addItem(img);
}
gcString fullPath("{0}{2}images{2}app{2}{1}", path.getFolderPath(), outVal, DIRS_STR);
img->path = fullPath;
});
}
示例7: LoadControls
void Theme::LoadControls(const XML::gcXMLElement &xmlEl)
{
xmlEl.for_each_child("control", [this](const XML::gcXMLElement &xmlChild)
{
const std::string name = xmlChild.GetAtt("name");
if (name.empty())
return;
auto control = ControlList::findItem(name.c_str());
if (!control)
{
control = gcRefPtr<ThemeControlInfo>::create(name.c_str());
addItem(control);
}
xmlChild.for_each_child("color", [control](const XML::gcXMLElement &xmlCol)
{
const std::string id = xmlCol.GetAtt("id");
const std::string val = xmlCol.GetText();
if (id.empty() || val.empty())
return;
auto col = control->findItem(id.c_str());
if (!col)
{
col = gcRefPtr<ThemeColorInfo>::create(id.c_str());
control->add(col);
}
col->color = Color(val.c_str());
});
});
}
示例8: LoadWeb
void Theme::LoadWeb(const UTIL::FS::Path& path, const XML::gcXMLElement &xmlEl)
{
gcString urlPath(path.getFolderPath());
for (size_t x=0; x<urlPath.size(); x++)
{
if (urlPath[x] == '\\')
urlPath[x] = '/';
}
xmlEl.for_each_child("page", [this, urlPath](const XML::gcXMLElement &xmlChild)
{
const std::string name = xmlChild.GetAtt("name");
const std::string val = xmlChild.GetText();
if (name.empty() || val.empty())
return;
std::string outVal = UTIL::STRING::sanitizeFileName(val);
#ifdef WIN32
gcString fullPath("file:///{0}/html/{1}", urlPath, outVal);
#else
gcString fullPath("file://{0}/html/{1}", urlPath, outVal);
#endif
auto web = WebList::findItem(name.c_str());
if (!web)
{
web = gcRefPtr<ThemeWebInfo>::create(name.c_str());
addItem(web);
}
web->path = fullPath;
});
}