author | František Kučera <franta-hg@frantovo.cz> |
Fri, 27 Nov 2020 16:42:55 +0100 | |
branch | v_0 |
changeset 24 | 07e0a2edf3bc |
parent 23 | b497140b0b63 |
child 25 | b9067d2812e5 |
permissions | -rw-r--r-- |
0
16c7fa9b7c49
project and parser skeleton + output demo data
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
1 |
/** |
16c7fa9b7c49
project and parser skeleton + output demo data
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
2 |
* Relational pipes |
16c7fa9b7c49
project and parser skeleton + output demo data
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
3 |
* Copyright © 2020 František Kučera (Frantovo.cz, GlobalCode.info) |
16c7fa9b7c49
project and parser skeleton + output demo data
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
4 |
* |
16c7fa9b7c49
project and parser skeleton + output demo data
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
5 |
* This program is free software: you can redistribute it and/or modify |
16c7fa9b7c49
project and parser skeleton + output demo data
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License as published by |
16c7fa9b7c49
project and parser skeleton + output demo data
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
7 |
* the Free Software Foundation, version 3 of the License. |
16c7fa9b7c49
project and parser skeleton + output demo data
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
8 |
* |
16c7fa9b7c49
project and parser skeleton + output demo data
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
16c7fa9b7c49
project and parser skeleton + output demo data
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
16c7fa9b7c49
project and parser skeleton + output demo data
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16c7fa9b7c49
project and parser skeleton + output demo data
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
16c7fa9b7c49
project and parser skeleton + output demo data
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
13 |
* |
16c7fa9b7c49
project and parser skeleton + output demo data
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
16c7fa9b7c49
project and parser skeleton + output demo data
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
15 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
16c7fa9b7c49
project and parser skeleton + output demo data
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
16 |
*/ |
16c7fa9b7c49
project and parser skeleton + output demo data
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
17 |
|
16c7fa9b7c49
project and parser skeleton + output demo data
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
18 |
#include <vector> |
1
3876a9c56a66
simple INI parser based on regular expressions
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
19 |
#include <regex> |
16 | 20 |
#include <sstream> |
21 |
#include <stdexcept> |
|
0
16c7fa9b7c49
project and parser skeleton + output demo data
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
22 |
|
16c7fa9b7c49
project and parser skeleton + output demo data
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
23 |
#include "INIReader.h" |
16c7fa9b7c49
project and parser skeleton + output demo data
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
24 |
|
16 | 25 |
namespace relpipe { |
26 |
namespace in { |
|
27 |
namespace ini { |
|
28 |
namespace lib { |
|
29 |
||
0
16c7fa9b7c49
project and parser skeleton + output demo data
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
30 |
class INIReaderImpl : public INIReader { |
16c7fa9b7c49
project and parser skeleton + output demo data
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
31 |
private: |
16c7fa9b7c49
project and parser skeleton + output demo data
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
32 |
std::istream& input; |
16c7fa9b7c49
project and parser skeleton + output demo data
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
33 |
std::vector<INIContentHandler*> handlers; |
16 | 34 |
|
35 |
/** |
|
36 |
* By default, we ignore all leading whitespace on continuing lines. |
|
37 |
* If there should be some spaces or tabs, they should be placed on the previous line before the „\“. |
|
38 |
* If a line break is desired, it should be written as \n (escaped) or the value should be quoted in " or '. |
|
39 |
* |
|
40 |
* Related specifications: |
|
41 |
* - https://docs.oracle.com/javase/8/docs/api/index.html?java/util/Properties.html |
|
42 |
*/ |
|
23
b497140b0b63
enable configuring the parser from CLI: --parser-option
František Kučera <franta-hg@frantovo.cz>
parents:
22
diff
changeset
|
43 |
bool trimLeadingSpacesOnContinuingLines = true; |
16 | 44 |
|
24
07e0a2edf3bc
add --parser-option allow-sections (Java .properties have no sections)
František Kučera <franta-hg@frantovo.cz>
parents:
23
diff
changeset
|
45 |
|
07e0a2edf3bc
add --parser-option allow-sections (Java .properties have no sections)
František Kučera <franta-hg@frantovo.cz>
parents:
23
diff
changeset
|
46 |
/** |
07e0a2edf3bc
add --parser-option allow-sections (Java .properties have no sections)
František Kučera <franta-hg@frantovo.cz>
parents:
23
diff
changeset
|
47 |
* Some dialects or configuration files in general does not support sections. |
07e0a2edf3bc
add --parser-option allow-sections (Java .properties have no sections)
František Kučera <franta-hg@frantovo.cz>
parents:
23
diff
changeset
|
48 |
* Then a line, that looks like an INI section, should be interpreted as a key |
07e0a2edf3bc
add --parser-option allow-sections (Java .properties have no sections)
František Kučera <franta-hg@frantovo.cz>
parents:
23
diff
changeset
|
49 |
* (or error, if does not have a proper key-value separator). |
07e0a2edf3bc
add --parser-option allow-sections (Java .properties have no sections)
František Kučera <franta-hg@frantovo.cz>
parents:
23
diff
changeset
|
50 |
*/ |
07e0a2edf3bc
add --parser-option allow-sections (Java .properties have no sections)
František Kučera <franta-hg@frantovo.cz>
parents:
23
diff
changeset
|
51 |
bool allowSections = true; |
07e0a2edf3bc
add --parser-option allow-sections (Java .properties have no sections)
František Kučera <franta-hg@frantovo.cz>
parents:
23
diff
changeset
|
52 |
|
16 | 53 |
/** |
54 |
* KDE uses some weird INI dialect that allows [section][x] syntax where „x“ is kind of „tag“ that signalizes some properties of given section. |
|
55 |
* Line „[section_1][$i]“ means that the „section_1“ is „locked“. |
|
56 |
* We may emit this information somehow later, but for now, it is just ignored. |
|
57 |
* |
|
58 |
* TODO: Is „section tag“ right name? |
|
59 |
* |
|
60 |
* Related specifications: |
|
61 |
* - https://userbase.kde.org/KDE_System_Administration/Configuration_Files#Lock_Down |
|
62 |
*/ |
|
63 |
bool allowSectionTags = true; |
|
64 |
||
65 |
/** |
|
66 |
* If whole key is „aaa[bbb]“ then „aaa“ is considered to be the key and „bbb“ the sub-key. |
|
67 |
* No \[ escaping is currently supported, so the key might not contain the bracket character. |
|
68 |
* |
|
69 |
* Related specifications: |
|
70 |
* - https://userbase.kde.org/KDE_System_Administration/Configuration_Files#Shell_Expansion |
|
71 |
* - https://specifications.freedesktop.org/desktop-entry-spec/latest/ar01s05.html |
|
72 |
*/ |
|
73 |
bool allowSubKeys = true; |
|
74 |
||
20
9187f0439ca9
prepare for multiple and configurable key-value separators (e.g. key=value and key:value)
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
75 |
/** |
9187f0439ca9
prepare for multiple and configurable key-value separators (e.g. key=value and key:value)
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
76 |
* Classic INI uses „key=value“ syntax. |
9187f0439ca9
prepare for multiple and configurable key-value separators (e.g. key=value and key:value)
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
77 |
* But some other formats/dialects might use key:value. |
9187f0439ca9
prepare for multiple and configurable key-value separators (e.g. key=value and key:value)
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
78 |
* |
9187f0439ca9
prepare for multiple and configurable key-value separators (e.g. key=value and key:value)
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
79 |
* Only single character separators are supported. |
9187f0439ca9
prepare for multiple and configurable key-value separators (e.g. key=value and key:value)
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
80 |
* If multiple separators should be recognized (e.g. both „=“ and „:“), this string will contain all of them, |
9187f0439ca9
prepare for multiple and configurable key-value separators (e.g. key=value and key:value)
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
81 |
* i.e. „:=“ does not mean that the „key:=value“ syntax, but „key=value“ or „key:value“. |
9187f0439ca9
prepare for multiple and configurable key-value separators (e.g. key=value and key:value)
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
82 |
*/ |
9187f0439ca9
prepare for multiple and configurable key-value separators (e.g. key=value and key:value)
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
83 |
std::string keyValueSeparators = "="; |
9187f0439ca9
prepare for multiple and configurable key-value separators (e.g. key=value and key:value)
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
84 |
|
21
b35baebf5005
prepare for multiple and configurable comment separators (e.g. „; comment“ and „# comment“)
František Kučera <franta-hg@frantovo.cz>
parents:
20
diff
changeset
|
85 |
/** |
b35baebf5005
prepare for multiple and configurable comment separators (e.g. „; comment“ and „# comment“)
František Kučera <franta-hg@frantovo.cz>
parents:
20
diff
changeset
|
86 |
* Classic INI uses „; comment“ syntax. |
b35baebf5005
prepare for multiple and configurable comment separators (e.g. „; comment“ and „# comment“)
František Kučera <franta-hg@frantovo.cz>
parents:
20
diff
changeset
|
87 |
* But many existing files contain „# comment“ lines. |
b35baebf5005
prepare for multiple and configurable comment separators (e.g. „; comment“ and „# comment“)
František Kučera <franta-hg@frantovo.cz>
parents:
20
diff
changeset
|
88 |
* |
b35baebf5005
prepare for multiple and configurable comment separators (e.g. „; comment“ and „# comment“)
František Kučera <franta-hg@frantovo.cz>
parents:
20
diff
changeset
|
89 |
* Only single character separators are supported (works same as keyValueSeparators). |
b35baebf5005
prepare for multiple and configurable comment separators (e.g. „; comment“ and „# comment“)
František Kučera <franta-hg@frantovo.cz>
parents:
20
diff
changeset
|
90 |
*/ |
b35baebf5005
prepare for multiple and configurable comment separators (e.g. „; comment“ and „# comment“)
František Kučera <franta-hg@frantovo.cz>
parents:
20
diff
changeset
|
91 |
std::string commentSeparators = ";#"; |
b35baebf5005
prepare for multiple and configurable comment separators (e.g. „; comment“ and „# comment“)
František Kučera <franta-hg@frantovo.cz>
parents:
20
diff
changeset
|
92 |
|
22
29d673a54ecf
prepare for multiple and configurable quotes (e.g. „key="value"“ and „key='value'“ or disabling quote support at all)
František Kučera <franta-hg@frantovo.cz>
parents:
21
diff
changeset
|
93 |
/** |
29d673a54ecf
prepare for multiple and configurable quotes (e.g. „key="value"“ and „key='value'“ or disabling quote support at all)
František Kučera <franta-hg@frantovo.cz>
parents:
21
diff
changeset
|
94 |
* INI often support both "quotes" and 'apostrophes' styles. |
29d673a54ecf
prepare for multiple and configurable quotes (e.g. „key="value"“ and „key='value'“ or disabling quote support at all)
František Kučera <franta-hg@frantovo.cz>
parents:
21
diff
changeset
|
95 |
* But some dialects may support only one of them or not support quoting at all. |
29d673a54ecf
prepare for multiple and configurable quotes (e.g. „key="value"“ and „key='value'“ or disabling quote support at all)
František Kučera <franta-hg@frantovo.cz>
parents:
21
diff
changeset
|
96 |
* |
29d673a54ecf
prepare for multiple and configurable quotes (e.g. „key="value"“ and „key='value'“ or disabling quote support at all)
František Kučera <franta-hg@frantovo.cz>
parents:
21
diff
changeset
|
97 |
* In such case e.g. „key="some value"“ would mean that the value is „"value"“ (including the quotes). |
29d673a54ecf
prepare for multiple and configurable quotes (e.g. „key="value"“ and „key='value'“ or disabling quote support at all)
František Kučera <franta-hg@frantovo.cz>
parents:
21
diff
changeset
|
98 |
* Thus it is important to allow disabling quote recognizing (which is done by setting this parameter to empty string). |
29d673a54ecf
prepare for multiple and configurable quotes (e.g. „key="value"“ and „key='value'“ or disabling quote support at all)
František Kučera <franta-hg@frantovo.cz>
parents:
21
diff
changeset
|
99 |
* |
29d673a54ecf
prepare for multiple and configurable quotes (e.g. „key="value"“ and „key='value'“ or disabling quote support at all)
František Kučera <franta-hg@frantovo.cz>
parents:
21
diff
changeset
|
100 |
* Only single character quotes are supported (works same as keyValueSeparators). |
29d673a54ecf
prepare for multiple and configurable quotes (e.g. „key="value"“ and „key='value'“ or disabling quote support at all)
František Kučera <franta-hg@frantovo.cz>
parents:
21
diff
changeset
|
101 |
*/ |
29d673a54ecf
prepare for multiple and configurable quotes (e.g. „key="value"“ and „key='value'“ or disabling quote support at all)
František Kučera <franta-hg@frantovo.cz>
parents:
21
diff
changeset
|
102 |
std::string quotes = "\"'"; |
29d673a54ecf
prepare for multiple and configurable quotes (e.g. „key="value"“ and „key='value'“ or disabling quote support at all)
František Kučera <franta-hg@frantovo.cz>
parents:
21
diff
changeset
|
103 |
|
16 | 104 |
int lineNumber = 1; |
105 |
int eventNumber = 0; |
|
106 |
||
107 |
/** |
|
108 |
* Should be always used instead of input.peek(). |
|
109 |
* Skips \r. |
|
110 |
*/ |
|
111 |
char peek() { |
|
112 |
// In 2020 there is no need to manually return the carriage. However some legacy systems still do it. |
|
113 |
char ch = input.peek(); |
|
114 |
if (ch == '\r') { |
|
115 |
input.get(); |
|
116 |
ch = input.peek(); |
|
117 |
} |
|
118 |
return ch; |
|
119 |
} |
|
120 |
||
121 |
/** |
|
122 |
* Should be always used instead of input.get(). |
|
123 |
* Counts the lines and skips \r. |
|
124 |
*/ |
|
125 |
char get() { |
|
126 |
char ch = input.get(); |
|
127 |
if (ch == '\n') lineNumber++; |
|
128 |
else if (ch == '\r') ch = get(); |
|
129 |
return ch; |
|
130 |
} |
|
131 |
||
132 |
std::string readSpacesAndTabs() { |
|
133 |
std::stringstream result; |
|
134 |
for (char ch = peek(); input.good() && (ch == ' ' || ch == '\t'); ch = peek()) result.put(get()); |
|
135 |
return result.str(); |
|
136 |
} |
|
137 |
||
138 |
std::string readAllWhitespace() { |
|
139 |
std::stringstream result; |
|
140 |
for (char ch = peek(); input.good() && (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r'); ch = peek()) result.put(get()); |
|
141 |
return result.str(); |
|
142 |
} |
|
143 |
||
144 |
void processContinuingLine(std::stringstream& result) { |
|
23
b497140b0b63
enable configuring the parser from CLI: --parser-option
František Kučera <franta-hg@frantovo.cz>
parents:
22
diff
changeset
|
145 |
if (trimLeadingSpacesOnContinuingLines) readSpacesAndTabs(); |
16 | 146 |
else result.put('\n'); |
147 |
} |
|
148 |
||
20
9187f0439ca9
prepare for multiple and configurable key-value separators (e.g. key=value and key:value)
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
149 |
std::string readUntil(const char until, bool* found = nullptr) { |
9187f0439ca9
prepare for multiple and configurable key-value separators (e.g. key=value and key:value)
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
150 |
return readUntil(std::string(1, until), found); |
9187f0439ca9
prepare for multiple and configurable key-value separators (e.g. key=value and key:value)
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
151 |
} |
9187f0439ca9
prepare for multiple and configurable key-value separators (e.g. key=value and key:value)
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
152 |
|
9187f0439ca9
prepare for multiple and configurable key-value separators (e.g. key=value and key:value)
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
153 |
std::string readUntil(const std::string& until, bool* found = nullptr) { |
16 | 154 |
std::stringstream result; |
155 |
||
20
9187f0439ca9
prepare for multiple and configurable key-value separators (e.g. key=value and key:value)
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
156 |
for (char ch = peek(); input.good() && !oneOf(ch, until); ch = peek()) { |
16 | 157 |
if (ch == '\\') { |
158 |
get(); |
|
159 |
ch = get(); |
|
20
9187f0439ca9
prepare for multiple and configurable key-value separators (e.g. key=value and key:value)
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
160 |
if (oneOf(ch, until) && ch == '\n') processContinuingLine(result); |
9187f0439ca9
prepare for multiple and configurable key-value separators (e.g. key=value and key:value)
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
161 |
else if (oneOf(ch, until)) result.put(ch); |
16 | 162 |
else if (ch == std::istream::traits_type::eof()) break; |
163 |
else result.put('\\').put(ch); |
|
20
9187f0439ca9
prepare for multiple and configurable key-value separators (e.g. key=value and key:value)
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
164 |
// unescaping is done in two phases: |
9187f0439ca9
prepare for multiple and configurable key-value separators (e.g. key=value and key:value)
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
165 |
// here we unescape just the \n (LF) |
9187f0439ca9
prepare for multiple and configurable key-value separators (e.g. key=value and key:value)
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
166 |
// other escape sequences are leaved untouched and will be processed in later phases, see see UnescapingINIHandler |
16 | 167 |
} else { |
168 |
ch = get(); |
|
169 |
result.put(ch); |
|
170 |
} |
|
171 |
} |
|
172 |
||
20
9187f0439ca9
prepare for multiple and configurable key-value separators (e.g. key=value and key:value)
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
173 |
if (oneOf(peek(), until)) { |
16 | 174 |
get(); |
175 |
if (found) *found = true; |
|
176 |
} else { |
|
177 |
if (found) *found = false; |
|
178 |
} |
|
179 |
||
180 |
return result.str(); |
|
181 |
} |
|
182 |
||
20
9187f0439ca9
prepare for multiple and configurable key-value separators (e.g. key=value and key:value)
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
183 |
std::string readToken(const char until, char* quote = nullptr, bool* found = nullptr) { |
9187f0439ca9
prepare for multiple and configurable key-value separators (e.g. key=value and key:value)
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
184 |
return readToken(std::string(1, until), quote, found); |
9187f0439ca9
prepare for multiple and configurable key-value separators (e.g. key=value and key:value)
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
185 |
} |
9187f0439ca9
prepare for multiple and configurable key-value separators (e.g. key=value and key:value)
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
186 |
|
9187f0439ca9
prepare for multiple and configurable key-value separators (e.g. key=value and key:value)
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
187 |
std::string readToken(const std::string& until, char* quote = nullptr, bool* found = nullptr) { |
16 | 188 |
std::string result; |
189 |
||
190 |
char ch = peek(); |
|
191 |
if (isQuote(ch)) { |
|
192 |
if (quote) *quote = ch; |
|
20
9187f0439ca9
prepare for multiple and configurable key-value separators (e.g. key=value and key:value)
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
193 |
result = readUntil(std::string(1, get()), found); |
16 | 194 |
} else { |
195 |
if (quote) *quote = 0; |
|
196 |
result = readUntil(until, found); |
|
197 |
} |
|
198 |
||
199 |
return result; |
|
200 |
} |
|
201 |
||
202 |
std::string readTokenAndEatTerminator(char until, char* quote = nullptr, bool* found = nullptr) { |
|
20
9187f0439ca9
prepare for multiple and configurable key-value separators (e.g. key=value and key:value)
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
203 |
return readTokenAndEatTerminator(std::string(1, until), quote, found); |
9187f0439ca9
prepare for multiple and configurable key-value separators (e.g. key=value and key:value)
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
204 |
} |
9187f0439ca9
prepare for multiple and configurable key-value separators (e.g. key=value and key:value)
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
205 |
|
9187f0439ca9
prepare for multiple and configurable key-value separators (e.g. key=value and key:value)
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
206 |
std::string readTokenAndEatTerminator(const std::string& until, char* quote = nullptr, bool* found = nullptr) { |
16 | 207 |
std::string result = readToken(until, quote, found); |
208 |
if (*quote) { |
|
209 |
readAllWhitespace(); |
|
20
9187f0439ca9
prepare for multiple and configurable key-value separators (e.g. key=value and key:value)
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
210 |
if (!oneOf(get(), until)) throw std::logic_error(std::string("missing „") + until + "“ after quoted section name"); |
16 | 211 |
} |
212 |
return result; |
|
213 |
} |
|
214 |
||
215 |
bool isComment(char ch) { |
|
21
b35baebf5005
prepare for multiple and configurable comment separators (e.g. „; comment“ and „# comment“)
František Kučera <franta-hg@frantovo.cz>
parents:
20
diff
changeset
|
216 |
return oneOf(ch, commentSeparators); |
16 | 217 |
} |
218 |
||
219 |
bool isQuote(char ch) { |
|
22
29d673a54ecf
prepare for multiple and configurable quotes (e.g. „key="value"“ and „key='value'“ or disabling quote support at all)
František Kučera <franta-hg@frantovo.cz>
parents:
21
diff
changeset
|
220 |
return oneOf(ch, quotes); |
16 | 221 |
} |
222 |
||
20
9187f0439ca9
prepare for multiple and configurable key-value separators (e.g. key=value and key:value)
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
223 |
/** |
9187f0439ca9
prepare for multiple and configurable key-value separators (e.g. key=value and key:value)
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
224 |
* @param ch character to be evaluated |
9187f0439ca9
prepare for multiple and configurable key-value separators (e.g. key=value and key:value)
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
225 |
* @param options list of options (characters) |
9187f0439ca9
prepare for multiple and configurable key-value separators (e.g. key=value and key:value)
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
226 |
* @return whether ch is one of options |
9187f0439ca9
prepare for multiple and configurable key-value separators (e.g. key=value and key:value)
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
227 |
*/ |
9187f0439ca9
prepare for multiple and configurable key-value separators (e.g. key=value and key:value)
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
228 |
bool oneOf(char ch, const std::string& options) { |
9187f0439ca9
prepare for multiple and configurable key-value separators (e.g. key=value and key:value)
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
229 |
return options.find(ch) != std::string::npos; |
9187f0439ca9
prepare for multiple and configurable key-value separators (e.g. key=value and key:value)
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
230 |
} |
9187f0439ca9
prepare for multiple and configurable key-value separators (e.g. key=value and key:value)
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
231 |
|
16 | 232 |
std::string trim(std::string s) { |
233 |
return std::regex_replace(s, std::regex("^\\s+|\\s+$"), ""); |
|
234 |
} |
|
235 |
||
23
b497140b0b63
enable configuring the parser from CLI: --parser-option
František Kučera <franta-hg@frantovo.cz>
parents:
22
diff
changeset
|
236 |
/** |
b497140b0b63
enable configuring the parser from CLI: --parser-option
František Kučera <franta-hg@frantovo.cz>
parents:
22
diff
changeset
|
237 |
* TODO: use a common method |
b497140b0b63
enable configuring the parser from CLI: --parser-option
František Kučera <franta-hg@frantovo.cz>
parents:
22
diff
changeset
|
238 |
*/ |
b497140b0b63
enable configuring the parser from CLI: --parser-option
František Kučera <franta-hg@frantovo.cz>
parents:
22
diff
changeset
|
239 |
bool parseBoolean(const std::string& value) { |
b497140b0b63
enable configuring the parser from CLI: --parser-option
František Kučera <franta-hg@frantovo.cz>
parents:
22
diff
changeset
|
240 |
if (value == "true") return true; |
b497140b0b63
enable configuring the parser from CLI: --parser-option
František Kučera <franta-hg@frantovo.cz>
parents:
22
diff
changeset
|
241 |
else if (value == "false") return false; |
b497140b0b63
enable configuring the parser from CLI: --parser-option
František Kučera <franta-hg@frantovo.cz>
parents:
22
diff
changeset
|
242 |
else throw std::invalid_argument(std::string("Unable to parse boolean value: ") + value + " (expecting true or false)"); |
b497140b0b63
enable configuring the parser from CLI: --parser-option
František Kučera <franta-hg@frantovo.cz>
parents:
22
diff
changeset
|
243 |
} |
b497140b0b63
enable configuring the parser from CLI: --parser-option
František Kučera <franta-hg@frantovo.cz>
parents:
22
diff
changeset
|
244 |
|
b497140b0b63
enable configuring the parser from CLI: --parser-option
František Kučera <franta-hg@frantovo.cz>
parents:
22
diff
changeset
|
245 |
void setDialect(const std::string& name) { |
b497140b0b63
enable configuring the parser from CLI: --parser-option
František Kučera <franta-hg@frantovo.cz>
parents:
22
diff
changeset
|
246 |
if (name == "default-ini") { |
b497140b0b63
enable configuring the parser from CLI: --parser-option
František Kučera <franta-hg@frantovo.cz>
parents:
22
diff
changeset
|
247 |
// already set |
b497140b0b63
enable configuring the parser from CLI: --parser-option
František Kučera <franta-hg@frantovo.cz>
parents:
22
diff
changeset
|
248 |
} else if (name == "java-properties") { |
b497140b0b63
enable configuring the parser from CLI: --parser-option
František Kučera <franta-hg@frantovo.cz>
parents:
22
diff
changeset
|
249 |
trimLeadingSpacesOnContinuingLines = true; |
24
07e0a2edf3bc
add --parser-option allow-sections (Java .properties have no sections)
František Kučera <franta-hg@frantovo.cz>
parents:
23
diff
changeset
|
250 |
allowSections = false; |
23
b497140b0b63
enable configuring the parser from CLI: --parser-option
František Kučera <franta-hg@frantovo.cz>
parents:
22
diff
changeset
|
251 |
allowSectionTags = false; |
b497140b0b63
enable configuring the parser from CLI: --parser-option
František Kučera <franta-hg@frantovo.cz>
parents:
22
diff
changeset
|
252 |
allowSubKeys = false; |
b497140b0b63
enable configuring the parser from CLI: --parser-option
František Kučera <franta-hg@frantovo.cz>
parents:
22
diff
changeset
|
253 |
commentSeparators = "#"; |
b497140b0b63
enable configuring the parser from CLI: --parser-option
František Kučera <franta-hg@frantovo.cz>
parents:
22
diff
changeset
|
254 |
keyValueSeparators = "=:"; |
b497140b0b63
enable configuring the parser from CLI: --parser-option
František Kučera <franta-hg@frantovo.cz>
parents:
22
diff
changeset
|
255 |
quotes = ""; |
b497140b0b63
enable configuring the parser from CLI: --parser-option
František Kučera <franta-hg@frantovo.cz>
parents:
22
diff
changeset
|
256 |
// TODO: enable unicode unescaping |
b497140b0b63
enable configuring the parser from CLI: --parser-option
František Kučera <franta-hg@frantovo.cz>
parents:
22
diff
changeset
|
257 |
} else { |
b497140b0b63
enable configuring the parser from CLI: --parser-option
František Kučera <franta-hg@frantovo.cz>
parents:
22
diff
changeset
|
258 |
throw std::invalid_argument(std::string("Unsupported INI dialect: ") + name); |
b497140b0b63
enable configuring the parser from CLI: --parser-option
František Kučera <franta-hg@frantovo.cz>
parents:
22
diff
changeset
|
259 |
} |
b497140b0b63
enable configuring the parser from CLI: --parser-option
František Kučera <franta-hg@frantovo.cz>
parents:
22
diff
changeset
|
260 |
} |
b497140b0b63
enable configuring the parser from CLI: --parser-option
František Kučera <franta-hg@frantovo.cz>
parents:
22
diff
changeset
|
261 |
|
0
16c7fa9b7c49
project and parser skeleton + output demo data
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
262 |
public: |
16c7fa9b7c49
project and parser skeleton + output demo data
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
263 |
|
16c7fa9b7c49
project and parser skeleton + output demo data
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
264 |
INIReaderImpl(std::istream& input) : input(input) { |
16c7fa9b7c49
project and parser skeleton + output demo data
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
265 |
} |
16c7fa9b7c49
project and parser skeleton + output demo data
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
266 |
|
23
b497140b0b63
enable configuring the parser from CLI: --parser-option
František Kučera <franta-hg@frantovo.cz>
parents:
22
diff
changeset
|
267 |
void setOption(const std::string& uri, const std::string& value) override { |
b497140b0b63
enable configuring the parser from CLI: --parser-option
František Kučera <franta-hg@frantovo.cz>
parents:
22
diff
changeset
|
268 |
if (uri == "trim-continuing-lines") trimLeadingSpacesOnContinuingLines = parseBoolean(value); // TODO: continuing lines modes (enum), not just boolean |
24
07e0a2edf3bc
add --parser-option allow-sections (Java .properties have no sections)
František Kučera <franta-hg@frantovo.cz>
parents:
23
diff
changeset
|
269 |
else if (uri == "allow-sections") allowSections = parseBoolean(value); |
23
b497140b0b63
enable configuring the parser from CLI: --parser-option
František Kučera <franta-hg@frantovo.cz>
parents:
22
diff
changeset
|
270 |
else if (uri == "allow-section-tags") allowSectionTags = parseBoolean(value); |
b497140b0b63
enable configuring the parser from CLI: --parser-option
František Kučera <franta-hg@frantovo.cz>
parents:
22
diff
changeset
|
271 |
else if (uri == "allow-sub-keys") allowSubKeys = parseBoolean(value); |
b497140b0b63
enable configuring the parser from CLI: --parser-option
František Kučera <franta-hg@frantovo.cz>
parents:
22
diff
changeset
|
272 |
else if (uri == "comment-separators") commentSeparators = value; |
b497140b0b63
enable configuring the parser from CLI: --parser-option
František Kučera <franta-hg@frantovo.cz>
parents:
22
diff
changeset
|
273 |
else if (uri == "key-value-separators") keyValueSeparators = value; |
b497140b0b63
enable configuring the parser from CLI: --parser-option
František Kučera <franta-hg@frantovo.cz>
parents:
22
diff
changeset
|
274 |
else if (uri == "quotes") quotes = value; |
b497140b0b63
enable configuring the parser from CLI: --parser-option
František Kučera <franta-hg@frantovo.cz>
parents:
22
diff
changeset
|
275 |
else if (uri == "dialect") setDialect(value); |
b497140b0b63
enable configuring the parser from CLI: --parser-option
František Kučera <franta-hg@frantovo.cz>
parents:
22
diff
changeset
|
276 |
else throw std::invalid_argument(std::string("Invalid parser option: „") + uri + "“ with value: „" + value + "“"); |
b497140b0b63
enable configuring the parser from CLI: --parser-option
František Kučera <franta-hg@frantovo.cz>
parents:
22
diff
changeset
|
277 |
} |
b497140b0b63
enable configuring the parser from CLI: --parser-option
František Kučera <franta-hg@frantovo.cz>
parents:
22
diff
changeset
|
278 |
|
0
16c7fa9b7c49
project and parser skeleton + output demo data
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
279 |
void addHandler(INIContentHandler* handler) override { |
16c7fa9b7c49
project and parser skeleton + output demo data
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
280 |
handlers.push_back(handler); |
16c7fa9b7c49
project and parser skeleton + output demo data
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
281 |
} |
16c7fa9b7c49
project and parser skeleton + output demo data
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
282 |
|
16c7fa9b7c49
project and parser skeleton + output demo data
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
283 |
void process() override { |
1
3876a9c56a66
simple INI parser based on regular expressions
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
284 |
for (INIContentHandler* handler : handlers) handler->startDocument(); |
3876a9c56a66
simple INI parser based on regular expressions
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
285 |
|
16 | 286 |
bool inSection = false; |
287 |
||
288 |
while (input.good()) { // TODO: condition |
|
289 |
{ |
|
19
967f73af64a4
start event numbers with 1
František Kučera <franta-hg@frantovo.cz>
parents:
16
diff
changeset
|
290 |
INIContentHandler::WhitespaceEvent event; |
967f73af64a4
start event numbers with 1
František Kučera <franta-hg@frantovo.cz>
parents:
16
diff
changeset
|
291 |
event.lineNumber = lineNumber; |
16 | 292 |
std::string whitespace = readAllWhitespace(); |
293 |
if (whitespace.size()) { |
|
294 |
event.eventNumber = ++eventNumber; |
|
295 |
event.whitespace = whitespace; |
|
296 |
for (INIContentHandler* handler : handlers) handler->whitespace(event); |
|
297 |
} |
|
298 |
} |
|
1
3876a9c56a66
simple INI parser based on regular expressions
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
299 |
|
16 | 300 |
bool found; |
301 |
char quote; |
|
302 |
||
303 |
char ch = peek(); |
|
2
f031a4dc7c52
add options: --enable-sections --enable-subkeys --enable-comments --enable-line-numbers --enable-event-numbers
František Kučera <franta-hg@frantovo.cz>
parents:
1
diff
changeset
|
304 |
|
16 | 305 |
if (ch == std::istream::traits_type::eof()) { |
306 |
break; |
|
24
07e0a2edf3bc
add --parser-option allow-sections (Java .properties have no sections)
František Kučera <franta-hg@frantovo.cz>
parents:
23
diff
changeset
|
307 |
} else if (ch == '[' && allowSections) { |
16 | 308 |
if (inSection) for (INIContentHandler* handler : handlers) handler->endSection(); |
309 |
inSection = true; |
|
310 |
INIContentHandler::SectionStartEvent event; |
|
6
fb717cfbfea1
improved support for comments and whitespace
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
311 |
event.lineNumber = lineNumber; |
fb717cfbfea1
improved support for comments and whitespace
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
312 |
event.eventNumber = ++eventNumber; |
19
967f73af64a4
start event numbers with 1
František Kučera <franta-hg@frantovo.cz>
parents:
16
diff
changeset
|
313 |
get(); |
967f73af64a4
start event numbers with 1
František Kučera <franta-hg@frantovo.cz>
parents:
16
diff
changeset
|
314 |
readAllWhitespace(); |
16 | 315 |
event.name = readTokenAndEatTerminator(']', "e, &found); |
24
07e0a2edf3bc
add --parser-option allow-sections (Java .properties have no sections)
František Kučera <franta-hg@frantovo.cz>
parents:
23
diff
changeset
|
316 |
// TODO: if (!quote) event.name = trim(event.name); |
16 | 317 |
|
318 |
readSpacesAndTabs(); |
|
319 |
if (allowSectionTags && peek() == '[') { |
|
320 |
get(); |
|
321 |
event.tag = readTokenAndEatTerminator(']', "e, &found); |
|
322 |
} |
|
323 |
||
324 |
readSpacesAndTabs(); |
|
325 |
ch = peek(); |
|
326 |
if (isComment(ch)) { |
|
327 |
get(); |
|
328 |
readSpacesAndTabs(); |
|
329 |
event.comment = readUntil('\n', &found); |
|
330 |
} else if (ch == '\n') { |
|
331 |
get(); |
|
332 |
} else { |
|
333 |
throw std::logic_error(std::string("unexpected content after the section: '") + event.name + "'"); |
|
334 |
} |
|
335 |
||
336 |
for (INIContentHandler* handler : handlers) handler->startSection(event); |
|
337 |
} else if (isComment(ch)) { |
|
6
fb717cfbfea1
improved support for comments and whitespace
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
338 |
INIContentHandler::CommentEvent event; |
fb717cfbfea1
improved support for comments and whitespace
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
339 |
event.lineNumber = lineNumber; |
fb717cfbfea1
improved support for comments and whitespace
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
340 |
event.eventNumber = ++eventNumber; |
19
967f73af64a4
start event numbers with 1
František Kučera <franta-hg@frantovo.cz>
parents:
16
diff
changeset
|
341 |
get(); |
967f73af64a4
start event numbers with 1
František Kučera <franta-hg@frantovo.cz>
parents:
16
diff
changeset
|
342 |
readSpacesAndTabs(); |
16 | 343 |
event.comment = readUntil('\n', &found); |
6
fb717cfbfea1
improved support for comments and whitespace
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
344 |
for (INIContentHandler* handler : handlers) handler->comment(event); |
16 | 345 |
} else { |
19
967f73af64a4
start event numbers with 1
František Kučera <franta-hg@frantovo.cz>
parents:
16
diff
changeset
|
346 |
INIContentHandler::EntryEvent event; |
967f73af64a4
start event numbers with 1
František Kučera <franta-hg@frantovo.cz>
parents:
16
diff
changeset
|
347 |
event.lineNumber = lineNumber; |
967f73af64a4
start event numbers with 1
František Kučera <franta-hg@frantovo.cz>
parents:
16
diff
changeset
|
348 |
event.eventNumber = ++eventNumber; |
967f73af64a4
start event numbers with 1
František Kučera <franta-hg@frantovo.cz>
parents:
16
diff
changeset
|
349 |
|
20
9187f0439ca9
prepare for multiple and configurable key-value separators (e.g. key=value and key:value)
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
350 |
std::string fullKey = readToken(keyValueSeparators, "e, &found); |
16 | 351 |
if (!found) throw std::logic_error(std::string("missing = after key: '") + fullKey + "'"); |
352 |
if (!quote) fullKey = trim(fullKey); |
|
353 |
readSpacesAndTabs(); |
|
354 |
||
355 |
if (quote) { |
|
356 |
ch = get(); |
|
20
9187f0439ca9
prepare for multiple and configurable key-value separators (e.g. key=value and key:value)
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
357 |
if (oneOf(ch, keyValueSeparators)) readSpacesAndTabs(); |
16 | 358 |
else throw std::logic_error(std::string("missing = after quoted key: '") + fullKey + "'"); |
359 |
} |
|
360 |
||
361 |
std::string value = readToken('\n', "e, &found); |
|
362 |
if (!quote) value = trim(value); |
|
363 |
||
364 |
event.key = fullKey; |
|
365 |
event.fullKey = fullKey; |
|
366 |
event.value = value; |
|
14
ea431c469403
multi-line support: quoted and apostrophed
František Kučera <franta-hg@frantovo.cz>
parents:
13
diff
changeset
|
367 |
|
16 | 368 |
if (allowSubKeys) { |
369 |
std::smatch match; |
|
370 |
if (std::regex_match(fullKey, match, std::regex("([^\\[]+)\\[([^\\[]+)\\]"))) { |
|
371 |
event.key = match[1]; |
|
372 |
event.subKey = match[2]; |
|
373 |
event.fullKey = fullKey; |
|
374 |
} |
|
375 |
} |
|
376 |
||
377 |
if (quote) { |
|
378 |
readSpacesAndTabs(); |
|
379 |
ch = peek(); |
|
380 |
if (isComment(ch)) { |
|
381 |
get(); |
|
382 |
readSpacesAndTabs(); |
|
383 |
event.comment = readUntil('\n', &found); |
|
384 |
} else if (ch == '\n') { |
|
385 |
get(); |
|
386 |
} else { |
|
387 |
throw std::logic_error(std::string("unexpected content after the quoted value: key='") + fullKey + "' value='" + event.value + "'"); |
|
14
ea431c469403
multi-line support: quoted and apostrophed
František Kučera <franta-hg@frantovo.cz>
parents:
13
diff
changeset
|
388 |
} |
ea431c469403
multi-line support: quoted and apostrophed
František Kučera <franta-hg@frantovo.cz>
parents:
13
diff
changeset
|
389 |
} |
ea431c469403
multi-line support: quoted and apostrophed
František Kučera <franta-hg@frantovo.cz>
parents:
13
diff
changeset
|
390 |
|
2
f031a4dc7c52
add options: --enable-sections --enable-subkeys --enable-comments --enable-line-numbers --enable-event-numbers
František Kučera <franta-hg@frantovo.cz>
parents:
1
diff
changeset
|
391 |
for (INIContentHandler* handler : handlers) handler->entry(event); |
1
3876a9c56a66
simple INI parser based on regular expressions
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
392 |
} |
0
16c7fa9b7c49
project and parser skeleton + output demo data
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
393 |
} |
16 | 394 |
// TODO: error at the end, catch premature/unexpected EOF |
395 |
// TODO: unescape + trim values + ignore \r |
|
396 |
// TODO: count lines |
|
2
f031a4dc7c52
add options: --enable-sections --enable-subkeys --enable-comments --enable-line-numbers --enable-event-numbers
František Kučera <franta-hg@frantovo.cz>
parents:
1
diff
changeset
|
397 |
if (inSection) for (INIContentHandler* handler : handlers) handler->endSection(); |
1
3876a9c56a66
simple INI parser based on regular expressions
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
398 |
for (INIContentHandler* handler : handlers) handler->endDocument(); |
0
16c7fa9b7c49
project and parser skeleton + output demo data
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
399 |
} |
16 | 400 |
|
401 |
// General feautres: |
|
402 |
// TODO: warning/error handler |
|
403 |
// TODO: support also escaped characters |
|
404 |
// TODO: support also Java .properties and manifest.mf formats? |
|
405 |
// TODO: support also nested sections – hierarchy |
|
406 |
// TODO: support also nested keys e.g. key.sub.subsub.subsubsub=value – translate them to nested sections |
|
407 |
// TODO: support also option for alternative key-value separator (: instead of =) |
|
408 |
// TODO: support also other encodings (currently only UTF-8 is supported) |
|
409 |
// TODO: better exceptions |
|
410 |
||
411 |
// Lossless conversions: |
|
412 |
// TODO: emit also the quote style ('/"/) |
|
413 |
// TODO: emit also the comment style (;/#) ? |
|
414 |
// TODO: emit also the whitespace before key name, around =, after "values"/'values', around [sections] ? |
|
415 |
// TODO: emit also the line-end type (LF/CRLF) ? |
|
416 |
||
0
16c7fa9b7c49
project and parser skeleton + output demo data
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
417 |
}; |
16c7fa9b7c49
project and parser skeleton + output demo data
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
418 |
|
16c7fa9b7c49
project and parser skeleton + output demo data
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
419 |
INIReader* INIReader::create(std::istream& input) { |
16c7fa9b7c49
project and parser skeleton + output demo data
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
420 |
return new INIReaderImpl(input); |
16c7fa9b7c49
project and parser skeleton + output demo data
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
421 |
} |
16 | 422 |
|
423 |
} |
|
424 |
} |
|
425 |
} |
|
426 |
} |