author | František Kučera <franta-hg@frantovo.cz> |
Sat, 21 Jul 2018 19:04:37 +0200 | |
branch | v_0 |
changeset 10 | 40ab091e5dfa |
parent 9 | src/BooleanDataTypeWriter.h@0a40752e401d |
child 13 | e7234dd45166 |
permissions | -rw-r--r-- |
7
01dd90eeedbb
add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
1 |
#pragma once |
01dd90eeedbb
add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
2 |
|
01dd90eeedbb
add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
3 |
#include <string> |
01dd90eeedbb
add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
4 |
#include <iostream> |
01dd90eeedbb
add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
5 |
|
10
40ab091e5dfa
move *DataTypeWriter.h to separate directory
František Kučera <franta-hg@frantovo.cz>
parents:
9
diff
changeset
|
6 |
#include "../../include/RelpipeWriterException.h" |
40ab091e5dfa
move *DataTypeWriter.h to separate directory
František Kučera <franta-hg@frantovo.cz>
parents:
9
diff
changeset
|
7 |
#include "../DataTypeWriter.h" |
40ab091e5dfa
move *DataTypeWriter.h to separate directory
František Kučera <franta-hg@frantovo.cz>
parents:
9
diff
changeset
|
8 |
#include "../format.h" |
7
01dd90eeedbb
add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
9 |
|
8
03750aff8619
writer only writes + refactoring
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
10 |
namespace relpipe { |
03750aff8619
writer only writes + refactoring
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
11 |
namespace writer { |
10
40ab091e5dfa
move *DataTypeWriter.h to separate directory
František Kučera <franta-hg@frantovo.cz>
parents:
9
diff
changeset
|
12 |
namespace types { |
40ab091e5dfa
move *DataTypeWriter.h to separate directory
František Kučera <franta-hg@frantovo.cz>
parents:
9
diff
changeset
|
13 |
|
40ab091e5dfa
move *DataTypeWriter.h to separate directory
František Kučera <franta-hg@frantovo.cz>
parents:
9
diff
changeset
|
14 |
using namespace relpipe::writer; |
7
01dd90eeedbb
add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
15 |
|
8
03750aff8619
writer only writes + refactoring
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
16 |
class BooleanDataTypeWriter : public DataTypeWriter<boolean_t> { |
7
01dd90eeedbb
add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
17 |
private: |
8
03750aff8619
writer only writes + refactoring
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
18 |
const string_t TRUE = L"true"; |
03750aff8619
writer only writes + refactoring
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
19 |
const string_t FALSE = L"false"; |
7
01dd90eeedbb
add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
20 |
public: |
01dd90eeedbb
add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
21 |
|
8
03750aff8619
writer only writes + refactoring
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
22 |
BooleanDataTypeWriter() : DataTypeWriter<boolean_t>(DATA_TYPE_ID_BOOLEAN, DATA_TYPE_CODE_BOOLEAN) { |
7
01dd90eeedbb
add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
23 |
} |
01dd90eeedbb
add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
24 |
|
8
03750aff8619
writer only writes + refactoring
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
25 |
void writeValue(std::ostream &output, const boolean_t &value) override { |
7
01dd90eeedbb
add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
26 |
output.put(value ? 1 : 0); |
01dd90eeedbb
add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
27 |
} |
01dd90eeedbb
add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
28 |
|
8
03750aff8619
writer only writes + refactoring
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
29 |
bool toValue(const string_t &stringValue) override { |
7
01dd90eeedbb
add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
30 |
if (stringValue == TRUE) return true; |
01dd90eeedbb
add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
31 |
else if (stringValue == FALSE) return false; |
8
03750aff8619
writer only writes + refactoring
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
32 |
else throw RelpipeWriterException(L"Unable to convert the string to boolean"); |
7
01dd90eeedbb
add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
33 |
} |
01dd90eeedbb
add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
34 |
|
01dd90eeedbb
add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
35 |
}; |
01dd90eeedbb
add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
36 |
|
8
03750aff8619
writer only writes + refactoring
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
37 |
} |
10
40ab091e5dfa
move *DataTypeWriter.h to separate directory
František Kučera <franta-hg@frantovo.cz>
parents:
9
diff
changeset
|
38 |
} |
7
01dd90eeedbb
add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
39 |
} |