equal
deleted
inserted
replaced
|
1 #pragma once |
|
2 |
|
3 #include <string> |
|
4 #include <iostream> |
|
5 #include <vector> |
|
6 |
|
7 #include <relpipe/protocol/constants.h> |
|
8 |
|
9 #include "../include/relpipe/reader/typedefs.h" |
|
10 #include "../include/relpipe/reader/RelationalReader.h" |
|
11 #include "../include/relpipe/reader/TypeId.h" |
|
12 #include "DataTypeReaderBase.h" |
|
13 #include "types/BooleanDataTypeReader.h" |
|
14 #include "types/IntegerDataTypeReader.h" |
|
15 #include "types/StringDataTypeReader.h" |
|
16 |
|
17 namespace relpipe { |
|
18 namespace reader { |
|
19 |
|
20 using namespace relpipe::protocol; |
|
21 |
|
22 class StreamRelationalReader : public RelationalReader { |
|
23 private: |
|
24 std::istream &input; |
|
25 types::BooleanDataTypeReader booleanReader; |
|
26 types::IntegerDataTypeReader integerReader; |
|
27 types::StringDataTypeReader stringReader; |
|
28 std::vector<DataTypeReaderBase*> readers = {&booleanReader, &integerReader, &stringReader}; |
|
29 |
|
30 /** |
|
31 * count of columns in the current table |
|
32 */ |
|
33 integer_t columnCount; |
|
34 /** |
|
35 * number of column (0 = first) that will be written; after writing, the number is increased and prepared for next one |
|
36 */ |
|
37 integer_t currentColumn; |
|
38 |
|
39 /** |
|
40 * types of columns in the current table |
|
41 */ |
|
42 std::vector<TypeId> columnTypes; |
|
43 |
|
44 public: |
|
45 |
|
46 StreamRelationalReader(std::istream &input) : |
|
47 input(input) { |
|
48 } |
|
49 |
|
50 string_t toTypeCode(const TypeId typeId) override { |
|
51 for (DataTypeReaderBase* reader : readers) if (reader->supports(typeId)) return reader->getTypeCode(); |
|
52 throw RelpipeReaderException(L"Unsupported data type: " + static_cast<integer_t> (typeId)); |
|
53 } |
|
54 |
|
55 }; |
|
56 |
|
57 } |
|
58 } |