lua_interpreter.h

Go to the documentation of this file.
00001 //    sampalib.org ESL library and tools
00002 //    Copyright (C) 2007  Thierry Grellier
00003 //
00004 //    This program is free software; you can redistribute it and/or modify
00005 //    it under the terms of the GNU General Public License version 2 as
00006 //    published by the Free Software Foundation.
00007 //
00008 //    This program is distributed in the hope that it will be useful,
00009 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011 //    GNU General Public License for more details.
00012 //
00013 //    You should have received a copy of the GNU General Public License along
00014 //    with this program; if not, write to the Free Software Foundation, Inc.,
00015 //    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00016 //
00017 //    contact: www.sampalib.org
00018 
00019 #ifndef SAMPA_LUA_INTERPRETER_H
00020 #define SAMPA_LUA_INTERPRETER_H
00021 
00022 #include "lua.hpp"
00023 #include "sampa/core/time.h"
00024 #include <string>
00025 
00026 namespace Sampa {
00027 
00028 class LuaInterpreter {
00029 public:
00030   LuaInterpreter(const std::string& init_script);
00031   ~LuaInterpreter();
00032   int  get_int   (const std::string& key, int& value) const;
00033   int  get_string(const std::string& key, std::string& value) const;
00034   int  get_bool  (const std::string& key, bool& value) const;
00035   int  get_time  (const std::string& key, Time& value) const;
00036   int  get_double(const std::string& key, double& value) const;
00037   int  get_size  (const std::string& key, int& value) const;
00038   int  get_hex   (const std::string& key, unsigned long long& value) const;
00039   bool set_int   (const std::string& key, const int& value) const;
00040   bool set_string(const std::string& key, const std::string& value) const;
00041   bool set_bool  (const std::string& key, const bool& value) const;
00042   bool set_double(const std::string& key, const double& value) const;
00043   bool set_time  (const std::string& key, const Time value) const;
00044   bool do_file (const std::string& key);
00045   lua_State* get_interpreter() { return L; }
00046 protected:
00047   bool reach(const std::string& key, bool create_when_absent) const;
00048   lua_State* L;
00049 };
00050 
00051 } // namespace Sampa
00052 
00053 #endif

Generated on Sat Feb 16 16:23:15 2008 for Sampa by  doxygen 1.5.3