src/DataTypeWriter.h
branchv_0
changeset 16 3613617d3076
parent 15 8fd6c4d44071
child 29 142bdbba520f
--- a/src/DataTypeWriter.h	Sun Jul 22 10:26:22 2018 +0200
+++ b/src/DataTypeWriter.h	Sun Jul 22 17:19:25 2018 +0200
@@ -1,5 +1,8 @@
 #pragma once
 
+#include <functional>
+#include <sstream>
+
 #include "DataTypeWriterBase.h"
 
 namespace relpipe {
@@ -16,6 +19,17 @@
 
 	virtual void writeValue(std::ostream& output, const T& value) = 0;
 
+	void writeRaw(std::ostream& output, const void * value, const std::type_info& type) override {
+		if (type == typeid (T)) {
+			const T v = *(static_cast<const T*>(value));
+			writeValue(output, v);
+		} else {
+			wstringstream message;
+			message << L"Data type in writeRaw() does not match – got: " << type.name() << " but expected: " << typeid (T).name();
+			throw RelpipeWriterException(message.str());
+		}
+	}
+
 	void writeString(std::ostream& output, const string_t &stringValue) override {
 		writeValue(output, toValue(stringValue));
 	}