use AttributeMetadata instead of std::pair for relation header v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Sun, 09 Sep 2018 21:01:17 +0200
branchv_0
changeset 22 e81019af67dc
parent 21 abd3e7f26584
child 23 25a53f4cd9eb
use AttributeMetadata instead of std::pair for relation header
include/relpipe/reader/handlers/AttributeMetadata.h
include/relpipe/reader/handlers/RelationalReaderBaseHandler.h
nbproject/configurations.xml
src/StreamRelationalReader.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/relpipe/reader/handlers/AttributeMetadata.h	Sun Sep 09 21:01:17 2018 +0200
@@ -0,0 +1,18 @@
+#pragma once
+
+#include "../TypeId.h"
+
+namespace relpipe {
+namespace reader {
+namespace handlers {
+
+class AttributeMetadata {
+public:
+	string_t attributeName;
+	relpipe::reader::TypeId typeId;
+	string_t typeName;
+};
+
+}
+}
+}
\ No newline at end of file
--- a/include/relpipe/reader/handlers/RelationalReaderBaseHandler.h	Sat Sep 08 23:27:49 2018 +0200
+++ b/include/relpipe/reader/handlers/RelationalReaderBaseHandler.h	Sun Sep 09 21:01:17 2018 +0200
@@ -3,6 +3,7 @@
 #include <vector>
 
 #include "../TypeId.h"
+#include "AttributeMetadata.h"
 
 namespace relpipe {
 namespace reader {
@@ -12,9 +13,9 @@
 public:
 	virtual ~RelationalReaderBaseHadler() = default;
 
-    virtual void startRelation(string_t name, std::vector<std::pair<string_t, TypeId>> attributes) = 0;
+	virtual void startRelation(string_t name, std::vector<AttributeMetadata> attributes) = 0;
 
-    virtual void endOfPipe() = 0;
+	virtual void endOfPipe() = 0;
 
 };
 
--- a/nbproject/configurations.xml	Sat Sep 08 23:27:49 2018 +0200
+++ b/nbproject/configurations.xml	Sun Sep 09 21:01:17 2018 +0200
@@ -4,6 +4,7 @@
     <logicalFolder name="HeaderFiles"
                    displayName="Header Files"
                    projectFiles="true">
+      <itemPath>include/relpipe/reader/handlers/AttributeMetadata.h</itemPath>
       <itemPath>src/types/BooleanDataTypeReader.h</itemPath>
       <itemPath>src/DataTypeReader.h</itemPath>
       <itemPath>src/DataTypeReaderBase.h</itemPath>
@@ -73,6 +74,11 @@
       </item>
       <item path="include/relpipe/reader/TypeId.h" ex="false" tool="3" flavor2="0">
       </item>
+      <item path="include/relpipe/reader/handlers/AttributeMetadata.h"
+            ex="false"
+            tool="3"
+            flavor2="0">
+      </item>
       <item path="include/relpipe/reader/handlers/RelationalReaderBaseHandler.h"
             ex="false"
             tool="3"
@@ -146,6 +152,11 @@
       </item>
       <item path="include/relpipe/reader/TypeId.h" ex="false" tool="3" flavor2="0">
       </item>
+      <item path="include/relpipe/reader/handlers/AttributeMetadata.h"
+            ex="false"
+            tool="3"
+            flavor2="0">
+      </item>
       <item path="include/relpipe/reader/handlers/RelationalReaderBaseHandler.h"
             ex="false"
             tool="3"
--- a/src/StreamRelationalReader.h	Sat Sep 08 23:27:49 2018 +0200
+++ b/src/StreamRelationalReader.h	Sun Sep 09 21:01:17 2018 +0200
@@ -50,7 +50,7 @@
 	 */
 	std::vector<TypeId> columnTypes;
 	std::vector<string_t> columnNames;
-	std::vector<std::pair<string_t, TypeId>> columns;
+	std::vector<handlers::AttributeMetadata> columns;
 
 	/**
 	 * TODO: remove?
@@ -155,10 +155,9 @@
 					TypeId typeId = (TypeId) integerReader.readValue(input); // TODO: přetypování OK?
 					string_t typeCode = toTypeCode(typeId); // validate typeId TODO: je potřeba?
 					columnTypes[i] = typeId;
-				}
 
-				for (int i = 0; i < columnCount; i++) {
-					columns[i] = {columnNames[i], columnTypes[i]};
+					// put together names, type ids and type codes:
+					columns[i] = {columnNames[i], columnTypes[i], typeCode};
 				}
 
 				for (StringHandler* handler : stringHandlers) handler->startRelation(tableName, columns);