5 #include <vector> |
5 #include <vector> |
6 |
6 |
7 #include "../include/typedefs.h" |
7 #include "../include/typedefs.h" |
8 #include "../include/RelationalWriter.h" |
8 #include "../include/RelationalWriter.h" |
9 #include "DataTypeWriterBase.h" |
9 #include "DataTypeWriterBase.h" |
10 #include "BooleanDataTypeWriter.h" |
10 #include "types/BooleanDataTypeWriter.h" |
11 #include "IntegerDataTypeWriter.h" |
11 #include "types/IntegerDataTypeWriter.h" |
12 #include "StringDataTypeWriter.h" |
12 #include "types/StringDataTypeWriter.h" |
13 |
13 |
14 namespace relpipe { |
14 namespace relpipe { |
15 namespace writer { |
15 namespace writer { |
16 |
16 |
17 class StreamRelationalWriter : public RelationalWriter { |
17 class StreamRelationalWriter : public RelationalWriter { |
18 private: |
18 private: |
19 std::ostream &output; |
19 std::ostream &output; |
20 BooleanDataTypeWriter booleanWriter; |
20 types::BooleanDataTypeWriter booleanWriter; |
21 IntegerDataTypeWriter integerWriter; |
21 types::IntegerDataTypeWriter integerWriter; |
22 StringDataTypeWriter stringWriter; |
22 types::StringDataTypeWriter stringWriter; |
23 vector<DataTypeWriterBase*> writers = {&booleanWriter, &integerWriter, &stringWriter}; |
23 vector<DataTypeWriterBase*> writers = {&booleanWriter, &integerWriter, &stringWriter}; |
24 |
24 |
25 void writeString(const string_t &stringValue, const integer_t typeId) { |
25 void writeString(const string_t &stringValue, const integer_t typeId) { |
26 for (DataTypeWriterBase* writer : writers) if (writer->supports(typeId)) return writer->writeString(output, stringValue); |
26 for (DataTypeWriterBase* writer : writers) if (writer->supports(typeId)) return writer->writeString(output, stringValue); |
27 throw RelpipeWriterException(L"Unsupported data type: " + typeId); |
27 throw RelpipeWriterException(L"Unsupported data type: " + typeId); |