# HG changeset patch # User František Kučera # Date 1532290925 -7200 # Node ID c1472544d95ae8104230292884946bab2579c6b4 # Parent 9ac885dd8037881498db6dbd22771b3515370ac0 replace writeRecord() with sequence of writeAttribute() diff -r 9ac885dd8037 -r c1472544d95a relpipe-in-cli.cpp --- a/relpipe-in-cli.cpp Sun Jul 22 17:19:33 2018 +0200 +++ b/relpipe-in-cli.cpp Sun Jul 22 22:22:05 2018 +0200 @@ -12,45 +12,40 @@ std::shared_ptr writer(Factory::create(std::cout)); - // All strings - writer->startRelation(L"my_first_table",{ - {L"a1", TypeId::STRING}, - {L"a2", TypeId::STRING}, - {L"a3", TypeId::STRING} - }, true); - - writer->writeRecord({L"1.1", L"1.2", L"1.3"}); - writer->writeRecord({L"2.1", L"2.2", L"2.3"}); - writer->writeRecord({L"3.1", L"3.2", L"3.3"}); - - // Various data types passed as strings - writer->startRelation(L"my_second_table",{ + writer->startRelation(L"table_from_strings",{ {L"s", TypeId::STRING}, {L"i", TypeId::INTEGER}, {L"b", TypeId::BOOLEAN} }, true); - writer->writeRecord({L"a", L"1", L"true"}); - writer->writeRecord({L"b", L"2", L"false"}); - writer->writeRecord({L"c", L"3", L"true"}); + writer->writeAttribute(L"a"); + writer->writeAttribute(L"1"); + writer->writeAttribute(L"true"); + + writer->writeAttribute(L"b"); + writer->writeAttribute(L"2"); + writer->writeAttribute(L"false"); // Various data types passed as raw pointers + typeids - writer->startRelation(L"my_raw_table",{ + writer->startRelation(L"from_raw_pointers",{ {L"s", TypeId::STRING}, {L"i", TypeId::INTEGER}, {L"b", TypeId::BOOLEAN} }, true); + string_t sValue; + integer_t iValue; + boolean_t bValue; + for (int i = 0; i < 3; i++) { - string_t sValue = L"s"; - integer_t iValue = i; - boolean_t bValue = i % 2 == 0; - - writer->writeAttribute(&sValue, typeid(sValue)); - writer->writeAttribute(&iValue, typeid(iValue)); - writer->writeAttribute(&bValue, typeid(bValue)); + sValue.append(L"a"); + iValue = i; + bValue = i % 2 == 0; + writer->writeAttribute(&sValue, typeid (sValue)); + writer->writeAttribute(&iValue, typeid (iValue)); + writer->writeAttribute(&bValue, typeid (bValue)); } return 0;