author | František Kučera <franta-hg@frantovo.cz> |
Sun, 19 Aug 2018 20:36:33 +0200 | |
branch | v_0 |
changeset 21 | 118b68d73420 |
parent 20 | bef6648e79b1 |
child 25 | 135ef93a4ac2 |
permissions | -rw-r--r-- |
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
|
1 |
#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
|
2 |
|
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
|
3 |
#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
|
4 |
#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
|
5 |
#include "StreamRelationalWriter.h" |
0a40752e401d
shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
6 |
|
0a40752e401d
shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
7 |
namespace relpipe { |
0a40752e401d
shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
8 |
namespace writer { |
0a40752e401d
shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
9 |
|
14
733334eca89b
move create() method to a factory
František Kučera <franta-hg@frantovo.cz>
parents:
9
diff
changeset
|
10 |
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
|
11 |
return new StreamRelationalWriter(output); |
0a40752e401d
shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
12 |
} |
0a40752e401d
shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
13 |
|
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
|
14 |
/** |
118b68d73420
static_assert to enforce compliance with common constants in lib-protocol
František Kučera <franta-hg@frantovo.cz>
parents:
20
diff
changeset
|
15 |
* 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
|
16 |
* 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
|
17 |
*/ |
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 |
#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
|
19 |
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
|
20 |
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
|
21 |
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
|
22 |
|
118b68d73420
static_assert to enforce compliance with common constants in lib-protocol
František Kučera <franta-hg@frantovo.cz>
parents:
20
diff
changeset
|
23 |
#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
|
24 |
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
|
25 |
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
|
26 |
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
|
27 |
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
|
28 |
|
9
0a40752e401d
shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
29 |
} |
0a40752e401d
shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
30 |
} |