Ignore:
Timestamp:
07/31/14 08:08:31 (11 years ago)
Author:
epyon
Message:
  • lua::table_guard is_* utility functions
  • minor tweaks
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lua/lua_state.cc

    r288 r296  
    209209        return result;
    210210}
     211
     212bool nv::lua::table_guard::is_table( const std::string& element )
     213{
     214        lua_getfield( m_state, -1, element.c_str() );
     215        bool result = lua_type( m_state, -1 ) == LUA_TTABLE;
     216        lua_pop( m_state, 1 );
     217        return result;
     218}
     219
     220bool nv::lua::table_guard::is_number( const std::string& element )
     221{
     222        lua_getfield( m_state, -1, element.c_str() );
     223        bool result = lua_type( m_state, -1 ) == LUA_TNUMBER;
     224        lua_pop( m_state, 1 );
     225        return result;
     226}
     227
     228bool nv::lua::table_guard::is_boolean( const std::string& element )
     229{
     230        lua_getfield( m_state, -1, element.c_str() );
     231        bool result = lua_type( m_state, -1 ) == LUA_TBOOLEAN;
     232        lua_pop( m_state, 1 );
     233        return result;
     234}
     235
     236bool nv::lua::table_guard::is_string( const std::string& element )
     237{
     238        lua_getfield( m_state, -1, element.c_str() );
     239        bool result = lua_type( m_state, -1 ) == LUA_TSTRING;
     240        lua_pop( m_state, 1 );
     241        return result;
     242}
     243
    211244
    212245// state
Note: See TracChangeset for help on using the changeset viewer.