BufferingMode: set default mode from the constructor v_0 tip
authorFrantišek Kučera <franta-hg@frantovo.cz>
Sat, 23 Apr 2022 23:51:13 +0200
branchv_0
changeset 60 1b20c1e03065
parent 59 4fce579bed22
BufferingMode: set default mode from the constructor
src/StreamRelationalWriter.h
--- a/src/StreamRelationalWriter.h	Sat Apr 23 23:23:29 2022 +0200
+++ b/src/StreamRelationalWriter.h	Sat Apr 23 23:51:13 2022 +0200
@@ -48,8 +48,8 @@
 	types::IntegerDataTypeWriter integerWriter;
 	types::StringDataTypeWriter stringWriter;
 	std::vector<DataTypeWriterBase*> writers = {&booleanWriter, &integerWriter, &stringWriter};
-	BufferingMode bufferingMode = BufferingMode::ENVIRONMENT;
-	BufferingMode bufferingModeEnvDefault = BufferingMode::AUTO;
+	BufferingMode bufferingMode;
+	BufferingMode bufferingModeEnvDefault;
 
 	/**
 	 * count of columns in the current table
@@ -103,6 +103,7 @@
 
 	StreamRelationalWriter(std::ostream &output) :
 	output(output) {
+		setBufferingMode(BufferingMode::ENVIRONMENT, BufferingMode::AUTO);
 	}
 
 	TypeId toTypeId(const string_t typeCode) override {
@@ -115,8 +116,6 @@
 		columnCount = attributes.size();
 		currentColumn = 0;
 
-		updateBufferingMode();
-
 		// Write table name and column count:
 		if (writeHeader) {
 			integerWriter.writeValue(output, DATA_PART_START);
@@ -172,6 +171,7 @@
 	void setBufferingMode(BufferingMode mode, BufferingMode envDefault) override {
 		bufferingMode = mode;
 		bufferingModeEnvDefault = envDefault;
+		updateBufferingMode();
 	}
 
 };