本文整理汇总了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;
}
示例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;
}