ScummVM API documentation
options.h
1
2/* ScummVM - Graphic Adventure Engine
3 *
4 * ScummVM is the legal property of its developers, whose names
5 * are too numerous to list here. Please refer to the COPYRIGHT
6 * file distributed with this source distribution.
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 *
21 */
22
23#ifndef BAGEL_BOFLIB_OPTIONS_H
24#define BAGEL_BOFLIB_OPTIONS_H
25
26#include "common/stream.h"
27
28#include "bagel/boflib/stdinc.h"
29#include "bagel/boflib/llist.h"
30#include "bagel/boflib/object.h"
31#include "bagel/boflib/error.h"
32
33namespace Bagel {
34namespace SpaceBar {
35
36#define MAX_OPTION_LEN 100
37
38class COption : public CLList, public CBofObject {
39public:
40 COption(const char *pszInit = nullptr);
41
42 char _szBuf[MAX_OPTION_LEN];
43};
44
45class CBofOptions : public CBofObject { // CCache
46private:
52 COption *findSection(const char *pszSection);
53
60 COption *findOption(const char *pszSection, const char *pszVar);
61
67 bool readLine(Common::SeekableReadStream *pFile, char *pszBuf);
68
69protected:
70 char _szFileName[MAX_FNAME];
71 COption *_pOptionList;
72 bool _bDirty;
73
74public:
80 CBofOptions(const char *pszOptionsFile = nullptr);
81
85 virtual ~CBofOptions();
86
91 ErrorCode commit();
92
99 ErrorCode loadOptionFile(const char *pszFile);
100
101 const char *getFileName() const {
102 return ((const char *)_szFileName);
103 }
104
112 ErrorCode writeSetting(const char *pszSection, const char *pszOption, const char *pszValue);
113
121 ErrorCode writeSetting(const char *pszSection, const char *pszOption, int nValue);
122
132 ErrorCode readSetting(const char *section, const char *option, char *stringValue, const char *defaultValue, uint32 nSize);
133
142 ErrorCode readSetting(const char *section, const char *option, int *nValue, int defaultValue);
143
152 ErrorCode readSetting(const char *section, const char *option, bool *boolValue, bool defaultValue);
153
158 ErrorCode load();
159
163 void release();
164};
165
166} // namespace SpaceBar
167} // namespace Bagel
168
169#endif
Definition: object.h:28
Definition: llist.h:31
Definition: options.h:45
ErrorCode readSetting(const char *section, const char *option, char *stringValue, const char *defaultValue, uint32 nSize)
CBofOptions(const char *pszOptionsFile=nullptr)
Loads specified .INI file which contains user options.
ErrorCode readSetting(const char *section, const char *option, int *nValue, int defaultValue)
ErrorCode writeSetting(const char *pszSection, const char *pszOption, int nValue)
ErrorCode readSetting(const char *section, const char *option, bool *boolValue, bool defaultValue)
ErrorCode writeSetting(const char *pszSection, const char *pszOption, const char *pszValue)
ErrorCode loadOptionFile(const char *pszFile)
Loads and builds Option list.
Definition: options.h:38
Definition: stream.h:745