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