00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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 }
00052
00053 #endif