prepare for multiple and configurable quotes (e.g. „key="value"“ and „key='value'“ or disabling quote support at all) v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Thu, 26 Nov 2020 18:52:49 +0100
branchv_0
changeset 22 29d673a54ecf
parent 21 b35baebf5005
child 23 b497140b0b63
prepare for multiple and configurable quotes (e.g. „key="value"“ and „key='value'“ or disabling quote support at all)
src/lib/INIReader.cpp
--- a/src/lib/INIReader.cpp	Thu Nov 26 18:42:38 2020 +0100
+++ b/src/lib/INIReader.cpp	Thu Nov 26 18:52:49 2020 +0100
@@ -92,6 +92,19 @@
 	 */
 	std::string commentSeparators = ";#";
 
+	/**
+	 * This might be configurable.
+	 * 
+	 * INI often support both "quotes" and 'apostrophes' styles.
+	 * But some dialects may support only one of them or not support quoting at all.
+	 * 
+	 * In such case e.g. „key="some value"“ would mean that the value is „"value"“ (including the quotes).
+	 * Thus it is important to allow disabling quote recognizing (which is done by setting this parameter to empty string).
+	 * 
+	 * Only single character quotes are supported (works same as keyValueSeparators).
+	 */
+	std::string quotes = "\"'";
+
 	int lineNumber = 1;
 	int eventNumber = 0;
 
@@ -208,7 +221,7 @@
 	}
 
 	bool isQuote(char ch) {
-		return ch == '"' || ch == '\'';
+		return oneOf(ch, quotes);
 	}
 
 	/**