relpipe-in-cli.cpp
author František Kučera <franta-hg@frantovo.cz>
Fri, 27 Jul 2018 00:07:16 +0200
branchv_0
changeset 9 3be327f67cdd
parent 8 c1472544d95a
child 10 77593735b057
permissions -rw-r--r--
more records
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
3dd6adb7e191 empty project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     1
#include <cstdlib>
1
7e43750deca8 shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
     2
#include <memory>
0
3dd6adb7e191 empty project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     3
7
9ac885dd8037 writeAttribute() with raw pointer and type_info
František Kučera <franta-hg@frantovo.cz>
parents: 6
diff changeset
     4
#include <tuple>
9ac885dd8037 writeAttribute() with raw pointer and type_info
František Kučera <franta-hg@frantovo.cz>
parents: 6
diff changeset
     5
1
7e43750deca8 shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
     6
#include <RelationalWriter.h>
6
4585c212a767 move create() method to a factory
František Kučera <franta-hg@frantovo.cz>
parents: 5
diff changeset
     7
#include <Factory.h>
5
83dd71fe5cfd use TypeId enum instead of numeric constants
František Kučera <franta-hg@frantovo.cz>
parents: 4
diff changeset
     8
#include <TypeId.h>
0
3dd6adb7e191 empty project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     9
3dd6adb7e191 empty project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    10
int main(int argc, char** argv) {
5
83dd71fe5cfd use TypeId enum instead of numeric constants
František Kučera <franta-hg@frantovo.cz>
parents: 4
diff changeset
    11
	using namespace relpipe::writer;
6
4585c212a767 move create() method to a factory
František Kučera <franta-hg@frantovo.cz>
parents: 5
diff changeset
    12
	std::shared_ptr<RelationalWriter> writer(Factory::create(std::cout));
0
3dd6adb7e191 empty project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    13
7
9ac885dd8037 writeAttribute() with raw pointer and type_info
František Kučera <franta-hg@frantovo.cz>
parents: 6
diff changeset
    14
9ac885dd8037 writeAttribute() with raw pointer and type_info
František Kučera <franta-hg@frantovo.cz>
parents: 6
diff changeset
    15
	// Various data types passed as strings
8
c1472544d95a replace writeRecord() with sequence of writeAttribute()
František Kučera <franta-hg@frantovo.cz>
parents: 7
diff changeset
    16
	writer->startRelation(L"table_from_strings",{
5
83dd71fe5cfd use TypeId enum instead of numeric constants
František Kučera <franta-hg@frantovo.cz>
parents: 4
diff changeset
    17
		{L"s", TypeId::STRING},
83dd71fe5cfd use TypeId enum instead of numeric constants
František Kučera <franta-hg@frantovo.cz>
parents: 4
diff changeset
    18
		{L"i", TypeId::INTEGER},
83dd71fe5cfd use TypeId enum instead of numeric constants
František Kučera <franta-hg@frantovo.cz>
parents: 4
diff changeset
    19
		{L"b", TypeId::BOOLEAN}
4
e615c7d87279 multiple relations, various data types
František Kučera <franta-hg@frantovo.cz>
parents: 3
diff changeset
    20
	}, true);
e615c7d87279 multiple relations, various data types
František Kučera <franta-hg@frantovo.cz>
parents: 3
diff changeset
    21
8
c1472544d95a replace writeRecord() with sequence of writeAttribute()
František Kučera <franta-hg@frantovo.cz>
parents: 7
diff changeset
    22
	writer->writeAttribute(L"a");
c1472544d95a replace writeRecord() with sequence of writeAttribute()
František Kučera <franta-hg@frantovo.cz>
parents: 7
diff changeset
    23
	writer->writeAttribute(L"1");
c1472544d95a replace writeRecord() with sequence of writeAttribute()
František Kučera <franta-hg@frantovo.cz>
parents: 7
diff changeset
    24
	writer->writeAttribute(L"true");
c1472544d95a replace writeRecord() with sequence of writeAttribute()
František Kučera <franta-hg@frantovo.cz>
parents: 7
diff changeset
    25
c1472544d95a replace writeRecord() with sequence of writeAttribute()
František Kučera <franta-hg@frantovo.cz>
parents: 7
diff changeset
    26
	writer->writeAttribute(L"b");
c1472544d95a replace writeRecord() with sequence of writeAttribute()
František Kučera <franta-hg@frantovo.cz>
parents: 7
diff changeset
    27
	writer->writeAttribute(L"2");
c1472544d95a replace writeRecord() with sequence of writeAttribute()
František Kučera <franta-hg@frantovo.cz>
parents: 7
diff changeset
    28
	writer->writeAttribute(L"false");
3
7d4525147bf7 multiple records, no nullptr
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
    29
7
9ac885dd8037 writeAttribute() with raw pointer and type_info
František Kučera <franta-hg@frantovo.cz>
parents: 6
diff changeset
    30
9ac885dd8037 writeAttribute() with raw pointer and type_info
František Kučera <franta-hg@frantovo.cz>
parents: 6
diff changeset
    31
	// Various data types passed as raw pointers + typeids
8
c1472544d95a replace writeRecord() with sequence of writeAttribute()
František Kučera <franta-hg@frantovo.cz>
parents: 7
diff changeset
    32
	writer->startRelation(L"from_raw_pointers",{
7
9ac885dd8037 writeAttribute() with raw pointer and type_info
František Kučera <franta-hg@frantovo.cz>
parents: 6
diff changeset
    33
		{L"s", TypeId::STRING},
9ac885dd8037 writeAttribute() with raw pointer and type_info
František Kučera <franta-hg@frantovo.cz>
parents: 6
diff changeset
    34
		{L"i", TypeId::INTEGER},
9ac885dd8037 writeAttribute() with raw pointer and type_info
František Kučera <franta-hg@frantovo.cz>
parents: 6
diff changeset
    35
		{L"b", TypeId::BOOLEAN}
9ac885dd8037 writeAttribute() with raw pointer and type_info
František Kučera <franta-hg@frantovo.cz>
parents: 6
diff changeset
    36
	}, true);
9ac885dd8037 writeAttribute() with raw pointer and type_info
František Kučera <franta-hg@frantovo.cz>
parents: 6
diff changeset
    37
8
c1472544d95a replace writeRecord() with sequence of writeAttribute()
František Kučera <franta-hg@frantovo.cz>
parents: 7
diff changeset
    38
	string_t sValue;
c1472544d95a replace writeRecord() with sequence of writeAttribute()
František Kučera <franta-hg@frantovo.cz>
parents: 7
diff changeset
    39
	integer_t iValue;
c1472544d95a replace writeRecord() with sequence of writeAttribute()
František Kučera <franta-hg@frantovo.cz>
parents: 7
diff changeset
    40
	boolean_t bValue;
c1472544d95a replace writeRecord() with sequence of writeAttribute()
František Kučera <franta-hg@frantovo.cz>
parents: 7
diff changeset
    41
9
3be327f67cdd more records
František Kučera <franta-hg@frantovo.cz>
parents: 8
diff changeset
    42
	for (int i = 0; i < 8; i++) {
3be327f67cdd more records
František Kučera <franta-hg@frantovo.cz>
parents: 8
diff changeset
    43
		sValue.append(L"*");
3be327f67cdd more records
František Kučera <franta-hg@frantovo.cz>
parents: 8
diff changeset
    44
		iValue = i + 1;
3be327f67cdd more records
František Kučera <franta-hg@frantovo.cz>
parents: 8
diff changeset
    45
		bValue = iValue % 2 == 0;
8
c1472544d95a replace writeRecord() with sequence of writeAttribute()
František Kučera <franta-hg@frantovo.cz>
parents: 7
diff changeset
    46
		writer->writeAttribute(&sValue, typeid (sValue));
c1472544d95a replace writeRecord() with sequence of writeAttribute()
František Kučera <franta-hg@frantovo.cz>
parents: 7
diff changeset
    47
		writer->writeAttribute(&iValue, typeid (iValue));
c1472544d95a replace writeRecord() with sequence of writeAttribute()
František Kučera <franta-hg@frantovo.cz>
parents: 7
diff changeset
    48
		writer->writeAttribute(&bValue, typeid (bValue));
7
9ac885dd8037 writeAttribute() with raw pointer and type_info
František Kučera <franta-hg@frantovo.cz>
parents: 6
diff changeset
    49
	}
9ac885dd8037 writeAttribute() with raw pointer and type_info
František Kučera <franta-hg@frantovo.cz>
parents: 6
diff changeset
    50
3
7d4525147bf7 multiple records, no nullptr
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
    51
	return 0;
0
3dd6adb7e191 empty project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    52
}