--- a/include/RelationalWriter.h Sun Jul 22 17:19:25 2018 +0200
+++ b/include/RelationalWriter.h Sun Jul 22 22:21:49 2018 +0200
@@ -21,12 +21,14 @@
virtual void startRelation(string_t name, std::vector<std::pair<string_t, TypeId>> attributes, boolean_t writeHeader) = 0;
- virtual void writeRecord(std::vector<string_t> attributes) = 0;
-
+ virtual void writeAttribute(const string_t& value) = 0;
+
+ // TODO: fluent interface?
+ // TODO: << operator?
// TODO: write bitmap + attribute:
// virtual void writeBitmap(...) = 0;
// virtual void writeAttribute(string_t attribute) = 0;
-
+
virtual void writeAttribute(const void* value, const std::type_info& type) = 0;
};
--- a/src/StreamRelationalWriter.h Sun Jul 22 17:19:25 2018 +0200
+++ b/src/StreamRelationalWriter.h Sun Jul 22 22:21:49 2018 +0200
@@ -92,19 +92,10 @@
}
- void writeRecord(std::vector<string_t> attributes) override {
- // FIXME: check vector size
- // FIXME: check currentColumn == 0
- for (size_t c = 0; c < columnCount; c++) {
- // TODO: do not support multiple rows in a single method call
- if (c % columnCount == 0) {
- integerWriter.writeValue(output, DATA_PART_ROW);
- }
-
- wstring stringValue = attributes[c];
- TypeId typeId = columnTypes[c % columnCount];
- writeString(stringValue, typeId);
- }
+ void writeAttribute(const string_t& value) override {
+ if (currentColumn == 0) integerWriter.writeValue(output, DATA_PART_ROW);
+ writeString(value, columnTypes[currentColumn]);
+ if (++currentColumn == columnCount) currentColumn = 0;
}
void writeAttribute(const void* value, const std::type_info& type) override {