author | František Kučera <franta-hg@frantovo.cz> |
Sat, 25 Aug 2018 17:04:11 +0200 | |
branch | v_0 |
changeset 12 | 2d7109286408 |
parent 8 | c87e9c84f7aa |
permissions | -rw-r--r-- |
7
489e52138771
add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
1 |
#pragma once |
489e52138771
add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
2 |
|
489e52138771
add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
3 |
#include <string> |
489e52138771
add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
4 |
#include <iostream> |
489e52138771
add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
5 |
#include <vector> |
489e52138771
add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
6 |
|
8
c87e9c84f7aa
reader only reads + refactoring
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
7 |
#include "../include/typedefs.h" |
c87e9c84f7aa
reader only reads + refactoring
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
8 |
#include "../include/DataTypeReaderBase.h" |
c87e9c84f7aa
reader only reads + refactoring
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
9 |
#include "../include/RelpipeReaderException.h" |
c87e9c84f7aa
reader only reads + refactoring
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
10 |
|
c87e9c84f7aa
reader only reads + refactoring
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
11 |
#include "BooleanDataTypeReader.h" |
c87e9c84f7aa
reader only reads + refactoring
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
12 |
#include "IntegerDataTypeReader.h" |
c87e9c84f7aa
reader only reads + refactoring
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
13 |
#include "StringDataTypeReader.h" |
7
489e52138771
add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
14 |
|
489e52138771
add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
15 |
using namespace std; |
489e52138771
add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
16 |
|
8
c87e9c84f7aa
reader only reads + refactoring
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
17 |
namespace relpipe { |
c87e9c84f7aa
reader only reads + refactoring
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
18 |
namespace reader { |
7
489e52138771
add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
19 |
|
8
c87e9c84f7aa
reader only reads + refactoring
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
20 |
class DataTypeReaderCatalog { |
7
489e52138771
add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
21 |
private: |
8
c87e9c84f7aa
reader only reads + refactoring
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
22 |
BooleanDataTypeReader booleanReader; |
c87e9c84f7aa
reader only reads + refactoring
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
23 |
IntegerDataTypeReader integerReader; |
c87e9c84f7aa
reader only reads + refactoring
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
24 |
StringDataTypeReader stringReader; |
c87e9c84f7aa
reader only reads + refactoring
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
25 |
vector<DataTypeReaderBase*> readers = {&booleanReader, &integerReader, &stringReader}; |
7
489e52138771
add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
26 |
public: |
489e52138771
add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
27 |
|
489e52138771
add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
28 |
integer_t toTypeId(const wstring typeCode) { |
8
c87e9c84f7aa
reader only reads + refactoring
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
29 |
for (DataTypeReaderBase* reader : readers) if (reader->supports(typeCode)) return reader->getTypeId(); |
c87e9c84f7aa
reader only reads + refactoring
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
30 |
throw RelpipeReaderException(L"Unsupported data type: " + typeCode); |
7
489e52138771
add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
31 |
} |
489e52138771
add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
32 |
|
489e52138771
add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
33 |
wstring toTypeCode(const integer_t typeId) { |
8
c87e9c84f7aa
reader only reads + refactoring
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
34 |
for (DataTypeReaderBase* reader : readers) if (reader->supports(typeId)) return reader->getTypeCode(); |
c87e9c84f7aa
reader only reads + refactoring
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
35 |
throw RelpipeReaderException(L"Unsupported data type: " + typeId); |
7
489e52138771
add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
36 |
} |
489e52138771
add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
37 |
|
489e52138771
add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
38 |
wstring readString(istream &input, const integer_t typeId) { |
8
c87e9c84f7aa
reader only reads + refactoring
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
39 |
for (DataTypeReaderBase* reader : readers) if (reader->supports(typeId)) return reader->readString(input); |
c87e9c84f7aa
reader only reads + refactoring
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
40 |
throw RelpipeReaderException(L"Unsupported data type: " + typeId); |
7
489e52138771
add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
41 |
} |
489e52138771
add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
42 |
|
489e52138771
add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
43 |
}; |
489e52138771
add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
44 |
|
8
c87e9c84f7aa
reader only reads + refactoring
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
45 |
} |
7
489e52138771
add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
46 |
} |