LuaState.hpp

Go to the documentation of this file.
00001 /******************************************************************************\
00002 * LuaState                                                                     *
00003 * A pleasant way to use a Lua state in C++.                                    *
00004 *                                                                              *
00005 *                                                                              *
00006 * Copyright (C) 2005-2007 by Leandro Motta Barros.                             *
00007 *                                                                              *
00008 * Permission is hereby granted, free of charge, to any person obtaining a copy *
00009 * of this software and associated documentation files (the "Software"), to     *
00010 * deal in the Software without restriction, including without limitation the   *
00011 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or  *
00012 * sell copies of the Software, and to permit persons to whom the Software is   *
00013 * furnished to do so, subject to the following conditions:                     *
00014 *                                                                              *
00015 * The above copyright notice and this permission notice shall be included in   *
00016 * all copies or substantial portions of the Software.                          *
00017 *                                                                              *
00018 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR   *
00019 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,     *
00020 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE *
00021 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER       *
00022 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING      *
00023 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS *
00024 * IN THE SOFTWARE.                                                             *
00025 \******************************************************************************/
00026 
00027 
00028 #ifndef _DILUCULUM_LUA_STATE_HPP_
00029 #define _DILUCULUM_LUA_STATE_HPP_
00030 
00031 #include <lua.hpp>
00032 #include <string>
00033 #include <vector>
00034 #include <Diluculum/LuaExceptions.hpp>
00035 #include <Diluculum/LuaValue.hpp>
00036 #include <Diluculum/LuaVariable.hpp>
00037 #include <Diluculum/Types.hpp>
00038 
00039 
00040 namespace Diluculum
00041 {
00042 
00050    class LuaState
00051    {
00052       public:
00060          explicit LuaState (bool loadStdLib = true);
00061 
00073          explicit LuaState (lua_State* state, bool loadStdLib = false);
00074 
00078          virtual ~LuaState();
00079 
00091          LuaValueList doFile (const std::string& fileName)
00092          { return doStringOrFile (false, fileName); }
00093 
00105          LuaValueList doString (const std::string& what)
00106          { return doStringOrFile (true, what); }
00107 
00118          LuaVariable operator[] (const std::string& variable);
00119 
00121          lua_State* getState() { return state_; }
00122 
00123       private:
00138          LuaValueList doStringOrFile (bool isString, const std::string& str);
00139 
00141          lua_State* state_;
00142 
00146          const bool ownsState_;
00147 
00165          void throwOnLuaError (int retCode);
00166    };
00167 
00168 } // namespace Diluculum
00169 
00170 #endif // #ifndef _DILUCULUM_LUA_STATE_HPP_

Generated on Tue Feb 6 09:30:26 2007 for Diluculum by  doxygen 1.4.6