support „writeHeader = false“ to allow appending records to an existing relation v_0 v0.15
authorFrantišek Kučera <franta-hg@frantovo.cz>
Fri, 24 Jan 2020 20:49:46 +0100
branchv_0
changeset 47 77fbaccdeea4
parent 46 36245d405b8a
child 48 283700190338
support „writeHeader = false“ to allow appending records to an existing relation
src/StreamRelationalWriter.h
--- a/src/StreamRelationalWriter.h	Wed Dec 25 00:54:54 2019 +0100
+++ b/src/StreamRelationalWriter.h	Fri Jan 24 20:49:46 2020 +0100
@@ -88,23 +88,27 @@
 		currentColumn = 0;
 
 		// Write table name and column count:
-		integerWriter.writeValue(output, DATA_PART_START);
-		stringWriter.writeValue(output, tableName);
-		integerWriter.writeValue(output, columnCount);
+		if (writeHeader) {
+			integerWriter.writeValue(output, DATA_PART_START);
+			stringWriter.writeValue(output, tableName);
+			integerWriter.writeValue(output, columnCount);
+		}
 
 		columnTypes.clear();
 		columnTypes.resize(columnCount);
 
 		// Write column names:
-		for (size_t c = 0; c < columnCount; c++) {
-			wstring columnName = attributes[c].attributeName;
-			stringWriter.writeValue(output, columnName);
+		if (writeHeader) {
+			for (size_t c = 0; c < columnCount; c++) {
+				wstring columnName = attributes[c].attributeName;
+				stringWriter.writeValue(output, columnName);
+			}
 		}
 
 		// Write column types:
 		for (size_t c = 0; c < columnCount; c++) {
 			TypeId typeId = attributes[c].typeId;
-			integerWriter.writeValue(output, static_cast<integer_t> (typeId));
+			if (writeHeader) integerWriter.writeValue(output, static_cast<integer_t> (typeId));
 			columnTypes[c] = typeId;
 		}