summaryrefslogtreecommitdiff
path: root/src/libluaglue
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2014-10-15 16:44:27 +0200
committerAndreas Baumann <mail@andreasbaumann.cc>2014-10-15 16:44:27 +0200
commit7c1364816bce2ecfad1ecc118225b1fa6f28faed (patch)
tree0a0232e53ed9ea50e0de07abb519455c07e24a14 /src/libluaglue
parentb37950fecfb3afb53942fba28e4e36d0b8753351 (diff)
downloadcrawler-7c1364816bce2ecfad1ecc118225b1fa6f28faed.tar.gz
crawler-7c1364816bce2ecfad1ecc118225b1fa6f28faed.tar.bz2
added getstringarray to luavm layer
Diffstat (limited to 'src/libluaglue')
-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;
+}