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


C++ CScriptArgReader::ReadStringTable方法代码示例

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


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

示例1: RequestBrowserDomains

int CLuaFunctionDefs::RequestBrowserDomains ( lua_State* luaVM )
{
//  bool requestBrowserDomains ( table domains, bool isURL )
    std::vector<SString> pages; bool bIsURL;

    CScriptArgReader argStream ( luaVM );
    argStream.ReadStringTable ( pages );
    argStream.ReadBool ( bIsURL, false );

    if ( !argStream.HasErrors () )
    {
        // Convert to domains if we got a list of URLs
        if ( bIsURL )
        {
            for ( auto& strURL : pages )
            {
                strURL = g_pCore->GetWebCore ()->GetDomainFromURL ( strURL );
            }
        }

        g_pCore->GetWebCore ()->RequestPages ( pages );
        // Todo: Add a callback or event to check if the pagerequest dialog was successfully done
        lua_pushboolean ( luaVM, true );
        return 1;
    }
    else
        m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );

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

示例2: RequestBrowserDomains

int CLuaFunctionDefs::RequestBrowserDomains ( lua_State* luaVM )
{
//  bool requestBrowserDomains ( table domains, bool isURL [, function callback ] )
    std::vector<SString> pages; bool bIsURL; CLuaFunctionRef callbackFunction;

    CScriptArgReader argStream ( luaVM );
    argStream.ReadStringTable ( pages );
    argStream.ReadBool ( bIsURL, false );
    argStream.ReadFunction ( callbackFunction, LUA_REFNIL );
    argStream.ReadFunctionComplete ();

    if ( !argStream.HasErrors () )
    {
        // Convert to domains if we got a list of URLs
        if ( bIsURL )
        {
            for ( auto& strURL : pages )
            {
                strURL = g_pCore->GetWebCore ()->GetDomainFromURL ( strURL );
            }
        }

        WebRequestCallback callback = [=]( bool bAllow, const std::vector<SString>& domains ) {
            // Test if luaVM is still available
            if ( m_pLuaManager->IsLuaVMValid ( luaVM ) && VERIFY_FUNCTION ( callbackFunction ) )
            {
                CLuaMain* pLuaMain = m_pLuaManager->GetVirtualMachine ( luaVM );
                if ( !pLuaMain )
                    return;

                CLuaArguments arguments;
                arguments.PushBoolean ( bAllow );
                
                CLuaArguments LuaTable;
                int i = 0;
                for ( const auto& domain : domains )
                {
                    LuaTable.PushNumber ( ++i );
                    LuaTable.PushString ( domain );
                }
                arguments.PushTable ( &LuaTable );
                arguments.Call ( pLuaMain, callbackFunction );
            }
        };

        g_pCore->GetWebCore ()->RequestPages ( pages, VERIFY_FUNCTION ( callbackFunction ) ? &callback : nullptr );
        lua_pushboolean ( luaVM, true );
        return 1;
    }
    else
        m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );

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


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