Lua_icxx  1.02 (Aug 2011)
LuaStackCleaner.h
00001 /*
00002 This file is part of the Lua_icxx library. 
00003 Copyright 2010 (c) by Oliver Schoenborn. 
00004 License terms in LICENSE.txt.
00005 */
00006 
00007 #pragma once
00008 
00009 #include <lua.h>
00010 
00011 
00016 class LUA_ICXX_CPP_API
00017 LuaStackCleaner
00018 {
00019 public:
00021     LuaStackCleaner(lua_State* L): mLua(L), mStackTop(lua_gettop(L)) { assert(L); }
00023     ~LuaStackCleaner() { lua_settop(mLua, mStackTop); }
00025     bool willPop(int n) const { return n == (lua_gettop(mLua) - mStackTop); }
00027     int getStackLevelOrig() const { return mStackTop; }
00028 
00029 private:
00030     lua_State* mLua;
00031     int mStackTop;
00032 };
00033 
00034