1 #include <cstdlib> |
1 #include <cstdlib> |
2 #include <memory> |
2 #include <memory> |
|
3 |
|
4 #include <tuple> |
3 |
5 |
4 #include <RelationalWriter.h> |
6 #include <RelationalWriter.h> |
5 #include <Factory.h> |
7 #include <Factory.h> |
6 #include <TypeId.h> |
8 #include <TypeId.h> |
7 |
9 |
8 int main(int argc, char** argv) { |
10 int main(int argc, char** argv) { |
9 using namespace relpipe::writer; |
11 using namespace relpipe::writer; |
10 std::shared_ptr<RelationalWriter> writer(Factory::create(std::cout)); |
12 std::shared_ptr<RelationalWriter> writer(Factory::create(std::cout)); |
11 |
13 |
|
14 |
|
15 // All strings |
12 writer->startRelation(L"my_first_table",{ |
16 writer->startRelation(L"my_first_table",{ |
13 {L"a1", TypeId::STRING}, |
17 {L"a1", TypeId::STRING}, |
14 {L"a2", TypeId::STRING}, |
18 {L"a2", TypeId::STRING}, |
15 {L"a3", TypeId::STRING} |
19 {L"a3", TypeId::STRING} |
16 }, true); |
20 }, true); |
17 |
21 |
18 writer->writeRecord({L"1.1", L"1.2", L"1.3"}); |
22 writer->writeRecord({L"1.1", L"1.2", L"1.3"}); |
19 writer->writeRecord({L"2.1", L"2.2", L"2.3"}); |
23 writer->writeRecord({L"2.1", L"2.2", L"2.3"}); |
20 writer->writeRecord({L"3.1", L"3.2", L"3.3"}); |
24 writer->writeRecord({L"3.1", L"3.2", L"3.3"}); |
21 |
25 |
|
26 |
|
27 // Various data types passed as strings |
22 writer->startRelation(L"my_second_table",{ |
28 writer->startRelation(L"my_second_table",{ |
23 {L"s", TypeId::STRING}, |
29 {L"s", TypeId::STRING}, |
24 {L"i", TypeId::INTEGER}, |
30 {L"i", TypeId::INTEGER}, |
25 {L"b", TypeId::BOOLEAN} |
31 {L"b", TypeId::BOOLEAN} |
26 }, true); |
32 }, true); |
27 |
33 |
28 writer->writeRecord({L"a", L"1", L"true"}); |
34 writer->writeRecord({L"a", L"1", L"true"}); |
29 writer->writeRecord({L"b", L"2", L"false"}); |
35 writer->writeRecord({L"b", L"2", L"false"}); |
30 writer->writeRecord({L"c", L"3", L"true"}); |
36 writer->writeRecord({L"c", L"3", L"true"}); |
31 |
37 |
|
38 |
|
39 // Various data types passed as raw pointers + typeids |
|
40 writer->startRelation(L"my_raw_table",{ |
|
41 {L"s", TypeId::STRING}, |
|
42 {L"i", TypeId::INTEGER}, |
|
43 {L"b", TypeId::BOOLEAN} |
|
44 }, true); |
|
45 |
|
46 for (int i = 0; i < 3; i++) { |
|
47 string_t sValue = L"s"; |
|
48 integer_t iValue = i; |
|
49 boolean_t bValue = i % 2 == 0; |
|
50 |
|
51 writer->writeAttribute(&sValue, typeid(sValue)); |
|
52 writer->writeAttribute(&iValue, typeid(iValue)); |
|
53 writer->writeAttribute(&bValue, typeid(bValue)); |
|
54 } |
|
55 |
32 return 0; |
56 return 0; |
33 } |
57 } |