本文整理汇总了C++中CXMLNode::FindSubNode方法的典型用法代码示例。如果您正苦于以下问题:C++ CXMLNode::FindSubNode方法的具体用法?C++ CXMLNode::FindSubNode怎么用?C++ CXMLNode::FindSubNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CXMLNode
的用法示例。
在下文中一共展示了CXMLNode::FindSubNode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadListsFromXML
void CWebCore::LoadListsFromXML ( bool bWhitelist, bool bBlacklist, bool bCustomLists )
{
if ( !m_pXmlConfig )
return;
CXMLNode* pRootNode = m_pXmlConfig->GetRootNode ();
if ( !pRootNode )
return;
if ( bWhitelist )
{
CXMLNode* pWhiteSubNode = pRootNode->FindSubNode ( "globalwhitelist" );
if ( pWhiteSubNode )
{
for ( std::list<CXMLNode*>::iterator iter = pWhiteSubNode->ChildrenBegin (); iter != pWhiteSubNode->ChildrenEnd (); ++iter )
{
AddAllowedPage ( (*iter)->GetTagContent (), eWebFilterType::WEBFILTER_DYNAMIC );
}
}
}
if ( bBlacklist )
{
CXMLNode* pBlackSubNode = pRootNode->FindSubNode ( "globalblacklist" );
if ( pBlackSubNode )
{
for ( std::list<CXMLNode*>::iterator iter = pBlackSubNode->ChildrenBegin (); iter != pBlackSubNode->ChildrenEnd (); ++iter )
{
AddBlockedPage ( (*iter)->GetTagContent (), eWebFilterType::WEBFILTER_DYNAMIC );
}
}
}
if ( bCustomLists )
{
CXMLNode* pBlackSubNode = pRootNode->FindSubNode ( "customblacklist" );
if ( pBlackSubNode )
{
for ( std::list<CXMLNode*>::iterator iter = pBlackSubNode->ChildrenBegin (); iter != pBlackSubNode->ChildrenEnd (); ++iter )
{
AddBlockedPage ( (*iter)->GetTagContent (), eWebFilterType::WEBFILTER_USER );
}
}
CXMLNode* pWhiteSubNode = pRootNode->FindSubNode ( "customwhitelist" );
if ( pWhiteSubNode )
{
for ( std::list<CXMLNode*>::iterator iter = pWhiteSubNode->ChildrenBegin (); iter != pWhiteSubNode->ChildrenEnd (); ++iter )
{
AddAllowedPage ( (*iter)->GetTagContent (), eWebFilterType::WEBFILTER_USER );
}
}
}
}
示例2: SetServerPassword
void CServerBrowser::SetServerPassword ( std::string strHost, std::string strPassword )
{
CXMLNode* pConfig = CCore::GetSingletonPtr ()->GetConfig ();
CXMLNode* pServerPasswords = pConfig->FindSubNode ( CONFIG_NODE_SERVER_SAVED );
if ( !pServerPasswords )
{
pServerPasswords = pConfig ->CreateSubNode ( CONFIG_NODE_SERVER_SAVED );
}
//Check if the server password already exists
for ( unsigned int i = 0 ; i < pServerPasswords->GetSubNodeCount() ; i++ )
{
CXMLAttributes* pAttributes = &(pServerPasswords->GetSubNode(i)->GetAttributes());
if ( pAttributes->Find( "host" ) )
{
if ( CXMLAttribute* pHost = pAttributes->Find ( "host" ) )
{
std::string strXMLHost = pHost->GetValue();
if ( strXMLHost == strHost )
{
CXMLAttribute* pPassword = pAttributes->Create( "password" );
pPassword->SetValue(strPassword.c_str());
return;
}
}
}
}
// Otherwise create the node from scratch
CXMLNode* pNode = pServerPasswords->CreateSubNode( "server" );
CXMLAttribute* pHostAttribute = pNode->GetAttributes().Create ( "host" );
pHostAttribute->SetValue(strHost.c_str());
CXMLAttribute* pPasswordAttribute = pNode->GetAttributes().Create ( "password" );
pPasswordAttribute->SetValue(strPassword.c_str());
}
示例3: WriteCustomList
void CWebCore::WriteCustomList ( const SString& strListName, const std::vector<SString>& customList, bool bReset )
{
if ( !m_pXmlConfig || !MakeSureXMLNodesExist () )
return;
CXMLNode* pRootNode = m_pXmlConfig->GetRootNode ();
if ( !pRootNode )
return;
CXMLNode* pCustomListNode = pRootNode->FindSubNode ( strListName );
if ( !pCustomListNode )
return;
pCustomListNode->DeleteAllSubNodes();
for ( std::vector<SString>::const_iterator iter = customList.begin (); iter != customList.end (); ++iter )
{
CXMLNode* pNode = pCustomListNode->CreateSubNode ( "url" );
if ( pNode )
pNode->SetTagContent ( *iter );
}
// Write custom blacklist and reload from XML
m_pXmlConfig->Write ();
if ( bReset )
ResetFilter ( false );
}
示例4: xmlNodeFindChild
int CLuaXMLDefs::xmlNodeFindChild ( lua_State* luaVM )
{
CXMLNode* pNode;
SString strTagName;
unsigned int uiIndex;
CScriptArgReader argStream ( luaVM );
argStream.ReadUserData ( pNode );
argStream.ReadString ( strTagName );
argStream.ReadNumber ( uiIndex );
if ( !argStream.HasErrors () )
{
CXMLNode * pFoundNode = pNode->FindSubNode ( strTagName, uiIndex );
if ( pFoundNode )
{
lua_pushxmlnode ( luaVM, pFoundNode );
return 1;
}
}
else
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );
lua_pushboolean ( luaVM, false );
return 1;
}
示例5: GetServerPassword
std::string CServerBrowser::GetServerPassword ( std::string strHost )
{
CXMLNode* pConfig = CCore::GetSingletonPtr ()->GetConfig ();
CXMLNode* pServerPasswords = pConfig->FindSubNode ( CONFIG_NODE_SERVER_SAVED );
if ( !pServerPasswords )
{
pServerPasswords = pConfig ->CreateSubNode ( CONFIG_NODE_SERVER_SAVED );
}
//Check if the server password already exists
for ( unsigned int i = 0 ; i < pServerPasswords->GetSubNodeCount() ; i++ )
{
CXMLAttributes* pAttributes = &(pServerPasswords->GetSubNode(i)->GetAttributes());
if ( pAttributes->Find( "host" ) )
{
if ( CXMLAttribute* pHost = pAttributes->Find ( "host" ) )
{
std::string strXMLHost = pHost->GetValue();
if ( strXMLHost == strHost )
{
CXMLAttribute* pPassword = pAttributes->Create( "password" );
std::string strPassword = pPassword->GetValue();
return strPassword;
}
}
}
}
return "";
}
示例6: UpdateListsFromMaster
bool CWebCore::UpdateListsFromMaster ()
{
if ( !m_pXmlConfig )
return false;
CXMLNode* pRootNode = m_pXmlConfig->GetRootNode ();
if ( !pRootNode || !MakeSureXMLNodesExist () )
return false;
// Fetch white- and blacklist revision from config
CXMLNode* pWhiteRevNode = pRootNode->FindSubNode ( "whitelistrev" );
if ( !pWhiteRevNode || !pWhiteRevNode->GetTagContent ( m_iWhitelistRevision ) )
{
m_iWhitelistRevision = 0;
}
CXMLNode* pBlackRevNode = pRootNode->FindSubNode ( "blacklistrev" );
if ( !pBlackRevNode || !pBlackRevNode->GetTagContent ( m_iBlacklistRevision ) )
{
m_iBlacklistRevision = 0;
}
// Get last update timestamp and compare with current time
CXMLNode* pLastUpdateNode = pRootNode->FindSubNode ( "lastupdate" );
if ( pLastUpdateNode )
{
SString lastUpdateTime = pLastUpdateNode->GetTagContent ();
time_t currentTime;
time ( ¤tTime );
if ( lastUpdateTime < SString ( "%d", (long long)currentTime - BROWSER_LIST_UPDATE_INTERVAL ) )
{
#ifdef MTA_DEBUG
OutputDebugLine ( "Updating white- and blacklist..." );
#endif
g_pCore->GetNetwork ()->GetHTTPDownloadManager ( EDownloadModeType::WEBBROWSER_LISTS )->QueueFile ( SString("%s?type=getrev", BROWSER_UPDATE_URL),
NULL, 0, NULL, 0, false, this, &CWebCore::StaticFetchRevisionProgress, false, 3 );
pLastUpdateNode->SetTagContent ( SString ( "%d", (long long)currentTime ) );
m_pXmlConfig->Write ();
}
}
return true;
}
示例7: StaticFetchBlacklistProgress
bool CWebCore::StaticFetchBlacklistProgress ( double dDownloadNow, double dDownloadTotal, char* pCompletedData, size_t completedLength, void *pObj, bool bComplete, int iError )
{
if ( !bComplete )
return false;
CWebCore* pWebCore = static_cast < CWebCore* > ( pObj );
if ( !pWebCore->m_pXmlConfig )
return false;
if ( !pWebCore->MakeSureXMLNodesExist () )
return false;
CXMLNode* pRootNode = pWebCore->m_pXmlConfig->GetRootNode ();
std::vector<SString> blacklist;
SString strData = pCompletedData;
strData.Split ( ";", blacklist );
CXMLNode* pListNode = pRootNode->FindSubNode ( "globalblacklist" );
if ( !pListNode )
return false;
pListNode->DeleteAllSubNodes ();
for ( std::vector<SString>::const_iterator iter = blacklist.begin (); iter != blacklist.end (); ++iter )
{
CXMLNode* pNode = pListNode->CreateSubNode ( "url" );
pNode->SetTagContent ( *iter );
}
// Set blacklist revision
CXMLNode* pNode = pRootNode->FindSubNode ( "blacklistrev" );
if ( !pNode )
return false;
pNode->SetTagContent ( pWebCore->m_iBlacklistRevision );
// Write changes to the XML file
pWebCore->m_pXmlConfig->Write ();
pWebCore->LoadListsFromXML ( false, true, false );
#ifdef MTA_DEBUG
OutputDebugLine ( "Updated browser blacklist!" );
#endif
return true;
}
示例8: ClearServerPasswords
void CServerBrowser::ClearServerPasswords ()
{
CXMLNode* pConfig = CCore::GetSingletonPtr ()->GetConfig ();
CXMLNode* pServerPasswords = pConfig->FindSubNode ( CONFIG_NODE_SERVER_SAVED );
if ( pServerPasswords )
{
pServerPasswords->DeleteAllSubNodes();
pConfig->DeleteSubNode ( pServerPasswords );
}
}
示例9: Load
bool CLocalServer::Load ( void )
{
// Get server module root
SString strServerPath = CalcMTASAPath( PathJoin ( "server", "mods", "deathmatch" ) );
m_pConfig = g_pCore->GetXML ()->CreateXML ( PathJoin ( strServerPath, m_strConfig ) );
if ( m_pConfig && m_pConfig->Parse() )
{
CXMLNode* pRoot = m_pConfig->GetRootNode();
CXMLNode* pServerName = pRoot->FindSubNode ( "servername", 0 );
if ( pServerName ) m_pEditName->SetText ( pServerName->GetTagContent().c_str() );
CXMLNode* pServerPass = pRoot->FindSubNode ( "password", 0 );
if ( pServerPass ) m_pEditPass->SetText ( pServerPass->GetTagContent().c_str() );
CXMLNode* pServerPlayers = pRoot->FindSubNode ( "maxplayers", 0 );
if ( pServerPlayers ) m_pEditPlayers->SetText ( pServerPlayers->GetTagContent().c_str() );
// Read the startup resources
list < CXMLNode* > ::const_iterator iter = pRoot->ChildrenBegin ();
for ( ; iter != pRoot->ChildrenEnd (); iter++ )
{
CXMLNode* pNode = reinterpret_cast < CXMLNode* > ( *iter );
if ( pNode->GetTagName ().compare ( "resource" ) == 0 )
{
CXMLAttribute* src = pNode->GetAttributes().Find ( "src" );
if ( src && src->GetValue()[1] )
{
m_pResourcesCur->SetItemText ( m_pResourcesCur->AddRow (), m_hResourcesCur, src->GetValue().c_str() );
}
}
}
}
// Get list of resource names
std::vector < SString > resourceNameList;
GetResourceNameList ( resourceNameList, strServerPath );
// Put resource names into the GUI
for ( std::vector < SString >::iterator iter = resourceNameList.begin () ; iter != resourceNameList.end () ; ++iter )
HandleResource ( *iter );
return true;
}
示例10: StaticFetchWhitelistFinished
void CWebCore::StaticFetchWhitelistFinished ( char* pCompletedData, size_t completedLength, void *pObj, bool bSuccess, int iErrorCode )
{
if ( !bSuccess )
return;
CWebCore* pWebCore = static_cast < CWebCore* > ( pObj );
if ( !pWebCore->m_pXmlConfig )
return;
if ( !pWebCore->MakeSureXMLNodesExist () )
return;
CXMLNode* pRootNode = pWebCore->m_pXmlConfig->GetRootNode ();
std::vector<SString> whitelist;
SString strData = pCompletedData;
strData.Split ( ";", whitelist );
CXMLNode* pListNode = pRootNode->FindSubNode ( "globalwhitelist" );
if ( !pListNode )
return;
pListNode->DeleteAllSubNodes ();
for ( std::vector<SString>::const_iterator iter = whitelist.begin (); iter != whitelist.end (); ++iter )
{
CXMLNode* pNode = pListNode->CreateSubNode ( "url" );
pNode->SetTagContent ( *iter );
}
// Set whitelist revision
CXMLNode* pNode = pRootNode->FindSubNode ( "whitelistrev" );
if ( !pNode )
return;
pNode->SetTagContent ( pWebCore->m_iWhitelistRevision );
// Write changes to the XML file
pWebCore->m_pXmlConfig->Write ();
pWebCore->LoadListsFromXML ( true, false, false );
#ifdef MTA_DEBUG
OutputDebugLine ( "Updated whitelist!" );
#endif
}
示例11: StoreConfigValue
void CLocalServer::StoreConfigValue ( const char* szNode, const char* szValue )
{
CXMLNode* pRoot = m_pConfig->GetRootNode();
CXMLNode* pNode = pRoot->FindSubNode ( szNode, 0 );
if ( pNode )
{
pNode->SetTagContent ( szValue );
}
else
{
pNode = pRoot->CreateSubNode ( szNode );
pNode->SetTagContent ( szValue );
}
}
示例12: Load
bool CClientVariables::Load ( void )
{
// Get the root node
CXMLNode *pRoot = CCore::GetSingleton ().GetConfig ();
if ( !pRoot )
return false;
m_iRevision++;
// Load the cvars
m_pStorage = pRoot->FindSubNode ( CONFIG_NODE_CVARS );
if ( !m_pStorage ) {
// Non-existant, create a new node
m_pStorage = pRoot->CreateSubNode ( CONFIG_NODE_CVARS );
}
// Verify that at least all the defaults are in
LoadDefaults ();
return true;
}
示例13: InitNewsItemList
////////////////////////////////////////////////////
//
// CNewsBrowser::InitNewsItemList
//
//
//
////////////////////////////////////////////////////
void CNewsBrowser::InitNewsItemList(void)
{
m_NewsitemList.clear();
// Find all sub-directories in 'news' directory
SString strAllNewsDir = PathJoin(GetMTADataPath(), "news");
std::vector<SString> directoryList = FindFiles(strAllNewsDir + "\\*", false, true);
std::sort(directoryList.begin(), directoryList.end());
// Get news settings
SString strOldestPost;
uint uiMaxHistoryLength;
GetVersionUpdater()->GetNewsSettings(strOldestPost, uiMaxHistoryLength);
// Process each sub-directory
for (uint i = 0; i < directoryList.size(); i++)
{
SString strItemDir = directoryList[directoryList.size() - 1 - i];
if (strItemDir < strOldestPost)
continue; // Post too old
if (m_NewsitemList.size() >= uiMaxHistoryLength)
continue; // Post count too high
SNewsItem newsItem;
newsItem.strContentFullDir = PathJoin(strAllNewsDir, strItemDir);
// Get filenames from XML file
CXMLFile* pFile = g_pCore->GetXML()->CreateXML(PathJoin(newsItem.strContentFullDir, "files.xml"));
if (pFile)
{
pFile->Parse();
CXMLNode* pRoot = pFile->GetRootNode();
if (pRoot)
{
// Headline text
CXMLNode* pHeadline = pRoot->FindSubNode("headline", 0);
if (pHeadline)
newsItem.strHeadline = pHeadline->GetTagContent();
// Date text
CXMLNode* pDate = pRoot->FindSubNode("date", 0);
if (pDate)
newsItem.strDate = pDate->GetTagContent();
else
newsItem.strHeadline.Split(" - ", &newsItem.strHeadline, &newsItem.strDate, true);
// Layout filename
CXMLNode* pLayout = pRoot->FindSubNode("layout", 0);
if (pLayout)
newsItem.strLayoutFilename = pLayout->GetTagContent();
// Imageset filenames
CXMLNode* pImages = pRoot->FindSubNode("imagesetlist", 0);
if (pImages)
for (uint i = 0; i < pImages->GetSubNodeCount(); i++)
newsItem.imagesetFilenameList.push_back(pImages->GetSubNode(i)->GetTagContent());
}
delete pFile;
}
// Add to news item list if valid
if (!newsItem.strHeadline.empty() && !newsItem.strLayoutFilename.empty())
m_NewsitemList.push_back(newsItem);
}
}
示例14: GetConfigNode
///////////////////////////////////////////////////////////////
//
// CJoystickManager::GetConfigNode
//
// Get the main node for load/saving data for the current joypad.
//
///////////////////////////////////////////////////////////////
CXMLNode* CJoystickManager::GetConfigNode ( bool bCreateIfRequired )
{
// Get the root node
CXMLNode *pRoot = CCore::GetSingleton ().GetConfig ();
if ( !pRoot )
return NULL;
// Get the top joypad config node
CXMLNode* pSectionNode = pRoot->FindSubNode ( CONFIG_NODE_JOYPAD );
if ( !pSectionNode )
{
if ( !bCreateIfRequired )
return NULL;
// Non-existant, create a new node
pSectionNode = pRoot->CreateSubNode ( CONFIG_NODE_JOYPAD );
}
// Get the node for this joystick's GUID
CXMLNode* pItemNode = NULL;
// Find existing node
for( int i=0; true; i++ )
{
CXMLNode* pNode = pSectionNode->FindSubNode ( "product", i );
if ( !pNode )
break;
CXMLAttributes* pAttributes = &pNode->GetAttributes ();
if ( CXMLAttribute* pA = pAttributes->Find ( "guid" ) )
{
string value = pA->GetValue ();
if ( value == m_DevInfo.strGuid )
{
pItemNode = pNode;
break;
}
}
}
if ( !pItemNode )
{
if ( !bCreateIfRequired )
return NULL;
// Non-existant, create a new node
pItemNode = pSectionNode->CreateSubNode ( "product" );
if ( pItemNode )
{
CXMLAttributes* pAttributes = &pItemNode->GetAttributes ();
CXMLAttribute* pA = NULL;
pA = pAttributes->Create ( "guid" );
pA->SetValue ( m_DevInfo.strGuid.c_str () );
}
}
return pItemNode;
}
示例15: MakeSureXMLNodesExist
bool CWebCore::MakeSureXMLNodesExist ()
{
// Check xml file
if ( !m_pXmlConfig )
{
SString browserDataPath = CalcMTASAPath ( MTA_BROWSERDATA_PATH );
bool exists = FileExists ( browserDataPath );
m_pXmlConfig = g_pCore->GetXML ()->CreateXML ( browserDataPath );
if ( !m_pXmlConfig || ( exists && !m_pXmlConfig->Parse () ) )
return false;
}
CXMLNode* pRootNode = m_pXmlConfig->GetRootNode ();
if ( !pRootNode )
{
pRootNode = m_pXmlConfig->CreateRootNode ( "browserdata" );
if ( !pRootNode )
return false;
}
if ( !pRootNode->FindSubNode ( "lastupdate" ) )
{
CXMLNode* pNode = pRootNode->CreateSubNode ( "lastupdate" );
if ( !pNode )
return false;
pNode->SetTagContent ( 0 );
}
if ( !pRootNode->FindSubNode ( "whitelistrev" ) )
{
if ( !pRootNode->CreateSubNode ( "whitelistrev" ) )
return false;
}
if ( !pRootNode->FindSubNode ( "blacklistrev" ) )
{
if ( !pRootNode->CreateSubNode ( "blacklistrev" ) )
return false;
}
if ( !pRootNode->FindSubNode ( "globalwhitelist" ) )
{
if ( !pRootNode->CreateSubNode ( "globalwhitelist" ) )
return false;
}
if ( !pRootNode->FindSubNode ( "globalblacklist" ) )
{
if ( !pRootNode->CreateSubNode ( "globalblacklist" ) )
return false;
}
if ( !pRootNode->FindSubNode ( "customblacklist" ) )
{
if ( !pRootNode->CreateSubNode ( "customblacklist" ) )
return false;
}
if ( !pRootNode->FindSubNode ( "customwhitelist" ) )
{
if ( !pRootNode->CreateSubNode ( "customwhitelist" ) )
return false;
}
return true;
}