Changeset 426 for trunk/src/lua


Ignore:
Timestamp:
07/17/15 13:39:31 (10 years ago)
Author:
epyon
Message:
  • lua table - get_string_hash_64
File:
1 edited

Legend:

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

    r406 r426  
    180180        lua_getfield( m_state, -1, element.data() );
    181181        bool result = !( lua_isnil( m_state, -1 ) );
     182        lua_pop( m_state, 1 );
     183        return result;
     184}
     185
     186uint64 nv::lua::table_guard::get_string_hash_64( string_view element, uint64 defval /*= 0 */ )
     187{
     188        lua_getfield( m_state, -1, element.data() );
     189        size_t l = 0;
     190        const char* str = nullptr;
     191        uint64 result = defval;
     192        if ( lua_type( m_state, -1 ) == LUA_TSTRING )
     193        {
     194                str = lua_tolstring( m_state, -1, &l );
     195                result = hash_string< uint64 >( str, l );
     196        }
    182197        lua_pop( m_state, 1 );
    183198        return result;
     
    253268        return result;
    254269}
    255 
    256270
    257271float nv::lua::table_guard::get_float( string_view element, float defval /*= 0.0 */ )
Note: See TracChangeset for help on using the changeset viewer.