本文整理汇总了C++中xml::gcXMLElement类的典型用法代码示例。如果您正苦于以下问题:C++ gcXMLElement类的具体用法?C++ gcXMLElement怎么用?C++ gcXMLElement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了gcXMLElement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: platformFilter
bool User::platformFilter(const XML::gcXMLElement &platform, PlatformType type)
{
if (!platform.IsValid())
return true;
uint32 id = 0;
platform.GetAtt("id", id);
if (id == 0)
return true;
#ifdef WIN32
return (id != 100);
#elif defined NIX
if (type == PT_Tool)
return (id != 110 && id != 120);
#ifdef NIX64
if (id == 120)
return false;
#endif
//linux will have windows and nix
return (id != 110); //id != 100 &&
#else
return true;
#endif
}
示例2: parseMod
void InstalledWizardThread::parseMod(DesuraId parId, DesuraId id, const XML::gcXMLElement &mod, gcRefPtr<WildcardManager> &pWildCard, const XML::gcXMLElement &info)
{
gcString name = mod.GetChild("name");
if (name == "" && info.IsValid())
name = info.GetChild("name");
if (name == "")
return;
if (m_bTriggerNewEvent)
onNewItemEvent(name);
triggerProgress();
m_uiDone++;
UserCore::Misc::InstallInfo temp(id, parId);
try
{
temp.loadXmlData(mod, pWildCard);
if (m_bTriggerNewEvent)
onModFound(temp);
}
catch (gcException &except)
{
Warning("ItemWizard: Error in xml parsing (installed wizard, mods): {0}\n", except);
}
}
示例3: processInstallScript
void BranchInfo::processInstallScript(const XML::gcXMLElement &xmlElement)
{
uint32 crc = 0;
xmlElement.GetAtt("crc", crc);
if (UTIL::FS::isValidFile(m_szInstallScript))
{
if (crc != 0 && m_uiInstallScriptCRC == (uint32)crc)
return;
}
else
{
m_szInstallScript = UTIL::OS::getAppDataPath(gcWString(L"{0}\\{1}\\install_script.js", m_ItemId.getFolderPathExtension(), getBranchId()).c_str());
}
gcString base64 = xmlElement.GetText();
try
{
UTIL::FS::recMakeFolder(UTIL::FS::Path(m_szInstallScript, "", true));
UTIL::FS::FileHandle fh(m_szInstallScript.c_str(), UTIL::FS::FILE_WRITE);
UTIL::STRING::base64_decode(base64, [&fh](const unsigned char* data, uint32 size) -> bool
{
fh.write((const char*)data, size);
return true;
});
m_uiInstallScriptCRC = crc;
}
catch (gcException &e)
{
Warning("Failed to save install script for {0} branch {1}: {2}\n", m_ItemId.toInt64(), m_uiBranchId, e);
m_szInstallScript = "";
}
}
示例4: parseItemsQuick
void InstalledWizardThread::parseItemsQuick(const XML::gcXMLElement &fNode)
{
if (!fNode.IsValid())
return;
auto platforms = fNode.FirstChildElement("platforms");
if (platforms.IsValid())
{
platforms.for_each_child("platform", [&](const XML::gcXMLElement &platform)
{
if (isStopped())
return;
if (getUserCore()->platformFilter(platform, PlatformType::Item))
return;
parseItemsQuick(platform);
});
}
else
{
fNode.FirstChildElement("games").for_each_child("game", [&](const XML::gcXMLElement &game)
{
if (isStopped())
return;
const std::string id = game.GetAtt("siteareaid");
DesuraId gameId(id.c_str(), "games");
if (gameId.isOk())
parseGameQuick(game);
});
}
}
示例5: 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);
}
示例6: gameId
void InstalledWizardThread::parseItems1(const XML::gcXMLElement &fNode, gcRefPtr<WildcardManager> &pWildCard, std::map<uint64, XML::gcXMLElement> *vMap)
{
gcAssert(pWildCard);
if (!fNode.IsValid())
return;
fNode.FirstChildElement("games").for_each_child("game", [&](const XML::gcXMLElement &game)
{
if (isStopped())
return;
const std::string szId = game.GetAtt("siteareaid");
DesuraId gameId(szId.c_str(), "games");
if (!gameId.isOk())
return;
XML::gcXMLElement info;
if (vMap)
info = (*vMap)[gameId.toInt64()];
parseGame(gameId, game, pWildCard, info);
});
}
示例7: parseGameQuick
void InstalledWizardThread::parseGameQuick(const XML::gcXMLElement &game)
{
if (!game.IsValid())
return;
m_uiTotal++;
game.FirstChildElement("mods").for_each_child("mod", [&](const XML::gcXMLElement &)
{
m_uiTotal++;
});
}
示例8: loadXmlData
void InstallInfo::loadXmlData(const XML::gcXMLElement &xmlNode, WildcardManager* pWildCard)
{
WildcardManager lwc(pWildCard);
auto wcNode = xmlNode.FirstChildElement("wcards");
if (wcNode.IsValid())
{
lwc.parseXML(wcNode);
}
xmlNode.GetChild("name", m_szName);
auto icsNode = xmlNode.FirstChildElement("settings").FirstChildElement("installlocations");
if (!icsNode.IsValid())
return;
icsNode.for_each_child("installlocation", [&](const XML::gcXMLElement &xmlChild)
{
if (m_bInstalled)
return;
const std::string path = xmlChild.GetChild("path");
const std::string check = xmlChild.GetChild("check");
if (path.empty() || check.empty())
return;
char* CheckRes = nullptr;
char* PathRes = nullptr;
try
{
lwc.constructPath(check.c_str(), &CheckRes);
lwc.constructPath(path.c_str(), &PathRes);
if (CheckRes && PathRes && UTIL::FS::isValidFile(UTIL::FS::PathWithFile(CheckRes)))
{
m_szPath = PathRes;
m_bInstalled = true;
}
}
catch (gcException &e)
{
Debug(gcString("InstallInfo: Error parsing wildcards for installInfo: {0}\n", e));
}
safe_delete(CheckRes);
safe_delete(PathRes);
});
}
示例9: 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;
}
示例10: 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 (...)
{
}
});
}
示例11: 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;
}
示例12: 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());
});
});
}
示例13: 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;
});
}
示例14: 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());
});
});
}
示例15: 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;
});
}