Пример #1
0
int CLuaXMLDefs::xmlDestroyNode ( lua_State* luaVM )
{
    // Verify the argument type
    if ( lua_type ( luaVM, 1 ) == LUA_TLIGHTUSERDATA )
    {
        // Get the Node
        CXMLNode* pXMLNode = lua_toxmlnode ( luaVM, 1 );
        if ( pXMLNode )
        {
            // Grab the parent so that we can delete this node from it
            CXMLNode* pParent = pXMLNode->GetParent ();
            if ( pParent )
            {
                // Delete it
                pParent->DeleteSubNode ( pXMLNode );

                // Return success
                lua_pushboolean ( luaVM, true );
                return 1;
            }
        }
    }
    else
        m_pScriptDebugging->LogBadType ( luaVM, "xmlDestroyNode" );

    lua_pushboolean ( luaVM, false );
    return 1;
}
Пример #2
0
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;
}
Пример #3
0
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;
}
Пример #4
0
///////////////////////////////////////////////////////////////
//
// 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;
}
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;
}
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;
}
Пример #7
0
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;
}
Пример #8
0
_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;
}
Пример #9
0
_MEMBER_FUNCTION_IMPL(xml, findNode)
{
    // 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 );

            // Find the node
            CXMLNode * pFoundNode = pNode->FindNode( szName );

            // Did we find the node?
            if( pFoundNode )
            {
                // Push the found node instance
                sq_pushpointer< CXMLNode* >( pVM, pFoundNode );
                return 1;
            }
        }
    }

    sq_pushbool( pVM, false );
    return 1;
}
Пример #10
0
int CLuaXMLDefs::xmlNodeGetAttributes ( lua_State* luaVM )
{
    // pNode, Attribute Name, [Buffer Size]
    if ( lua_type ( luaVM, 1 ) == LUA_TLIGHTUSERDATA )
    {
        CXMLNode* pNode = lua_toxmlnode ( luaVM, 1 );
        if ( pNode )
        {
            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->LogBadType ( luaVM, "xmlNodeGetAttributes" );
    }
    else
        m_pScriptDebugging->LogBadType ( luaVM, "xmlNodeGetAttributes" );

    lua_pushboolean ( luaVM, false );
    return 1;
}
Пример #11
0
int CLuaXMLDefs::xmlNodeGetName ( lua_State* luaVM )
{
    // xmlNode*, node name, index
    if ( lua_type ( luaVM, 1 ) != LUA_TLIGHTUSERDATA )
    {
        m_pScriptDebugging->LogBadType ( luaVM, "xmlNodeGetName" );

        lua_pushboolean ( luaVM, false );
        return 1;
    }
    else
    {
        CXMLNode* pNode = lua_toxmlnode ( luaVM, 1 );
        if ( pNode )
        {
            if ( pNode )
            {
                std::string strTagName;
                lua_pushstring ( luaVM, pNode->GetTagName ().c_str () );
                return 1;
            }
        }
    }

    lua_pushboolean ( luaVM, false );
    return 1;
}
Пример #12
0
int CLuaXMLDefs::xmlNodeSetValue ( lua_State* luaVM )
{
    // pNode, Value
    if ( lua_type ( luaVM, 1 ) != LUA_TLIGHTUSERDATA ||
         lua_type ( luaVM, 2 ) != LUA_TSTRING )
    {
        m_pScriptDebugging->LogBadType ( luaVM, "xmlNodeSetValue" );

        lua_pushboolean ( luaVM, false );
        return 1;
    }
    else
    {
        CXMLNode* pNode = lua_toxmlnode ( luaVM, 1 );
        if ( pNode )
        {
            const char * szTagContents = lua_tostring ( luaVM, 2 );
            pNode->SetTagContent ( szTagContents );
            lua_pushboolean ( luaVM, true );
            return 1;
        }
    }

    lua_pushboolean ( luaVM, false );
    return 1;
}
Пример #13
0
int CLuaXMLDefs::xmlNodeGetValue ( lua_State* luaVM )
{
    // pNode, [Buffer Size]
    int iSecondVariableType = lua_type ( luaVM, 2 );
    if ( lua_type ( luaVM, 1 ) != LUA_TLIGHTUSERDATA ||
        !( iSecondVariableType == LUA_TNONE || iSecondVariableType == LUA_TNUMBER ) )
    {
        m_pScriptDebugging->LogBadType ( luaVM, "xmlNodeGetValue" );

        lua_pushboolean ( luaVM, false );
        return 1;
    }
    else
    {
        CXMLNode* pNode = lua_toxmlnode ( luaVM, 1 );
        if ( pNode )
        {
            unsigned int iBufferSize = 1024;
            if ( iSecondVariableType == LUA_TNUMBER )
            {
                iBufferSize = static_cast < unsigned int > ( lua_tonumber ( luaVM, 2 ) );
                if ( iBufferSize > 1024 )
                    iBufferSize = 255;
            }
            lua_pushstring ( luaVM, pNode->GetTagContent ().c_str () );
            return 1;
        }
    }

    lua_pushboolean ( luaVM, false );
    return 1;
}
Пример #14
0
int CLuaXMLDefs::xmlNodeFindChild ( lua_State* luaVM )
{
    // xmlNode*, node name, index
    if ( lua_type ( luaVM, 1 ) != LUA_TLIGHTUSERDATA ||
         lua_type ( luaVM, 2 ) != LUA_TSTRING ||
         lua_type ( luaVM, 3 ) != LUA_TNUMBER )
    {
        m_pScriptDebugging->LogBadType ( luaVM, "xmlNodeFindChild" );

        lua_pushboolean ( luaVM, false );
        return 1;
    }
    else
    {
        CXMLNode* pNode = lua_toxmlnode ( luaVM, 1 );
        if ( pNode )
        {
            const char * szTagName = lua_tostring ( luaVM, 2 );
            unsigned int iIndex = static_cast < unsigned int > ( lua_tonumber ( luaVM, 3 ) );
            CXMLNode * pFoundNode = pNode->FindSubNode ( szTagName, iIndex );
            if ( pFoundNode )
            {
                lua_pushxmlnode ( luaVM, pFoundNode );
                return 1;
            }
        }
    }

    lua_pushboolean ( luaVM, false );
    return 1;
}
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;
}
Пример #16
0
_MEMBER_FUNCTION_IMPL(xml, setNodeValue)
{
    // 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 value
            const char * szValue;
            sq_getstring( pVM, 3, &szValue );

            // Set the node value
            pNode->SetValue( szValue );

            sq_pushbool( pVM, true );
            return 1;
        }
    }

    sq_pushbool( pVM, false );
    return 1;
}
int CLuaFunctionDefs::XMLNodeGetParent ( lua_State* luaVM )
{
    // xmlNode*, node name, index
    CXMLNode* pNode = NULL;
    CScriptArgReader argStream ( luaVM );
    argStream.ReadUserData ( pNode );

    if ( !argStream.HasErrors ( ) )
    {
        if ( pNode )
        {
            CXMLNode * pParent = pNode->GetParent ();
            if ( pParent )
            {
                lua_pushxmlnode ( luaVM, pParent );
                return 1;
            }
        }
    }
    else
        m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage() );

    lua_pushboolean ( luaVM, false );
    return 1;
}
Пример #18
0
_MEMBER_FUNCTION_IMPL(xml, getNodeAttribute)
{
    // 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 attribute name
            const char * szName;
            sq_getstring( pVM, 3, &szName );

            // Get the attribute value
            const char * szValue = pNode->GetAttribute( szName );

            sq_pushstring( pVM, szValue, strlen(szValue) );
            return 1;
        }
    }

    sq_pushbool( pVM, false );
    return 1;
}
Пример #19
0
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;
}
Пример #20
0
	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;
	}
Пример #21
0
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 "";
}
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;
}
Пример #23
0
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;
}
Пример #24
0
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;
}
Пример #25
0
int CLuaXMLDefs::xmlCreateChild ( lua_State* luaVM )
{
    // Node name
    if ( lua_type ( luaVM, 1 ) != LUA_TLIGHTUSERDATA ||
         lua_type ( luaVM, 2 ) != LUA_TSTRING )
    {
        m_pScriptDebugging->LogBadType ( luaVM, "xmlCreateChild" );

        lua_pushboolean ( luaVM, false );
        return 1;
    }
    else
    {
        // Get the Node
        CXMLNode* pXMLNode = lua_toxmlnode ( luaVM, 1 );
        if ( pXMLNode )
        {
            // Grab the subnode name
            const char* szSubNodeName = lua_tostring ( luaVM, 2 );
            if ( szSubNodeName )
            {
                CXMLNode* pXMLSubNode = pXMLNode->CreateSubNode ( szSubNodeName );
                if ( pXMLSubNode )
                {
                    lua_pushxmlnode ( luaVM, pXMLSubNode );
                    return 1;
                }
            }
        }
    }

    lua_pushboolean ( luaVM, false );
    return 1;
}
Пример #26
0
int CLuaXMLDefs::xmlDestroyNode ( lua_State* luaVM )
{
    // Verify the argument type
    CXMLNode* pNode = nullptr;
    CScriptArgReader argStream ( luaVM );
    argStream.ReadUserData ( pNode );

    if ( !argStream.HasErrors () )
    {
        // Grab the parent so that we can delete this node from it
        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;
}
Пример #27
0
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
Пример #28
0
//////////////////////////////////////////////////////////////////////
//
// Fetch multiple values for a named setting from the server config
//
//  <module src="module_test.dll" />
//  <resource src="admin" startup="1" protected="0" />
//
//////////////////////////////////////////////////////////////////////
bool CMainConfig::GetSettingTable ( const SString& strName, const char** szAttribNames, uint uiNumAttribNames, CLuaArguments* outTable )
{
    uint uiXMLIndex = 0;
    uint uiLuaIndex = 1;
    CXMLNode* pNode = NULL;
    do
    {
        // Grab the current script node
        pNode = m_pRootNode->FindSubNode ( strName, uiXMLIndex++ );
        if ( pNode )
        {
            CLuaArguments resultLine;
            CXMLAttributes& attributes = pNode->GetAttributes();
            for ( uint i = 0 ; i < attributes.Count() ; i++ )
            {
                CXMLAttribute* pAttribute = attributes.Get( i );
                resultLine.PushString( pAttribute->GetName() );
                resultLine.PushString( pAttribute->GetValue() );
            }

            if ( resultLine.Count() != 0 )
            {
                outTable->PushNumber( uiLuaIndex++ );
                outTable->PushTable( &resultLine );
            }
        }
    }
    while( pNode );

    return outTable->Count() != 0;
}
/*
const irr::c8 *CXMLRegistry::getValueAsCharCStr(const wchar_t *index, const wchar_t *context) {
	irr::core::stringc temp;
	temp = getValueAsCStr(index,context);
	return (const irr::c8 *)temp.c_str();

}
*/
const wchar_t *CXMLRegistry::getValueAsCStr(const wchar_t *index, const wchar_t *context) {
	CXMLNode *targetNode;
	targetNode = resolveContext(context);
	if(!targetNode) return 0;
	targetNode = targetNode->findChildByName(index);
	if(!targetNode) return 0;
	return targetNode->getValue();
}
bool CXMLRegistry::setValue(const wchar_t *index, const wchar_t * txtval, const wchar_t *context) {
	CXMLNode *targetNode;
	targetNode = resolveContext(context);
	if(!targetNode) return false;
	targetNode = targetNode->findChildByName(index);
	if(!targetNode) return false;
	targetNode->setValue(txtval);
	return true;
}