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 
33 namespace Bagel {
34 
35 #define MAX_OPTION_LEN 100
36 
37 class COption : public CLList, public CBofObject {
38 public:
39  COption(const char *pszInit = nullptr);
40 
41  char _szBuf[MAX_OPTION_LEN];
42 };
43 
44 class CBofOptions : public CBofObject { // CCache
45 private:
51  COption *findSection(const char *pszSection);
52 
59  COption *findOption(const char *pszSection, const char *pszVar);
60 
66  bool readLine(Common::SeekableReadStream *pFile, char *pszBuf);
67 
68 protected:
69  char _szFileName[MAX_FNAME];
70  COption *_pOptionList;
71  bool _bDirty;
72 
73 public:
79  CBofOptions(const char *pszOptionsFile = nullptr);
80 
84  virtual ~CBofOptions();
85 
90  ErrorCode commit();
91 
98  ErrorCode loadOptionFile(const char *pszFile);
99 
100  const char *getFileName() const {
101  return ((const char *)_szFileName);
102  }
103 
111  ErrorCode writeSetting(const char *pszSection, const char *pszOption, const char *pszValue);
112 
120  ErrorCode writeSetting(const char *pszSection, const char *pszOption, int nValue);
121 
131  ErrorCode readSetting(const char *section, const char *option, char *stringValue, const char *defaultValue, uint32 nSize);
132 
141  ErrorCode readSetting(const char *section, const char *option, int *nValue, int defaultValue);
142 
151  ErrorCode readSetting(const char *section, const char *option, bool *boolValue, bool defaultValue);
152 
157  ErrorCode load();
158 
162  void release();
163 };
164 
165 } // namespace Bagel
166 
167 #endif
Definition: object.h:28
Definition: stream.h:745
Definition: options.h:37
Definition: options.h:44
Definition: bagel.h:31
Definition: llist.h:31