-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathIniConfigParser.html
More file actions
266 lines (264 loc) · 5.88 KB
/
IniConfigParser.html
File metadata and controls
266 lines (264 loc) · 5.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
<!DOCTYPE html>
<html>
<head>
<title>Project Artemis</title>
<link rel="stylesheet" type="text/css" href="/printfonts/print.css" media="print" />
<link rel="stylesheet" type="text/css" href="/webfonts/fonts.css" media="screen" />
<link href="/css/site.css" rel="stylesheet" />
</head>
<body>
<header>
…
</header>
<section>
<h1 id="artemis-iniconfigparser-user-guide">
Artemis IniConfigParser – User Guide
</h1>
<p>
<strong>Module:</strong> IniConfigParser.Mod<br />
<strong>Project:</strong> Artemis Standard Library Extensions
</p>
<hr />
<h2 id="overview">
Overview
</h2>
<p>
The <code>IniConfigParser</code> module provides a type-aware parser and
writer for INI configuration files in Oberon-07. It is designed for
integration with Artemis project, supporting automatic type detection,
sectioned configuration, error handling, and config saving.
</p>
<hr />
<h2 id="features">
Features
</h2>
<ul>
<li>
<strong>Automatic Type Detection:</strong>
<ul>
<li>
Unquoted values are parsed as INTEGER, REAL, BOOLEAN (TRUE/FALSE), or
STRING.
</li>
<li>
Quoted values are always treated as strings.
</li>
</ul>
</li>
<li>
<strong>Section Support:</strong>
<ul>
<li>
Case-sensitive section names.
</li>
<li>
Keys outside any section are placed in a default section.
</li>
</ul>
</li>
<li>
<strong>API Procedures:</strong>
<ul>
<li>
<code>LoadConfig</code>: Loads and parses an INI file.
</li>
<li>
<code>GetSection</code>: Retrieves a section by name.
</li>
<li>
<code>GetValue</code>: Retrieves a value by key and section.
</li>
<li>
<code>GetDefaultValue</code>: Retrieves a value from the default
section.
</li>
<li>
<code>GetType</code>: Returns the detected type of a value.
</li>
<li>
<code>SetValue</code>/<code>SetDefaultValue</code>: Set or update values
in the config.
</li>
<li>
<code>SaveConfig</code>: Saves the configuration back to an INI file.
</li>
<li>
<code>GetError</code>/<code>GetErrorLine</code>: Retrieve error codes
and line numbers for diagnostics.
</li>
<li>
<code>FreeConfig</code>: Frees all resources used by a config object.
</li>
</ul>
</li>
<li>
<strong>Error Handling:</strong>
<ul>
<li>
All major procedures return error codes for robust error reporting.
</li>
</ul>
</li>
<li>
<strong>Integration:</strong>
<ul>
<li>
Uses Artemis Collections (ArrayList, Dictionary) for internal storage.
</li>
<li>
Designed for Oberon-07 language constraints.
</li>
</ul>
</li>
</ul>
<hr />
<h2 id="usage-example">
Usage Example
</h2>
<pre class="oberon"><code>MODULE ExampleIniConfigParser;
IMPORT IniConfigParser, Out;
VAR
config: IniConfigParser.Config;
err: INTEGER;
value: IniConfigParser.ConfigValuePtr;
valueType: INTEGER;
ok: BOOLEAN;
BEGIN
err := IniConfigParser.LoadConfig("settings.ini", config);
IF err = IniConfigParser.NoError THEN
ok := IniConfigParser.GetValue(config, "Database", "port", value);
IF ok THEN
valueType := IniConfigParser.GetType(value);
IF valueType = IniConfigParser.IntegerType THEN
Out.String("Port: "); Out.Int(ORD(value.value[0]), 0); Out.Ln
END
END;
(* Set a value and save *)
IniConfigParser.SetValue(config, "Database", "host", "localhost");
IniConfigParser.SaveConfig(config, "settings-out.ini")
ELSE
Out.String("Failed to load config, error code: "); Out.Int(err, 0); Out.Ln
END;
IniConfigParser.FreeConfig(config)
END ExampleIniConfigParser.</code></pre>
<hr />
<h2 id="limitations">
Limitations
</h2>
<ul>
<li>
Only fixed-size arrays are supported (Oberon-07 constraint).
</li>
<li>
<strong>Maximum token/key/section name length:</strong> 256 characters
(see <code>IniConfigTokenizer.MaxTokenLength</code>).
</li>
<li>
<strong>Maximum value length:</strong> 512 characters (see
<code>ConfigValue.value</code>).
</li>
<li>
<strong>Maximum number of sections/keys:</strong> Limited by available
memory; internally uses <code>ArrayList</code> and
<code>Dictionary</code> which dynamically allocate as needed, but are
subject to system memory limits.
</li>
<li>
No nested sections or multiline values.
</li>
<li>
Comments must start at the beginning of a line with a semicolon
(<code>;</code>).
</li>
<li>
Section and key names are case-sensitive.
</li>
<li>
Value interpolation and advanced INI features are not supported.
</li>
<li>
Type detection is simple and may not handle all edge cases.
</li>
<li>
<strong>Maximum INI file size:</strong> Limited by available system
memory and Oberon-07 implementation.
</li>
</ul>
<hr />
<h2 id="integration-notes">
Integration Notes
</h2>
<ul>
<li>
Uses <code>Files</code> for I/O and
<code>Dictionary</code>/<code>ArrayList</code> from Artemis Collections.
</li>
<li>
See <code>IniConfigParserTest.Mod</code> and
<code>examples/ExampleIniConfigParser.Mod</code> for more usage examples
and tests.
</li>
<li>
Documentation is generated with <code>obncdoc</code> and available in
<code>obncdoc/IniConfigParser.def</code>.
</li>
</ul>
<hr />
<h2 id="see-also">
See Also
</h2>
<ul>
<li>
<a href="./Collections.md">Artemis Collections API</a>
</li>
<li>
<a
href="./examples/ExampleIniConfigParser.Mod">ExampleIniConfigParser.Mod</a>
</li>
<li>
<a href="./IniConfigParserTest.Mod">IniConfigParserTest.Mod</a>
</li>
</ul>
<hr />
<p>
© 2025 Artemis Project. BSD 3-Clause License.
</p>
</section>
<nav>
<ul>
<li>
<a href="/">Home</a>
</li>
<li>
<a href="./">README</a>
</li>
<li>
<a href="license.html">LICENSE</a>
</li>
<li>
<a href="install.html">INSTALL</a>
</li>
<li>
<a href="./obnc/">OBNC Modules</a>
</li>
<li>
<a href="./oxford/">Obc-3 Modules</a>
</li>
<li>
<a href="./ofrontplus/">Ofront+ Modules</a>
</li>
<li>
<a href="./development-notes.html">development notes</a>
</li>
<li>
<a href="https://github.com/rsdoiel/Artemis">Github</a>
</li>
</ul>
</nav>
<footer>
copyright (c) 2021 all rights reserved.
Released under the BSD 3-Clause license
See: http://opensource.org/licenses/BSD-3-Clause
</footer>
</body>
</html>