diff options
author | Andreas Baumann <mail@andreasbaumann.cc> | 2014-10-16 13:28:44 +0200 |
---|---|---|
committer | Andreas Baumann <mail@andreasbaumann.cc> | 2014-10-16 13:28:44 +0200 |
commit | ff403df10813717698dc47e0b22f19d62c007cff (patch) | |
tree | 3edd435fd2f6ec6a433a6ab41de87ba63dff2bbd | |
parent | 09dbbdcd142d3538858cbd086fa57d2d4f04bc07 (diff) | |
download | crawler-ff403df10813717698dc47e0b22f19d62c007cff.tar.gz crawler-ff403df10813717698dc47e0b22f19d62c007cff.tar.bz2 |
added getInt to LuaVm
-rwxr-xr-x | include/luaglue/LuaVM.hpp | 1 | ||||
-rw-r--r-- | src/libluaglue/LuaVM.cpp | 12 |
2 files changed, 13 insertions, 0 deletions
diff --git a/include/luaglue/LuaVM.hpp b/include/luaglue/LuaVM.hpp index 81261f3..6055fd4 100755 --- a/include/luaglue/LuaVM.hpp +++ b/include/luaglue/LuaVM.hpp @@ -27,6 +27,7 @@ class LuaVM LUAGLUE_DLL_VISIBLE std::string getString( const std::string &key ); LUAGLUE_DLL_VISIBLE std::vector<std::string> getStringArray( const std::string &key ); + LUAGLUE_DLL_VISIBLE int getInt( const std::string &key ); LUAGLUE_DLL_VISIBLE bool getBoolean( const std::string &key ); LUAGLUE_DLL_VISIBLE lua_State *handle( ); diff --git a/src/libluaglue/LuaVM.cpp b/src/libluaglue/LuaVM.cpp index 566e516..9764707 100644 --- a/src/libluaglue/LuaVM.cpp +++ b/src/libluaglue/LuaVM.cpp @@ -262,6 +262,18 @@ string LuaVM::getString( const string &key ) return res; } +int LuaVM::getInt( const std::string &key ) +{ + int n = findValue( key ); + + int res = lua_tointeger( m_lua, -1 ); + lua_pop( m_lua, n ); + + //dumpStack( ); + + return res; +} + bool LuaVM::getBoolean( const string &key ) { int n = findValue( key ); |