src/GuileHandler.h
author František Kučera <franta-hg@frantovo.cz>
Tue, 22 Jan 2019 15:07:21 +0100
branchv_0
changeset 3 d4d0e50f54da
parent 2 7fb4d2c70e8c
child 4 9b4fe4bc5f0f
permissions -rw-r--r--
add $ prefix to attribute variables
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     1
/**
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     2
 * Relational pipes
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     3
 * Copyright © 2019 František Kučera (Frantovo.cz, GlobalCode.info)
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     4
 *
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     5
 * This program is free software: you can redistribute it and/or modify
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     7
 * the Free Software Foundation, either version 3 of the License, or
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     8
 * (at your option) any later version.
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     9
 *
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    10
 * This program is distributed in the hope that it will be useful,
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    13
 * GNU General Public License for more details.
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    14
 *
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    16
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    17
 */
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    18
#pragma once
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    19
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    20
#include <memory>
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    21
#include <string>
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    22
#include <vector>
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    23
#include <iostream>
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    24
#include <sstream>
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    25
#include <locale>
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    26
#include <codecvt>
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    27
#include <regex>
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    28
1
9179406ab3b3 link to the Guile library and add some Guile demo code – evaluate code from CLI argument
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    29
#include <libguile.h>
9179406ab3b3 link to the Guile library and add some Guile demo code – evaluate code from CLI argument
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    30
0
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    31
#include <relpipe/reader/typedefs.h>
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    32
#include <relpipe/reader/TypeId.h>
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    33
#include <relpipe/reader/handlers/RelationalReaderStringHandler.h>
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    34
#include <relpipe/reader/handlers/AttributeMetadata.h>
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    35
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    36
#include <relpipe/writer/Factory.h>
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    37
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    38
#include <relpipe/cli/RelpipeCLIException.h>
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    39
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    40
namespace relpipe {
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    41
namespace tr {
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    42
namespace guile {
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    43
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    44
using namespace std;
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    45
using namespace relpipe;
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    46
using namespace relpipe::reader;
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    47
using namespace relpipe::reader::handlers;
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    48
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    49
class GuileHandler : public RelationalReaderStringHadler {
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    50
private:
1
9179406ab3b3 link to the Guile library and add some Guile demo code – evaluate code from CLI argument
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    51
	std::wstring_convert<codecvt_utf8<wchar_t>> convertor; // TODO: support also other encodings.
9179406ab3b3 link to the Guile library and add some Guile demo code – evaluate code from CLI argument
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    52
0
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    53
	shared_ptr<writer::RelationalWriter> relationalWriter;
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    54
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    55
	wregex relationNameRegEx;
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    56
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    57
	vector<AttributeMetadata> currentMetadata;
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    58
	vector<string_t> currentRecord;
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    59
	integer_t currentAttributeIndex = 0;
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    60
	boolean_t includeCurrentRecord = false;
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    61
	boolean_t filterCurrentRelation = false;
1
9179406ab3b3 link to the Guile library and add some Guile demo code – evaluate code from CLI argument
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    62
	string_t guileCode;
9179406ab3b3 link to the Guile library and add some Guile demo code – evaluate code from CLI argument
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    63
9179406ab3b3 link to the Guile library and add some Guile demo code – evaluate code from CLI argument
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    64
	SCM toGuileSymbol(const string_t& name) {
3
d4d0e50f54da add $ prefix to attribute variables
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
    65
		return scm_string_to_symbol(scm_from_locale_string(convertor.to_bytes(L"$" + name).c_str()));
1
9179406ab3b3 link to the Guile library and add some Guile demo code – evaluate code from CLI argument
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    66
	}
9179406ab3b3 link to the Guile library and add some Guile demo code – evaluate code from CLI argument
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    67
9179406ab3b3 link to the Guile library and add some Guile demo code – evaluate code from CLI argument
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    68
	SCM toGuileString(const string_t& value) {
9179406ab3b3 link to the Guile library and add some Guile demo code – evaluate code from CLI argument
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    69
		return scm_from_locale_string(convertor.to_bytes(value).c_str());
9179406ab3b3 link to the Guile library and add some Guile demo code – evaluate code from CLI argument
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    70
	}
2
7fb4d2c70e8c record filtering in Guile
František Kučera <franta-hg@frantovo.cz>
parents: 1
diff changeset
    71
1
9179406ab3b3 link to the Guile library and add some Guile demo code – evaluate code from CLI argument
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    72
	SCM toGuileInteger(const string_t& value) {
9179406ab3b3 link to the Guile library and add some Guile demo code – evaluate code from CLI argument
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    73
		return scm_from_uint64(stoul(value));
9179406ab3b3 link to the Guile library and add some Guile demo code – evaluate code from CLI argument
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    74
	}
2
7fb4d2c70e8c record filtering in Guile
František Kučera <franta-hg@frantovo.cz>
parents: 1
diff changeset
    75
1
9179406ab3b3 link to the Guile library and add some Guile demo code – evaluate code from CLI argument
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    76
	SCM toGuileBoolean(const string_t& value) {
9179406ab3b3 link to the Guile library and add some Guile demo code – evaluate code from CLI argument
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    77
		return value == L"true" ? SCM_BOOL_T : SCM_BOOL_F;
9179406ab3b3 link to the Guile library and add some Guile demo code – evaluate code from CLI argument
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    78
	}
9179406ab3b3 link to the Guile library and add some Guile demo code – evaluate code from CLI argument
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    79
9179406ab3b3 link to the Guile library and add some Guile demo code – evaluate code from CLI argument
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    80
	void defineGuileVariable(const string_t& name, TypeId type, const string_t& value) {
9179406ab3b3 link to the Guile library and add some Guile demo code – evaluate code from CLI argument
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    81
		// TODO: RelationalReaderValueHadler?
9179406ab3b3 link to the Guile library and add some Guile demo code – evaluate code from CLI argument
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    82
		switch (type) {
9179406ab3b3 link to the Guile library and add some Guile demo code – evaluate code from CLI argument
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    83
			case TypeId::BOOLEAN:
9179406ab3b3 link to the Guile library and add some Guile demo code – evaluate code from CLI argument
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    84
				scm_define(toGuileSymbol(name), toGuileBoolean(value));
9179406ab3b3 link to the Guile library and add some Guile demo code – evaluate code from CLI argument
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    85
				break;
9179406ab3b3 link to the Guile library and add some Guile demo code – evaluate code from CLI argument
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    86
			case TypeId::INTEGER:
9179406ab3b3 link to the Guile library and add some Guile demo code – evaluate code from CLI argument
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    87
				scm_define(toGuileSymbol(name), toGuileInteger(value));
9179406ab3b3 link to the Guile library and add some Guile demo code – evaluate code from CLI argument
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    88
				break;
9179406ab3b3 link to the Guile library and add some Guile demo code – evaluate code from CLI argument
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    89
			case TypeId::STRING:
9179406ab3b3 link to the Guile library and add some Guile demo code – evaluate code from CLI argument
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    90
				scm_define(toGuileSymbol(name), toGuileString(value));
9179406ab3b3 link to the Guile library and add some Guile demo code – evaluate code from CLI argument
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    91
				break;
9179406ab3b3 link to the Guile library and add some Guile demo code – evaluate code from CLI argument
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    92
			default:
9179406ab3b3 link to the Guile library and add some Guile demo code – evaluate code from CLI argument
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    93
				throw cli::RelpipeCLIException(L"Unsupported type in defineGuileVariable()", cli::CLI::EXIT_CODE_UNEXPECTED_ERROR);
9179406ab3b3 link to the Guile library and add some Guile demo code – evaluate code from CLI argument
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    94
		}
9179406ab3b3 link to the Guile library and add some Guile demo code – evaluate code from CLI argument
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    95
	}
9179406ab3b3 link to the Guile library and add some Guile demo code – evaluate code from CLI argument
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    96
9179406ab3b3 link to the Guile library and add some Guile demo code – evaluate code from CLI argument
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    97
	void undefineGuileVariable(const string_t& name, TypeId type, const string_t& value) {
9179406ab3b3 link to the Guile library and add some Guile demo code – evaluate code from CLI argument
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    98
		scm_define(toGuileSymbol(name), scm_make_undefined_variable()); // undefined != (define n)
3
d4d0e50f54da add $ prefix to attribute variables
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
    99
		// TODO: or use: scm_variable_unset_x() ?
1
9179406ab3b3 link to the Guile library and add some Guile demo code – evaluate code from CLI argument
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   100
	}
0
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   101
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   102
public:
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   103
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   104
	GuileHandler(ostream& output, const vector<string_t>& arguments) {
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   105
		relationalWriter.reset(writer::Factory::create(output));
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   106
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   107
		// TODO: options and parser
1
9179406ab3b3 link to the Guile library and add some Guile demo code – evaluate code from CLI argument
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   108
		if (arguments.size() == 2) {
0
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   109
			relationNameRegEx = wregex(arguments[0]);
1
9179406ab3b3 link to the Guile library and add some Guile demo code – evaluate code from CLI argument
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   110
			guileCode = arguments[1];
0
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   111
		} else {
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   112
			throw cli::RelpipeCLIException(L"Usage: relpipe-tr-guile <relationNameRegExp>", cli::CLI::EXIT_CODE_UNKNOWN_COMMAND);
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   113
		}
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   114
	}
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   115
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   116
	void startRelation(string_t name, vector<AttributeMetadata> attributes) override {
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   117
		currentMetadata = attributes;
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   118
		// TODO: move to a reusable method (or use same metadata on both reader and writer side?)
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   119
		vector<writer::AttributeMetadata> writerMetadata;
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   120
		for (AttributeMetadata readerMetadata : attributes) {
1
9179406ab3b3 link to the Guile library and add some Guile demo code – evaluate code from CLI argument
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   121
0
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   122
			writerMetadata.push_back({readerMetadata.getAttributeName(), relationalWriter->toTypeId(readerMetadata.getTypeName())});
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   123
		}
1
9179406ab3b3 link to the Guile library and add some Guile demo code – evaluate code from CLI argument
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   124
0
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   125
		currentRecord.resize(attributes.size());
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   126
		filterCurrentRelation = regex_match(name, relationNameRegEx);
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   127
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   128
		relationalWriter->startRelation(name, writerMetadata, true);
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   129
	}
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   130
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   131
	void attribute(const string_t& value) override {
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   132
		if (filterCurrentRelation) {
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   133
			currentRecord[currentAttributeIndex] = value;
2
7fb4d2c70e8c record filtering in Guile
František Kučera <franta-hg@frantovo.cz>
parents: 1
diff changeset
   134
			defineGuileVariable(currentMetadata[currentAttributeIndex].getAttributeName(), currentMetadata[currentAttributeIndex].getTypeId(), value);
0
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   135
			currentAttributeIndex++;
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   136
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   137
			if (currentAttributeIndex > 0 && currentAttributeIndex % currentMetadata.size() == 0) {
2
7fb4d2c70e8c record filtering in Guile
František Kučera <franta-hg@frantovo.cz>
parents: 1
diff changeset
   138
				// TODO: support also updates in Guile
7fb4d2c70e8c record filtering in Guile
František Kučera <franta-hg@frantovo.cz>
parents: 1
diff changeset
   139
				includeCurrentRecord = scm_to_bool(scm_eval_string(toGuileString(guileCode)));
0
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   140
				if (includeCurrentRecord) for (string_t v : currentRecord) relationalWriter->writeAttribute(v);
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   141
				includeCurrentRecord = false;
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   142
			}
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   143
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   144
			currentAttributeIndex = currentAttributeIndex % currentMetadata.size();
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   145
		} else {
1
9179406ab3b3 link to the Guile library and add some Guile demo code – evaluate code from CLI argument
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
   146
0
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   147
			relationalWriter->writeAttribute(value);
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   148
		}
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   149
	}
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   150
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   151
	void endOfPipe() {
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   152
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   153
	}
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   154
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   155
};
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   156
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   157
}
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   158
}
f36bf14d45cb project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   159
}