Lua_icxx  1.02 (Aug 2011)
LuaStackSizeChecker.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_icxx_export.h"
00010 #include <cassert>
00011 #include <lua.hpp>
00012 
00031 class // LUA_ICXX_CPP_API
00032 LuaStackSizeChecker
00033 {
00034 public:
00036     LuaStackSizeChecker(lua_State* lua)
00037         : mLua(lua), mStackTop( lua_gettop(mLua) ) { assert(mLua); }
00039     inline ~LuaStackSizeChecker() { checkNow(); }
00041     inline void checkNow() const { assert( mStackTop == lua_gettop(mLua) ); }
00042 
00043 private:
00044     lua_State * mLua;
00045     const int mStackTop;
00046 };