equal
deleted
inserted
replaced
56 |
56 |
57 }; |
57 }; |
58 |
58 |
59 std::vector<ConfiguredDialect> dialects; |
59 std::vector<ConfiguredDialect> dialects; |
60 |
60 |
|
61 /** |
|
62 * If there is a „\“ backspace at the end of a physical line, the logical line continues on the next physical line. |
|
63 * |
|
64 * Disabling this option makes sense only if we also disable the unescaping processors (unescape-basic, unescape-backspace). |
|
65 * Otherwise they will complain about „Missing escape sequence“ because they got „\“ at the end of the value. |
|
66 */ |
|
67 bool allowLineContinuationsWithEscaping = true; |
|
68 |
|
69 /** |
|
70 * If a line starts with a space, it is continuation of the previous line. |
|
71 * This rule conflicts with default ignorance of such insignificant whitespace and is quite specific to the Java MANIFEST.MF dialect. |
|
72 */ |
|
73 bool allowLineContinuationsWithSpace = false; |
|
74 |
61 /** |
75 /** |
62 * By default, we ignore all leading whitespace on continuing lines. |
76 * By default, we ignore all leading whitespace on continuing lines. |
63 * If there should be some spaces or tabs, they should be placed on the previous line before the „\“. |
77 * If there should be some spaces or tabs, they should be placed on the previous line before the „\“. |
64 * If a line break is desired, it should be written as \n (escaped) or the value should be quoted in " or '. |
78 * If a line break is desired, it should be written as \n (escaped) or the value should be quoted in " or '. |
65 * |
79 * |
187 |
201 |
188 std::string readUntil(const std::string& until, bool* found = nullptr) { |
202 std::string readUntil(const std::string& until, bool* found = nullptr) { |
189 std::stringstream result; |
203 std::stringstream result; |
190 |
204 |
191 for (char ch = peek(); input.good() && !oneOf(ch, until); ch = peek()) { |
205 for (char ch = peek(); input.good() && !oneOf(ch, until); ch = peek()) { |
192 if (ch == '\\') { |
206 if (allowLineContinuationsWithEscaping && ch == '\\') { |
193 get(); |
207 get(); |
194 ch = get(); |
208 ch = get(); |
195 if (oneOf(ch, until) && ch == '\n') processContinuingLine(result); |
209 if (oneOf(ch, until) && ch == '\n') processContinuingLine(result); |
196 else if (oneOf(ch, until)) result.put(ch); |
210 else if (oneOf(ch, until)) result.put(ch); |
197 else if (ch == std::istream::traits_type::eof()) break; |
211 else if (ch == std::istream::traits_type::eof()) break; |
307 |
321 |
308 INIReaderImpl(std::istream& input) : input(input) { |
322 INIReaderImpl(std::istream& input) : input(input) { |
309 } |
323 } |
310 |
324 |
311 void setOption(const std::string& uri, const std::string& value) override { |
325 void setOption(const std::string& uri, const std::string& value) override { |
312 if (uri == option::TrimContinuingLines) trimLeadingSpacesOnContinuingLines = parseBoolean(value); // TODO: continuing lines modes (enum), not just boolean |
326 if (uri == option::AllowLineContinuationWithEscaping) allowLineContinuationsWithEscaping = parseBoolean(value); |
|
327 else if (uri == option::AllowLineContinuationWithSpace) allowLineContinuationsWithSpace = parseBoolean(value); |
|
328 else if (uri == option::TrimContinuingLines) trimLeadingSpacesOnContinuingLines = parseBoolean(value); |
313 else if (uri == option::AllowSections) allowSections = parseBoolean(value); |
329 else if (uri == option::AllowSections) allowSections = parseBoolean(value); |
314 else if (uri == option::AllowSectionTags) allowSectionTags = parseBoolean(value); |
330 else if (uri == option::AllowSectionTags) allowSectionTags = parseBoolean(value); |
315 else if (uri == option::AllowSubKeys) allowSubKeys = parseBoolean(value); |
331 else if (uri == option::AllowSubKeys) allowSubKeys = parseBoolean(value); |
316 else if (uri == option::CommentSeparators) commentSeparators = value; |
332 else if (uri == option::CommentSeparators) commentSeparators = value; |
317 else if (uri == option::KeyValueSeparators) keyValueSeparators = value; |
333 else if (uri == option::KeyValueSeparators) keyValueSeparators = value; |