3 Copyright (C) 2013 PilzAdam <pilzadam@minetest.net>
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.
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.
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.
23 #include "lua_api/l_base.h"
27 class LuaSettings : public ModApiBase {
29 static const char className[];
30 static const luaL_reg methods[];
33 static int gc_object(lua_State* L);
35 // get(self, key) -> value
36 static int l_get(lua_State* L);
38 // get_bool(self, key) -> boolean
39 static int l_get_bool(lua_State* L);
41 // set(self, key, value)
42 static int l_set(lua_State* L);
44 // remove(self, key) -> success
45 static int l_remove(lua_State* L);
47 // get_names(self) -> {key1, ...}
48 static int l_get_names(lua_State* L);
50 // write(self) -> success
51 static int l_write(lua_State* L);
53 // to_table(self) -> {[key1]=value1,...}
54 static int l_to_table(lua_State* L);
57 std::string m_filename;
60 LuaSettings(const char* filename);
63 // LuaSettings(filename)
64 // Creates an LuaSettings and leaves it on top of stack
65 static int create_object(lua_State* L);
67 static LuaSettings* checkobject(lua_State* L, int narg);
69 static void Register(lua_State* L);