summaryrefslogtreecommitdiff
path: root/src/libluaglue/LuaVM.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/libluaglue/LuaVM.cpp')
-rw-r--r--src/libluaglue/LuaVM.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/libluaglue/LuaVM.cpp b/src/libluaglue/LuaVM.cpp
index 637f668..04027af 100644
--- a/src/libluaglue/LuaVM.cpp
+++ b/src/libluaglue/LuaVM.cpp
@@ -273,3 +273,31 @@ bool LuaVM::getBoolean( const string &key )
return res;
}
+
+vector<string> LuaVM::getStringArray( const string &key )
+{
+ vector<string> res;
+
+ int n = findValue( key );
+
+ if( !lua_istable( m_lua, -1 ) ) {
+ lua_pop( m_lua, n );
+ ostringstream ss;
+ ss << "key '" << key << "' refers not to a table";
+ throw runtime_error( ss.str( ) );
+ }
+
+ //dumpStack( );
+
+ lua_pushvalue( m_lua, -1 );
+ lua_pushnil( m_lua );
+ while( lua_next( m_lua, -2 ) ) {
+ res.push_back( lua_tostring( m_lua, -1 ) );
+ lua_pop( m_lua, 1 );
+ }
+ lua_pop( m_lua, 1 );
+
+ lua_pop( m_lua, n );
+
+ return res;
+}