config.h

main 67 lines · 2.2 KB Raw
Alex Alex Commit Client Upload Part 2 19/10/2026 00:06
1/*
2 * Copyright (c) 2010-2017 OTClient <https://github.com/edubart/otclient>
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 * THE SOFTWARE.
21 */
22
23#ifndef CONFIG_H
24#define CONFIG_H
25
26#include "declarations.h"
27
28#include <framework/luaengine/luaobject.h>
29#include <framework/otml/declarations.h>
30
31// @bindclass
32class Config : public LuaObject
33{
34public:
35 Config();
36
37 bool load(const std::string& file);
38 bool unload();
39 bool save();
40 void clear();
41
42 void setValue(const std::string& key, const std::string& value);
43 void setList(const std::string& key, const std::vector<std::string>& list);
44 std::string getValue(const std::string& key);
45 std::vector<std::string> getList(const std::string& key);
46
47 void setNode(const std::string& key, const OTMLNodePtr& node);
48 void mergeNode(const std::string& key, const OTMLNodePtr& node);
49 OTMLNodePtr getNode(const std::string& key);
50 int getNodeSize(const std::string& key);
51
52 bool exists(const std::string& key);
53 void remove(const std::string& key);
54
55 std::string getFileName();
56 bool isLoaded();
57
58 // @dontbind
59 ConfigPtr asConfig() { return static_self_cast<Config>(); }
60
61private:
62 std::string m_fileName;
63 OTMLDocumentPtr m_confsDoc;
64};
65
66#endif
67
Top