prepare for multiple and configurable comment separators (e.g. „; comment“ and „# comment“) v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Thu, 26 Nov 2020 18:42:38 +0100
branchv_0
changeset 21 b35baebf5005
parent 20 9187f0439ca9
child 22 29d673a54ecf
prepare for multiple and configurable comment separators (e.g. „; comment“ and „# comment“)
src/lib/INIReader.cpp
--- a/src/lib/INIReader.cpp	Thu Nov 26 18:28:27 2020 +0100
+++ b/src/lib/INIReader.cpp	Thu Nov 26 18:42:38 2020 +0100
@@ -82,6 +82,16 @@
 	 */
 	std::string keyValueSeparators = "=";
 
+	/**
+	 * This might be configurable.
+	 * 
+	 * Classic INI uses „; comment“ syntax.
+	 * But many existing files contain „# comment“ lines.
+	 * 
+	 * Only single character separators are supported (works same as keyValueSeparators).
+	 */
+	std::string commentSeparators = ";#";
+
 	int lineNumber = 1;
 	int eventNumber = 0;
 
@@ -194,7 +204,7 @@
 	}
 
 	bool isComment(char ch) {
-		return ch == '#' || ch == ';';
+		return oneOf(ch, commentSeparators);
 	}
 
 	bool isQuote(char ch) {