relpipe-in-cli.cpp
author František Kučera <franta-hg@frantovo.cz>
Sat, 21 Jul 2018 23:47:09 +0200
branchv_0
changeset 5 83dd71fe5cfd
parent 4 e615c7d87279
child 6 4585c212a767
permissions -rw-r--r--
use TypeId enum instead of numeric constants

#include <cstdlib>
#include <memory>

#include <RelationalWriter.h>
#include <TypeId.h>

int main(int argc, char** argv) {
	using namespace relpipe::writer;
	std::shared_ptr<RelationalWriter> writer(RelationalWriter::create(std::cout));

	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"});
	
	writer->startRelation(L"my_second_table",{
		{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"});

	return 0;
}