author | František Kučera <franta-hg@frantovo.cz> |
Thu, 20 Dec 2018 00:26:00 +0100 | |
branch | v_0 |
changeset 34 | bd596c95395b |
parent 30 | 3f18cb7a6963 |
child 41 | 744b61559eb2 |
permissions | -rw-r--r-- |
29
142bdbba520f
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
23
diff
changeset
|
1 |
/** |
30
3f18cb7a6963
license of protocol, reader and writer: GNU LGPLv3+ or GNU GPLv2+
František Kučera <franta-hg@frantovo.cz>
parents:
29
diff
changeset
|
2 |
* Relational pipes (library) |
29
142bdbba520f
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
23
diff
changeset
|
3 |
* Copyright © 2018 František Kučera (Frantovo.cz, GlobalCode.info) |
142bdbba520f
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
23
diff
changeset
|
4 |
* |
142bdbba520f
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
23
diff
changeset
|
5 |
* This program is free software: you can redistribute it and/or modify |
30
3f18cb7a6963
license of protocol, reader and writer: GNU LGPLv3+ or GNU GPLv2+
František Kučera <franta-hg@frantovo.cz>
parents:
29
diff
changeset
|
6 |
* it under the terms of the: |
3f18cb7a6963
license of protocol, reader and writer: GNU LGPLv3+ or GNU GPLv2+
František Kučera <franta-hg@frantovo.cz>
parents:
29
diff
changeset
|
7 |
* - GNU Lesser General Public License as published by the Free Software Foundation; |
3f18cb7a6963
license of protocol, reader and writer: GNU LGPLv3+ or GNU GPLv2+
František Kučera <franta-hg@frantovo.cz>
parents:
29
diff
changeset
|
8 |
* either version 3 of the License, or (at your option) any later version; |
3f18cb7a6963
license of protocol, reader and writer: GNU LGPLv3+ or GNU GPLv2+
František Kučera <franta-hg@frantovo.cz>
parents:
29
diff
changeset
|
9 |
* or (at your option) |
3f18cb7a6963
license of protocol, reader and writer: GNU LGPLv3+ or GNU GPLv2+
František Kučera <franta-hg@frantovo.cz>
parents:
29
diff
changeset
|
10 |
* - GNU General Public License as published by the Free Software Foundation; |
3f18cb7a6963
license of protocol, reader and writer: GNU LGPLv3+ or GNU GPLv2+
František Kučera <franta-hg@frantovo.cz>
parents:
29
diff
changeset
|
11 |
* either version 2 of the License, or (at your option) any later version. |
29
142bdbba520f
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
23
diff
changeset
|
12 |
* |
142bdbba520f
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
23
diff
changeset
|
13 |
* This program is distributed in the hope that it will be useful, |
142bdbba520f
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
23
diff
changeset
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
142bdbba520f
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
23
diff
changeset
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
142bdbba520f
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
23
diff
changeset
|
16 |
* GNU General Public License for more details. |
142bdbba520f
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
23
diff
changeset
|
17 |
* |
142bdbba520f
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
23
diff
changeset
|
18 |
* You should have received a copy of the GNU General Public License |
142bdbba520f
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
23
diff
changeset
|
19 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
142bdbba520f
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
23
diff
changeset
|
20 |
*/ |
7
01dd90eeedbb
add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
21 |
#pragma once |
01dd90eeedbb
add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
22 |
|
01dd90eeedbb
add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
23 |
#include <string> |
01dd90eeedbb
add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
24 |
#include <iostream> |
01dd90eeedbb
add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
25 |
|
23
d505eaedc35e
remove format.h and use constants.h from lib-protocol
František Kučera <franta-hg@frantovo.cz>
parents:
20
diff
changeset
|
26 |
#include <relpipe/protocol/constants.h> |
d505eaedc35e
remove format.h and use constants.h from lib-protocol
František Kučera <franta-hg@frantovo.cz>
parents:
20
diff
changeset
|
27 |
|
20
bef6648e79b1
relpipe-lib-writer: move public header files to: include/relpipe/writer/
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
28 |
#include "../../include/relpipe/writer/RelpipeWriterException.h" |
10
40ab091e5dfa
move *DataTypeWriter.h to separate directory
František Kučera <franta-hg@frantovo.cz>
parents:
9
diff
changeset
|
29 |
#include "../DataTypeWriter.h" |
7
01dd90eeedbb
add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
30 |
|
8
03750aff8619
writer only writes + refactoring
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
31 |
namespace relpipe { |
03750aff8619
writer only writes + refactoring
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
32 |
namespace writer { |
10
40ab091e5dfa
move *DataTypeWriter.h to separate directory
František Kučera <franta-hg@frantovo.cz>
parents:
9
diff
changeset
|
33 |
namespace types { |
40ab091e5dfa
move *DataTypeWriter.h to separate directory
František Kučera <franta-hg@frantovo.cz>
parents:
9
diff
changeset
|
34 |
|
23
d505eaedc35e
remove format.h and use constants.h from lib-protocol
František Kučera <franta-hg@frantovo.cz>
parents:
20
diff
changeset
|
35 |
using namespace relpipe::protocol; |
10
40ab091e5dfa
move *DataTypeWriter.h to separate directory
František Kučera <franta-hg@frantovo.cz>
parents:
9
diff
changeset
|
36 |
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
|
37 |
|
8
03750aff8619
writer only writes + refactoring
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
38 |
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
|
39 |
private: |
13
e7234dd45166
use TypeId enum instead of numeric constants
František Kučera <franta-hg@frantovo.cz>
parents:
10
diff
changeset
|
40 |
const string_t TRUE = L"true"; |
8
03750aff8619
writer only writes + refactoring
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
41 |
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
|
42 |
public: |
01dd90eeedbb
add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
43 |
|
15
8fd6c4d44071
use more TypeId enum
František Kučera <franta-hg@frantovo.cz>
parents:
13
diff
changeset
|
44 |
BooleanDataTypeWriter() : DataTypeWriter<boolean_t>(TypeId::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
|
45 |
} |
01dd90eeedbb
add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
46 |
|
8
03750aff8619
writer only writes + refactoring
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
47 |
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
|
48 |
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
|
49 |
} |
01dd90eeedbb
add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
50 |
|
8
03750aff8619
writer only writes + refactoring
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
51 |
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
|
52 |
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
|
53 |
else if (stringValue == FALSE) return false; |
8
03750aff8619
writer only writes + refactoring
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
54 |
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
|
55 |
} |
01dd90eeedbb
add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
56 |
|
01dd90eeedbb
add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
57 |
}; |
01dd90eeedbb
add data type and catalog classes from the prototype
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
58 |
|
8
03750aff8619
writer only writes + refactoring
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
59 |
} |
10
40ab091e5dfa
move *DataTypeWriter.h to separate directory
František Kučera <franta-hg@frantovo.cz>
parents:
9
diff
changeset
|
60 |
} |
13
e7234dd45166
use TypeId enum instead of numeric constants
František Kučera <franta-hg@frantovo.cz>
parents:
10
diff
changeset
|
61 |
} |