]> git.lizzy.rs Git - dragonfireclient.git/blob - src/script/lua_api/l_settings.h
cb0c09a734a9eb3122dd81989a652c90c53aa2ed
[dragonfireclient.git] / src / script / lua_api / l_settings.h
1 /*
2 Minetest
3 Copyright (C) 2013 PilzAdam <pilzadam@minetest.net>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #ifndef L_SETTINGS_H_
21 #define L_SETTINGS_H_
22
23 #include "lua_api/l_base.h"
24
25 class Settings;
26
27 class LuaSettings : public ModApiBase {
28 private:
29         static const char className[];
30         static const luaL_reg methods[];
31
32         // garbage collector
33         static int gc_object(lua_State* L);
34
35         // get(self, key) -> value
36         static int l_get(lua_State* L);
37
38         // get_bool(self, key) -> boolean
39         static int l_get_bool(lua_State* L);
40
41         // set(self, key, value)
42         static int l_set(lua_State* L);
43
44         // remove(self, key) -> success
45         static int l_remove(lua_State* L);
46
47         // get_names(self) -> {key1, ...}
48         static int l_get_names(lua_State* L);
49
50         // write(self) -> success
51         static int l_write(lua_State* L);
52
53         // to_table(self) -> {[key1]=value1,...}
54         static int l_to_table(lua_State* L);
55
56         Settings* m_settings;
57         std::string m_filename;
58
59 public:
60         LuaSettings(const char* filename);
61         ~LuaSettings();
62
63         // LuaSettings(filename)
64         // Creates an LuaSettings and leaves it on top of stack
65         static int create_object(lua_State* L);
66
67         static LuaSettings* checkobject(lua_State* L, int narg);
68
69         static void Register(lua_State* L);
70
71 };
72
73 #endif