当前位置: 首页>>代码示例>>C++>>正文


C++ CXMLNode类代码示例

本文整理汇总了C++中CXMLNode的典型用法代码示例。如果您正苦于以下问题:C++ CXMLNode类的具体用法?C++ CXMLNode怎么用?C++ CXMLNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CXMLNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: argStream

int CLuaXMLDefs::xmlDestroyNode ( lua_State* luaVM )
{
    CXMLNode* pNode;
    SString strSubNodeName;
        
    CScriptArgReader argStream ( luaVM );
    argStream.ReadUserData ( pNode );

    if ( !argStream.HasErrors () )
    {
        CXMLNode* pParent = pNode->GetParent ();
        if ( pParent )
        {
            // Delete it
            pParent->DeleteSubNode ( pNode );

            // Return success
            lua_pushboolean ( luaVM, true );
            return 1;
        }
    }
    else
        m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );
    
    lua_pushboolean ( luaVM, false );
    return 1;
}
开发者ID:Jusonex,项目名称:mtasa-awesomium,代码行数:27,代码来源:CLuaXMLDefs.cpp

示例2: xmlNodeGetAttributes

int CLuaXMLDefs::xmlNodeGetAttributes ( lua_State* luaVM )
{  
    CXMLNode* pNode;
        
    CScriptArgReader argStream ( luaVM );
    argStream.ReadUserData ( pNode );

    if ( !argStream.HasErrors () )
    {
        lua_newtable ( luaVM );
        list < class CXMLAttribute * > ::iterator iter = pNode->GetAttributes().ListBegin();
        for ( ; iter != pNode->GetAttributes().ListEnd() ; ++iter )
        {
            lua_pushstring ( luaVM, ( *iter )->GetName().c_str () );
            lua_pushstring ( luaVM, ( *iter )->GetValue().c_str () );
            lua_settable ( luaVM, -3 );
        }
        return 1;
    }
    else
        m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );

    lua_pushboolean ( luaVM, false );
    return 1;
}
开发者ID:Jusonex,项目名称:mtasa-awesomium,代码行数:25,代码来源:CLuaXMLDefs.cpp

示例3: PathJoin

///////////////////////////////////////////////////////////////
//
// 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;
}
开发者ID:AdiBoy,项目名称:mtasa-blue,代码行数:32,代码来源:CServerIdManager.cpp

示例4: Evaluate

const CValue* CXMLBoundValueChildNode::Evaluate(_IN SCFXML::CXMLNode& rCurrent) const
{
	if (BoundValueChildNode_pValue) { delete BoundValueChildNode_pValue; BoundValueChildNode_pValue = nullptr; }

	if (rCurrent.Type() == XmlElement)
	{
		CXMLNode* pChild = ((CXMLElement&)rCurrent).ChildFirst();
		while (pChild)
		{
			if (pChild->Name() == m_Name)
			{
				UINT uiCharsParsed = 0;

				CString valueString = pChild->Value() ? pChild->Value()->ToString() : "";

				BoundValueChildNode_pValue = &CValue::Parse(valueString, &uiCharsParsed);

				for (UINT i = uiCharsParsed; i < valueString.Length(); i++)
				{
					if (!CharIsWhiteSpace(valueString[i])) {

						if (BoundValueChildNode_pValue) { delete BoundValueChildNode_pValue; BoundValueChildNode_pValue = nullptr; }

						BoundValueChildNode_pValue = new STRING_RETURN(valueString); 
					}
				}

				return BoundValueChildNode_pValue;
			}
		}
	}

	return nullptr;
}
开发者ID:rjadroncik,项目名称:Shadow-Common-Files,代码行数:34,代码来源:BoundValueChildNode.cpp

示例5: argStream

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;
}
开发者ID:Jusonex,项目名称:mtasa-awesomium,代码行数:27,代码来源:CLuaFunctionDefs.XML.cpp

示例6: SaveServerList

bool CServerBrowser::SaveServerList ( CXMLNode* pNode, std::string strTagName, CServerList *pList )
{
    if ( !pNode )
        return false;

    // Start by clearing out all previous nodes
    pNode->DeleteAllSubNodes ();

    // Iterate through the list, adding any items to our node
    CServerListIterator i, i_b = pList->IteratorBegin (), i_e = pList->IteratorEnd ();
    int j = 0;
    int k = pList->GetServerCount ();
    if ( k > 0 )
    {
        for ( CServerListIterator i = i_b; i != i_e; i++ )
        {
            CServerListItem * pServer = *i;

            // Add the item to the node
            CXMLNode * pSubNode = pNode->CreateSubNode ( strTagName.c_str () );
            if ( pSubNode )
            {
                CXMLAttribute* pHostAttribute = pSubNode->GetAttributes ().Create ( "host" );
				pHostAttribute->SetValue ( pServer->strHost.c_str () );
                
                CXMLAttribute* pPortAttribute = pSubNode->GetAttributes ().Create ( "port" );
				pPortAttribute->SetValue ( pServer->usGamePort );
            }
            j++;
        }
    }
    return true;
}
开发者ID:AdiBoy,项目名称:multitheftauto,代码行数:33,代码来源:CServerBrowser.cpp

示例7: _MEMBER_FUNCTION_IMPL

_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;
}
开发者ID:hopk1nz,项目名称:maf2mp,代码行数:34,代码来源:CXMLNatives.cpp

示例8: XMLNodeGetAttributes

int CLuaFunctionDefs::XMLNodeGetAttributes ( lua_State* luaVM )
{
    // pNode, Attribute Name, [Buffer Size]
    CXMLNode* pNode = NULL;
    CScriptArgReader argStream ( luaVM );
    argStream.ReadUserData ( pNode );

    if ( !argStream.HasErrors ( ) )
    {
        if ( pNode )
        {
            lua_newtable ( luaVM );
            unsigned int uiIndex = 0;
            list < CXMLAttribute * > ::iterator iter = pNode->GetAttributes ().ListBegin ();
            for ( ; iter != pNode->GetAttributes ().ListEnd () ; iter++ )
            {
                lua_pushstring ( luaVM, ( *iter )->GetName ().c_str () );
                lua_pushstring ( luaVM, ( *iter )->GetValue ().c_str () );
                lua_settable ( luaVM, -3 );
            }
            return 1;
        }
        else
            m_pScriptDebugging->LogBadType ( luaVM );
    }
    else
        m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage() );

    lua_pushboolean ( luaVM, false );
    return 1;
}
开发者ID:Jusonex,项目名称:mtasa-awesomium,代码行数:31,代码来源:CLuaFunctionDefs.XML.cpp

示例9: LoadServerList

bool CServerBrowser::LoadServerList ( CXMLNode* pNode, std::string strTagName, CServerList *pList )
{
    CXMLNode* pSubNode = NULL;
    in_addr Address;
    int iPort;

    if ( !pNode )
        return false;

    // Loop through all subnodes looking for relevant nodes
    unsigned int uiCount = pNode->GetSubNodeCount ();
    for ( unsigned int i = 0; i < uiCount; i++ )
    {
        pSubNode = pNode->GetSubNode ( i );
        if ( pSubNode && pSubNode->GetTagName ().compare ( strTagName ) == 0 )
        {
            // This node is relevant, so get the attributes we need and add it to the list
            CXMLAttribute* pHostAttribute = pSubNode->GetAttributes ().Find ( "host" );
            CXMLAttribute* pPortAttribute = pSubNode->GetAttributes ().Find ( "port" );
            if ( pHostAttribute && pPortAttribute ) {
                if ( CServerListItem::Parse ( pHostAttribute->GetValue ().c_str (), Address ) )
                {
                    iPort = atoi ( pPortAttribute->GetValue ().c_str () ) + SERVER_LIST_QUERY_PORT_OFFSET;
                    if ( iPort > 0 )
                        pList->Add ( CServerListItem ( Address, iPort ) );
                }
            }
        }
    }
    pList->SetUpdated ( true );
    return true;
}
开发者ID:AdiBoy,项目名称:multitheftauto,代码行数:32,代码来源:CServerBrowser.cpp

示例10: GetPrototypeXML

	CGameObject* CFactory::InstantiatePrototype(const string &AProtoName, const string &AName /*= ""*/)
	{
		CXMLNode *xml = GetPrototypeXML(AProtoName);
		if (!xml)
		{
			Log("ERROR", "Can't create prototype instance: no such prototype: '%s'", AProtoName.c_str());
			return NULL;
		}

		CGameObject *result = New<CGameObject>(AName);

		if (AName.empty())
			result->SetName(AProtoName + itos(result->GetID()));

		result->Prototype = true;
		result->Deserialize(xml);

		SetRecursionLimit(AProtoName, from_string<int>(xml->SafeGetAttribute("RecursionLimit", "-1")));

		TraversePrototypeNode(xml, result, result);

		result->FinalizeCreation();

		Log("INFO", "Prototype INSTANTIATED: '%s', instance name: '%s'", AProtoName.c_str(), result->GetName().c_str());

		return result;
	}
开发者ID:rotanov,项目名称:deku2d-engine,代码行数:27,代码来源:2de_Factory.cpp

示例11: 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 "";
}
开发者ID:AdiBoy,项目名称:multitheftauto,代码行数:29,代码来源:CServerBrowser.cpp

示例12: XMLNodeSetName

int CLuaFunctionDefs::XMLNodeSetName ( lua_State* luaVM )
{
    CXMLNode* pNode = NULL;
    SString strTagName = "";
    CScriptArgReader argStream ( luaVM );
    argStream.ReadUserData ( pNode );
    argStream.ReadString ( strTagName );

    if ( !argStream.HasErrors ( ) )
    {
        if ( pNode )
        {
            pNode->SetTagName ( strTagName );
            lua_pushboolean ( luaVM, true );
            return 1;
        }
        else
            m_pScriptDebugging->LogBadPointer ( luaVM, "xml-node", 1 );
    }
    else
        m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage() );

    lua_pushboolean ( luaVM, false );
    return 1;
}
开发者ID:Jusonex,项目名称:mtasa-awesomium,代码行数:25,代码来源:CLuaFunctionDefs.XML.cpp

示例13: xmlNodeGetAttribute

int CLuaXMLDefs::xmlNodeGetAttribute ( lua_State* luaVM )
{
    CXMLNode* pNode = nullptr;
    SString strAttributeName = "";
    CScriptArgReader argStream ( luaVM );
    argStream.ReadUserData ( pNode );
    argStream.ReadString ( strAttributeName );

    if ( !argStream.HasErrors () )
    {
        // Find the attribute with that name
        CXMLAttribute * pAttribute = pNode->GetAttributes ().Find ( strAttributeName );
        if ( pAttribute )
        {
            // Read the attribute and return the string
            lua_pushstring ( luaVM, pAttribute->GetValue ().c_str () );
            return 1;
        }
    }
    else
        m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );

    lua_pushboolean ( luaVM, false );
    return 1;
}
开发者ID:qaisjp,项目名称:mtasa-blue,代码行数:25,代码来源:CLuaXMLDefs.cpp

示例14: argStream

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;
}
开发者ID:qaisjp,项目名称:mtasa-blue,代码行数:26,代码来源:CLuaXMLDefs.cpp

示例15: GetRGBA

int CXMLConfig::GetRGBA(CXMLNode* pParent, const char* szKey, unsigned char& R, unsigned char& G, unsigned char& B, unsigned char& A)
{
    int Status = INVALID_VALUE;
    int iR, iG, iB, iA;

    // Grab the XML node
    CXMLNode* pNode = pParent->FindSubNode(szKey);
    if (pNode)
    {
        char          cDelimiter;
        istringstream iss;

        std::string strValue;
        strValue = pNode->GetTagContent();

        try
        {
            iss >> iR >> cDelimiter >> iG >> cDelimiter >> iB >> cDelimiter >> iA;
            R = iR;
            G = iG;
            B = iB;
            A = iA;
            Status = IS_SUCCESS;
        }
        catch (std::ios::failure e)
        {
        }
    }
    else
开发者ID:ccw808,项目名称:mtasa-blue,代码行数:29,代码来源:CXMLConfig.cpp


注:本文中的CXMLNode类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。