use AttributeMetadata instead of std::pair for relation header v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Sun, 09 Sep 2018 23:20:57 +0200
branchv_0
changeset 27 a64afb2d24c9
parent 26 8ae93a43fed2
child 28 e436789e981e
use AttributeMetadata instead of std::pair for relation header
include/relpipe/writer/AttributeMetadata.h
include/relpipe/writer/RelationalWriter.h
nbproject/configurations.xml
src/StreamRelationalWriter.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/relpipe/writer/AttributeMetadata.h	Sun Sep 09 23:20:57 2018 +0200
@@ -0,0 +1,15 @@
+#pragma once
+
+#include "TypeId.h"
+
+namespace relpipe {
+namespace writer {
+
+class AttributeMetadata {
+public:
+	string_t attributeName;
+	relpipe::writer::TypeId typeId;
+};
+
+}
+}
\ No newline at end of file
--- a/include/relpipe/writer/RelationalWriter.h	Mon Sep 03 23:41:29 2018 +0200
+++ b/include/relpipe/writer/RelationalWriter.h	Sun Sep 09 23:20:57 2018 +0200
@@ -5,6 +5,7 @@
 
 #include "typedefs.h"
 #include "TypeId.h"
+#include "AttributeMetadata.h"
 
 namespace relpipe {
 namespace writer {
@@ -28,7 +29,7 @@
 	 * @param attributes list of attributes (columns) containing their names and types
 	 * @param writeHeader header might be omitted – when appending new records to a stream alreaready containing the header
 	 */
-	virtual void startRelation(string_t name, std::vector<std::pair<string_t, TypeId>> attributes, boolean_t writeHeader) = 0;
+	virtual void startRelation(string_t name, std::vector<AttributeMetadata> attributes, boolean_t writeHeader) = 0;
 
 	/**
 	 * Writes a single attribute.
--- a/nbproject/configurations.xml	Mon Sep 03 23:41:29 2018 +0200
+++ b/nbproject/configurations.xml	Sun Sep 09 23:20:57 2018 +0200
@@ -4,6 +4,7 @@
     <logicalFolder name="HeaderFiles"
                    displayName="Header Files"
                    projectFiles="true">
+      <itemPath>include/relpipe/writer/AttributeMetadata.h</itemPath>
       <itemPath>src/types/BooleanDataTypeWriter.h</itemPath>
       <itemPath>src/DataTypeWriter.h</itemPath>
       <itemPath>src/DataTypeWriterBase.h</itemPath>
@@ -55,6 +56,11 @@
           </linkerLibItems>
         </linkerTool>
       </compileType>
+      <item path="include/relpipe/writer/AttributeMetadata.h"
+            ex="false"
+            tool="3"
+            flavor2="0">
+      </item>
       <item path="include/relpipe/writer/Factory.h" ex="false" tool="3" flavor2="0">
       </item>
       <item path="include/relpipe/writer/RelationalWriter.h"
@@ -111,6 +117,11 @@
           </linkerLibItems>
         </linkerTool>
       </compileType>
+      <item path="include/relpipe/writer/AttributeMetadata.h"
+            ex="false"
+            tool="3"
+            flavor2="0">
+      </item>
       <item path="include/relpipe/writer/Factory.h" ex="false" tool="3" flavor2="0">
       </item>
       <item path="include/relpipe/writer/RelationalWriter.h"
--- a/src/StreamRelationalWriter.h	Mon Sep 03 23:41:29 2018 +0200
+++ b/src/StreamRelationalWriter.h	Sun Sep 09 23:20:57 2018 +0200
@@ -9,6 +9,7 @@
 #include "../include/relpipe/writer/typedefs.h"
 #include "../include/relpipe/writer/RelationalWriter.h"
 #include "../include/relpipe/writer/TypeId.h"
+#include "../include/relpipe/writer/AttributeMetadata.h"
 #include "DataTypeWriterBase.h"
 #include "types/BooleanDataTypeWriter.h"
 #include "types/IntegerDataTypeWriter.h"
@@ -62,7 +63,7 @@
 		throw RelpipeWriterException(L"Unsupported data type: " + typeCode);
 	}
 
-	void startRelation(string_t name, std::vector<std::pair<string_t, TypeId> > attributes, boolean_t writeHeader) override {
+	void startRelation(string_t name, std::vector<AttributeMetadata> attributes, boolean_t writeHeader) override {
 		string_t tableName = name;
 		columnCount = attributes.size();
 		currentColumn = 0;
@@ -77,13 +78,13 @@
 
 		// Write column names:
 		for (size_t c = 0; c < columnCount; c++) {
-			wstring columnName = attributes[c].first;
+			wstring columnName = attributes[c].attributeName;
 			stringWriter.writeValue(output, columnName);
 		}
 
 		// Write column types:
 		for (size_t c = 0; c < columnCount; c++) {
-			TypeId typeId = attributes[c].second;
+			TypeId typeId = attributes[c].typeId;
 			integerWriter.writeValue(output, static_cast<integer_t> (typeId));
 			columnTypes[c] = typeId;
 		}