do not quote nor escape integers and booleans, v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Wed, 23 Dec 2020 18:29:36 +0100
branchv_0
changeset 2 6839c85a9621
parent 1 af15c47f77ae
child 3 1e9a07d8a406
do not quote nor escape integers and booleans, escape line ends, escape backslash
src/YAMLHandler.h
--- a/src/YAMLHandler.h	Wed Dec 23 18:22:55 2020 +0100
+++ b/src/YAMLHandler.h	Wed Dec 23 18:29:36 2020 +0100
@@ -47,7 +47,10 @@
 		std::stringstream result;
 		result.put(Q);
 		for (char ch : convertor.to_bytes(value)) {
-			if (ch == Q) result.put(ESC).put(ch);
+			if (ch == ESC) result.put(ESC).put(ch);
+			else if (ch == Q) result.put(ESC).put(ch);
+			else if (ch == '\n') result.put(ESC).put('n');
+			else if (ch == '\r') result.put(ESC).put('r');
 			else result.put(ch);
 		}
 		result.put(Q);
@@ -89,7 +92,10 @@
 		}
 
 		output << escape(currentAttributes[currentAttributeIndex].getAttributeName()) << ": ";
-		output << escape(value) << std::endl;
+
+		if (currentAttributes[currentAttributeIndex].getTypeId() == relpipe::reader::TypeId::INTEGER) output << convertor.to_bytes(value) << std::endl;
+		else if (currentAttributes[currentAttributeIndex].getTypeId() == relpipe::reader::TypeId::BOOLEAN) output << convertor.to_bytes(value) << std::endl;
+		else output << escape(value) << std::endl;
 
 		currentAttributeIndex++;
 	}