writeAttribute() with raw pointer and type_info v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Sun, 22 Jul 2018 17:19:33 +0200
branchv_0
changeset 7 9ac885dd8037
parent 6 4585c212a767
child 8 c1472544d95a
writeAttribute() with raw pointer and type_info
relpipe-in-cli.cpp
--- a/relpipe-in-cli.cpp	Sun Jul 22 00:08:24 2018 +0200
+++ b/relpipe-in-cli.cpp	Sun Jul 22 17:19:33 2018 +0200
@@ -1,6 +1,8 @@
 #include <cstdlib>
 #include <memory>
 
+#include <tuple>
+
 #include <RelationalWriter.h>
 #include <Factory.h>
 #include <TypeId.h>
@@ -9,6 +11,8 @@
 	using namespace relpipe::writer;
 	std::shared_ptr<RelationalWriter> writer(Factory::create(std::cout));
 
+
+	// All strings
 	writer->startRelation(L"my_first_table",{
 		{L"a1", TypeId::STRING},
 		{L"a2", TypeId::STRING},
@@ -18,7 +22,9 @@
 	writer->writeRecord({L"1.1", L"1.2", L"1.3"});
 	writer->writeRecord({L"2.1", L"2.2", L"2.3"});
 	writer->writeRecord({L"3.1", L"3.2", L"3.3"});
-	
+
+
+	// Various data types passed as strings
 	writer->startRelation(L"my_second_table",{
 		{L"s", TypeId::STRING},
 		{L"i", TypeId::INTEGER},
@@ -29,5 +35,23 @@
 	writer->writeRecord({L"b", L"2", L"false"});
 	writer->writeRecord({L"c", L"3", L"true"});
 
+
+	// Various data types passed as raw pointers + typeids
+	writer->startRelation(L"my_raw_table",{
+		{L"s", TypeId::STRING},
+		{L"i", TypeId::INTEGER},
+		{L"b", TypeId::BOOLEAN}
+	}, true);
+
+	for (int i = 0; i < 3; i++) {
+		string_t sValue = L"s";
+		integer_t iValue = i;
+		boolean_t bValue = i % 2 == 0;
+
+		writer->writeAttribute(&sValue, typeid(sValue));
+		writer->writeAttribute(&iValue, typeid(iValue));
+		writer->writeAttribute(&bValue, typeid(bValue));
+	}
+
 	return 0;
 }