本文整理汇总了C++中CXMLNode::CreateSubNode方法的典型用法代码示例。如果您正苦于以下问题:C++ CXMLNode::CreateSubNode方法的具体用法?C++ CXMLNode::CreateSubNode怎么用?C++ CXMLNode::CreateSubNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CXMLNode
的用法示例。
在下文中一共展示了CXMLNode::CreateSubNode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WriteToXMLNode
void CAccessControlListGroup::WriteToXMLNode ( CXMLNode* pNode )
{
assert ( pNode );
// Create the subnode for this
CXMLNode* pSubNode = pNode->CreateSubNode ( "group" );
assert ( pSubNode );
// Create attribute for the name and set it
CXMLAttribute* pAttribute = pSubNode->GetAttributes ().Create ( "name" );
pAttribute->SetValue ( m_strGroupName );
// Write the ACL's this group use
ACLsList::iterator iterACL = m_ACLs.begin ();
for ( ; iterACL != m_ACLs.end (); iterACL++ )
{
CAccessControlList* pACL = *iterACL;
// Create the subnode for this object and write the name attribute we generated
CXMLNode* pObjectNode = pSubNode->CreateSubNode ( "acl" );
pAttribute = pObjectNode->GetAttributes ().Create ( "name" );
pAttribute->SetValue ( pACL->GetName () );
}
// Write every object
ObjectList::iterator iter = m_Objects.begin ();
for ( ; iter != m_Objects.end (); iter++ )
{
CAccessControlListGroupObject* pObject = *iter;
// Find out the object type string
char szObjectType [255];
switch ( pObject->GetObjectType () )
{
case CAccessControlListGroupObject::OBJECT_TYPE_RESOURCE:
strcpy ( szObjectType, "resource" );
break;
case CAccessControlListGroupObject::OBJECT_TYPE_USER:
strcpy ( szObjectType, "user" );
break;
default:
strcpy ( szObjectType, "error" );
break;
}
// Append a dot append the name of the node
strcat ( szObjectType, "." );
strncat ( szObjectType, pObject->GetObjectName (), NUMELMS( szObjectType ) - 1 );
// Create the subnode for this object and write the name attribute we generated
CXMLNode* pObjectNode = pSubNode->CreateSubNode ( "object" );
pAttribute = pObjectNode->GetAttributes ().Create ( "name" );
pAttribute->SetValue ( szObjectType );
}
}
示例2: Save
bool CLocalServer::Save ( void )
{
if ( m_pConfig && m_pConfig->GetRootNode() )
{
StoreConfigValue ( "servername", ( m_pEditName->GetText().length() > 0 ) ? m_pEditName->GetText().c_str() : "MTA Local Server" );
StoreConfigValue ( "maxplayers", ( atoi ( m_pEditPlayers->GetText().c_str() ) ) ? m_pEditPlayers->GetText().c_str() : "32" );
StoreConfigValue ( "donotbroadcastlan", ( m_pBroadcastLan->IsActive () ) ? "0" : "1" );
StoreConfigValue ( "ase", ( m_pBroadcastInternet->IsActive () ) ? "1" : "0" );
StoreConfigValue ( "password", m_pEditPass->GetText().c_str() );
// Remove old resources from the config
CXMLNode* pRoot = m_pConfig->GetRootNode();
list < CXMLNode* > ::const_iterator iter = pRoot->ChildrenBegin ();
for ( ; iter != pRoot->ChildrenEnd (); iter++ )
{
CXMLNode* pNode = reinterpret_cast < CXMLNode* > ( *iter );
if ( pNode->GetTagName().compare ( "resource" ) == 0 )
{
pRoot->DeleteSubNode ( pNode );
iter = pRoot->ChildrenBegin ();
}
}
// Add new resources to the config
for ( int i = 0; i < m_pResourcesCur->GetRowCount(); i++ )
{
CXMLNode* pResourceNode = pRoot->CreateSubNode ( "resource" );
pResourceNode->GetAttributes().Create ( "src" )->SetValue ( m_pResourcesCur->GetItemText ( i, 1 ) );
pResourceNode->GetAttributes().Create ( "startup" )->SetValue ( "1" );
pResourceNode->GetAttributes().Create ( "protected" )->SetValue ( "0" );
}
m_pConfig->Write ();
}
return true;
}
示例3: XMLCreateChild
int CLuaFunctionDefs::XMLCreateChild ( lua_State* luaVM )
{
// Node name
CXMLNode* pNode = NULL;
SString strChild = "";
CScriptArgReader argStream ( luaVM );
argStream.ReadUserData ( pNode );
argStream.ReadString ( strChild );
if ( !argStream.HasErrors ( ) )
{
if ( pNode )
{
CXMLNode* pXMLSubNode = pNode->CreateSubNode ( strChild );
if ( pXMLSubNode )
{
lua_pushxmlnode ( luaVM, pXMLSubNode );
return 1;
}
}
}
else
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage() );
lua_pushboolean ( luaVM, false );
return 1;
}
示例4: 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());
}
示例5: StaticSaveServerIdMap
///////////////////////////////////////////////////////////////
//
// CServerIdManagerImpl::StaticSaveServerIdMap
//
//
//
///////////////////////////////////////////////////////////////
void CServerIdManagerImpl::StaticSaveServerIdMap ( void )
{
CXMLFile* pConfigFile = g_pCore->GetXML ()->CreateXML ( PathJoin ( g_pClientGame->GetFileCacheRoot(), MTA_SERVERID_LOOKUP_XML ) );
if ( !pConfigFile )
return;
pConfigFile->Reset ();
CXMLNode* pRoot = pConfigFile->GetRootNode ();
if ( !pRoot )
pRoot = pConfigFile->CreateRootNode ( "root" );
// Transfer each item from m_ServerIdMap into the file
for ( std::map < CServerIdKey, CServerIdInfo >::iterator it = ms_ServerIdMap.begin () ; it != ms_ServerIdMap.end () ; ++it )
{
const SString& strId = it->first.strId;
const SString& strDir = it->second.strDir;
CXMLNode* pSubNode = pRoot->CreateSubNode ( "id" );
pSubNode->SetTagContent ( strId );
pSubNode->GetAttributes().Create ( "dir" )->SetValue ( strDir );
}
pConfigFile->Write ();
delete pConfigFile;
}
示例6: 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 );
}
示例7:
_MEMBER_FUNCTION_IMPL(xml, createNode)
{
// Get the XML instance pointer
CXML * pXML = sq_getinstance< CXML* >( pVM );
// Is the xml instance valid?
if( pXML )
{
// Get the XML node pointer
CXMLNode * pNode = sq_getpointer< CXMLNode* >( pVM, 2 );
// Is the node valid?
if( pNode )
{
// Get the node name
const char * szName;
sq_getstring( pVM, 3, &szName );
// Create the node
CXMLNode * pNewNode = pNode->CreateSubNode( szName );
// Did the new node create?
if( pNewNode )
{
// Push the new node instance
sq_pushpointer< CXMLNode* >( pVM, pNewNode );
return 1;
}
}
}
sq_pushbool( pVM, false );
return 1;
}
示例8: 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 );
}
}
示例9: 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;
}
示例10: SaveBanList
void CBanManager::SaveBanList ( void )
{
// Create the XML file
CXMLFile* pFile = g_pServerInterface->GetXML ()->CreateXML ( m_strPath );
if ( pFile )
{
// create the root node again as you are outputting all the bans again not just new ones
CXMLNode* pRootNode = pFile->CreateRootNode ( "banlist" );
// Check it was created
if ( pRootNode )
{
// Iterate the ban list adding it to the XML tree
CXMLNode* pNode;
list < CBan* >::const_iterator iter = m_BanManager.begin ();
for ( ; iter != m_BanManager.end (); iter++ )
{
pNode = pRootNode->CreateSubNode ( "ban" );
if ( pNode )
{
SafeSetValue ( pNode, "nick", (*iter)->GetNick() );
SafeSetValue ( pNode, "ip", (*iter)->GetIP() );
SafeSetValue ( pNode, "serial", (*iter)->GetSerial() );
SafeSetValue ( pNode, "account", (*iter)->GetAccount() );
SafeSetValue ( pNode, "banner", (*iter)->GetBanner() );
SafeSetValue ( pNode, "reason", (*iter)->GetReason() );
SafeSetValue ( pNode, "time", ( unsigned int )(*iter)->GetTimeOfBan() );
if ( (*iter)->GetTimeOfUnban() > 0 )
{
SafeSetValue ( pNode, "unban", ( unsigned int )(*iter)->GetTimeOfUnban() );
}
}
}
// Write the XML file
pFile->Write ();
}
// Delete the file pointer
delete pFile;
}
}
示例11: 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
}
示例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: xmlCreateChild
int CLuaXMLDefs::xmlCreateChild ( lua_State* luaVM )
{
CXMLNode* pNode = nullptr;
SString strChildName;
CScriptArgReader argStream ( luaVM );
argStream.ReadUserData ( pNode );
argStream.ReadString ( strChildName );
if ( !argStream.HasErrors () )
{
CXMLNode* pXMLSubNode = pNode->CreateSubNode ( strChildName );
if ( pXMLSubNode )
{
lua_pushxmlnode ( luaVM, pXMLSubNode );
return 1;
}
}
else
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );
lua_pushboolean ( luaVM, false );
return 1;
}
示例14: SaveToXML
///////////////////////////////////////////////////////////////
//
// CJoystickManager::SaveToXML
//
// Save axes mapping for the current joypad.
//
///////////////////////////////////////////////////////////////
bool CJoystickManager::SaveToXML ( void )
{
if ( !IsJoypadValid () )
return false;
m_SettingsRevision++;
CXMLNode* pMainNode = GetConfigNode ( true );
// Add the current settings
if ( pMainNode )
{
// Clear our current bind nodes
pMainNode->DeleteAllSubNodes ();
{
// Create a new 'info' node
CXMLNode* pNode = pMainNode->CreateSubNode ( "info" );
// If it was created
if ( pNode )
{
CXMLAttributes* pAttributes = &pNode->GetAttributes ();
CXMLAttribute* pA = NULL;
pA = pAttributes->Create ( "deadzone" );
pA->SetValue ( m_DevInfo.iDeadZone );
pA = pAttributes->Create ( "saturation" );
pA->SetValue ( m_DevInfo.iSaturation );
pA = pAttributes->Create ( "product_name" );
pA->SetValue ( m_DevInfo.strProductName.c_str () );
}
}
// Iterate the binds adding them to the XML tree
for ( int i = 0 ; i < NUMELMS(m_currentMapping) ; i++ )
{
const SMappingLine& line = m_currentMapping[i];
// Create the new 'axis' node
CXMLNode* pNode = pMainNode->CreateSubNode ( "axis" );
// If it was created
if ( pNode )
{
CXMLAttributes* pAttributes = &pNode->GetAttributes ();
CXMLAttribute* pA = NULL;
pA = pAttributes->Create ( "source_index" );
pA->SetValue ( line.SourceAxisIndex );
pA = pAttributes->Create ( "source_dir" );
pA->SetValue ( line.SourceAxisDir );
pA = pAttributes->Create ( "output_index" );
pA->SetValue ( line.OutputAxisIndex );
pA = pAttributes->Create ( "output_dir" );
pA->SetValue ( line.OutputAxisDir );
pA = pAttributes->Create ( "enabled" );
pA->SetValue ( line.bEnabled );
pA = pAttributes->Create ( "max_value" );
pA->SetValue ( line.MaxValue );
}
}
return true;
}
return false;
}
示例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;
}