author | František Kučera <franta-hg@frantovo.cz> |
Thu, 29 Nov 2018 22:30:12 +0100 | |
branch | v_0 |
changeset 29 | 142bdbba520f |
parent 25 | 135ef93a4ac2 |
child 30 | 3f18cb7a6963 |
permissions | -rw-r--r-- |
29
142bdbba520f
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
25
diff
changeset
|
1 |
/** |
142bdbba520f
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
25
diff
changeset
|
2 |
* Relational pipes |
142bdbba520f
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
25
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:
25
diff
changeset
|
4 |
* |
142bdbba520f
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
25
diff
changeset
|
5 |
* This program is free software: you can redistribute it and/or modify |
142bdbba520f
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
25
diff
changeset
|
6 |
* it under the terms of the GNU General Public License as published by |
142bdbba520f
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
25
diff
changeset
|
7 |
* the Free Software Foundation, either version 3 of the License, or |
142bdbba520f
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
25
diff
changeset
|
8 |
* (at your option) any later version. |
142bdbba520f
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
25
diff
changeset
|
9 |
* |
142bdbba520f
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
25
diff
changeset
|
10 |
* 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:
25
diff
changeset
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
142bdbba520f
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
25
diff
changeset
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
142bdbba520f
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
25
diff
changeset
|
13 |
* GNU General Public License for more details. |
142bdbba520f
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
25
diff
changeset
|
14 |
* |
142bdbba520f
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
25
diff
changeset
|
15 |
* 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:
25
diff
changeset
|
16 |
* 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:
25
diff
changeset
|
17 |
*/ |
21
118b68d73420
static_assert to enforce compliance with common constants in lib-protocol
František Kučera <franta-hg@frantovo.cz>
parents:
20
diff
changeset
|
18 |
#include <relpipe/protocol/constants.h> |
118b68d73420
static_assert to enforce compliance with common constants in lib-protocol
František Kučera <franta-hg@frantovo.cz>
parents:
20
diff
changeset
|
19 |
|
25
135ef93a4ac2
imports, namespaces
František Kučera <franta-hg@frantovo.cz>
parents:
21
diff
changeset
|
20 |
#include "../include/relpipe/writer/TypeId.h" |
20
bef6648e79b1
relpipe-lib-writer: move public header files to: include/relpipe/writer/
František Kučera <franta-hg@frantovo.cz>
parents:
14
diff
changeset
|
21 |
#include "../include/relpipe/writer/RelationalWriter.h" |
bef6648e79b1
relpipe-lib-writer: move public header files to: include/relpipe/writer/
František Kučera <franta-hg@frantovo.cz>
parents:
14
diff
changeset
|
22 |
#include "../include/relpipe/writer/Factory.h" |
9
0a40752e401d
shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
23 |
#include "StreamRelationalWriter.h" |
0a40752e401d
shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
24 |
|
0a40752e401d
shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
25 |
namespace relpipe { |
0a40752e401d
shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
26 |
namespace writer { |
0a40752e401d
shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
27 |
|
14
733334eca89b
move create() method to a factory
František Kučera <franta-hg@frantovo.cz>
parents:
9
diff
changeset
|
28 |
RelationalWriter* Factory::create(std::ostream& output) { |
9
0a40752e401d
shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
29 |
return new StreamRelationalWriter(output); |
0a40752e401d
shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
30 |
} |
0a40752e401d
shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
31 |
|
21
118b68d73420
static_assert to enforce compliance with common constants in lib-protocol
František Kučera <franta-hg@frantovo.cz>
parents:
20
diff
changeset
|
32 |
/** |
118b68d73420
static_assert to enforce compliance with common constants in lib-protocol
František Kučera <franta-hg@frantovo.cz>
parents:
20
diff
changeset
|
33 |
* Some basic constants defined in lib-protocol are re-exported in public headers of lib-reader and lib-writer, |
118b68d73420
static_assert to enforce compliance with common constants in lib-protocol
František Kučera <franta-hg@frantovo.cz>
parents:
20
diff
changeset
|
34 |
* so we should check (during compile-time) that they match. |
118b68d73420
static_assert to enforce compliance with common constants in lib-protocol
František Kučera <franta-hg@frantovo.cz>
parents:
20
diff
changeset
|
35 |
*/ |
118b68d73420
static_assert to enforce compliance with common constants in lib-protocol
František Kučera <franta-hg@frantovo.cz>
parents:
20
diff
changeset
|
36 |
#define PROTOCOL_VIOLATION_TYPE_ID_ERROR "type id does not match with protocol" |
118b68d73420
static_assert to enforce compliance with common constants in lib-protocol
František Kučera <franta-hg@frantovo.cz>
parents:
20
diff
changeset
|
37 |
static_assert((int) TypeId::BOOLEAN == relpipe::protocol::DATA_TYPE_ID_BOOLEAN, PROTOCOL_VIOLATION_TYPE_ID_ERROR); |
118b68d73420
static_assert to enforce compliance with common constants in lib-protocol
František Kučera <franta-hg@frantovo.cz>
parents:
20
diff
changeset
|
38 |
static_assert((int) TypeId::STRING == relpipe::protocol::DATA_TYPE_ID_STRING, PROTOCOL_VIOLATION_TYPE_ID_ERROR); |
118b68d73420
static_assert to enforce compliance with common constants in lib-protocol
František Kučera <franta-hg@frantovo.cz>
parents:
20
diff
changeset
|
39 |
static_assert((int) TypeId::INTEGER == relpipe::protocol::DATA_TYPE_ID_INTEGER, PROTOCOL_VIOLATION_TYPE_ID_ERROR); |
118b68d73420
static_assert to enforce compliance with common constants in lib-protocol
František Kučera <franta-hg@frantovo.cz>
parents:
20
diff
changeset
|
40 |
|
118b68d73420
static_assert to enforce compliance with common constants in lib-protocol
František Kučera <franta-hg@frantovo.cz>
parents:
20
diff
changeset
|
41 |
#define PROTOCOL_VIOLATION_TYPE_DEF_ERROR "type definition does not match with protocol" |
118b68d73420
static_assert to enforce compliance with common constants in lib-protocol
František Kučera <franta-hg@frantovo.cz>
parents:
20
diff
changeset
|
42 |
static_assert(std::is_same<relpipe::writer::boolean_t, typename relpipe::protocol::boolean_t>::value, PROTOCOL_VIOLATION_TYPE_DEF_ERROR); |
118b68d73420
static_assert to enforce compliance with common constants in lib-protocol
František Kučera <franta-hg@frantovo.cz>
parents:
20
diff
changeset
|
43 |
static_assert(std::is_same<relpipe::writer::integer_t, typename relpipe::protocol::integer_t>::value, PROTOCOL_VIOLATION_TYPE_DEF_ERROR); |
118b68d73420
static_assert to enforce compliance with common constants in lib-protocol
František Kučera <franta-hg@frantovo.cz>
parents:
20
diff
changeset
|
44 |
static_assert(std::is_same<relpipe::writer::string_t, typename relpipe::protocol::string_t>::value, PROTOCOL_VIOLATION_TYPE_DEF_ERROR); |
118b68d73420
static_assert to enforce compliance with common constants in lib-protocol
František Kučera <franta-hg@frantovo.cz>
parents:
20
diff
changeset
|
45 |
static_assert(std::is_same<relpipe::writer::octet_t, typename relpipe::protocol::octet_t>::value, PROTOCOL_VIOLATION_TYPE_DEF_ERROR); |
118b68d73420
static_assert to enforce compliance with common constants in lib-protocol
František Kučera <franta-hg@frantovo.cz>
parents:
20
diff
changeset
|
46 |
|
9
0a40752e401d
shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
47 |
} |
0a40752e401d
shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
48 |
} |