# HG changeset patch # User František Kučera # Date 1547943814 -3600 # Node ID 7fb4d2c70e8cc0a9d887c2a7b40b9e4621744045 # Parent 9179406ab3b32018c33c31201517511699772425 record filtering in Guile try: relpipe-in-fstab | relpipe-tr-guile 'fstab' '(= pass 2)' | relpipe-out-tabular relpipe-in-fstab | relpipe-tr-guile 'fstab' '(equal? mount_point "/")' | relpipe-out-tabular diff -r 9179406ab3b3 -r 7fb4d2c70e8c src/GuileHandler.h --- a/src/GuileHandler.h Sun Jan 20 01:02:40 2019 +0100 +++ b/src/GuileHandler.h Sun Jan 20 01:23:34 2019 +0100 @@ -68,11 +68,11 @@ SCM toGuileString(const string_t& value) { return scm_from_locale_string(convertor.to_bytes(value).c_str()); } - + SCM toGuileInteger(const string_t& value) { return scm_from_uint64(stoul(value)); } - + SCM toGuileBoolean(const string_t& value) { return value == L"true" ? SCM_BOOL_T : SCM_BOOL_F; } @@ -129,28 +129,13 @@ void attribute(const string_t& value) override { if (filterCurrentRelation) { - // TODO: evaluate condition and updates in Guile currentRecord[currentAttributeIndex] = value; - includeCurrentRecord = false; - - // TODO: remove, just a demo code - defineGuileVariable(L"hello", TypeId::STRING, L"world"); - defineGuileVariable(L"a", TypeId::INTEGER, L"123"); - defineGuileVariable(L"b", TypeId::INTEGER, L"456"); - defineGuileVariable(L"tr", TypeId::BOOLEAN, L"true"); - defineGuileVariable(L"fa", TypeId::BOOLEAN, L"false"); - - //integer_t guileResult = scm_to_uint64(scm_eval_string(toGuileString(guileCode))); - //std::wcerr << "result from Guile: " << guileResult << std::endl; - - includeCurrentRecord = scm_to_bool(scm_eval_string(toGuileString(guileCode))); - //scm_shell(0, nullptr); - // -------- - - + defineGuileVariable(currentMetadata[currentAttributeIndex].getAttributeName(), currentMetadata[currentAttributeIndex].getTypeId(), value); currentAttributeIndex++; if (currentAttributeIndex > 0 && currentAttributeIndex % currentMetadata.size() == 0) { + // TODO: support also updates in Guile + includeCurrentRecord = scm_to_bool(scm_eval_string(toGuileString(guileCode))); if (includeCurrentRecord) for (string_t v : currentRecord) relationalWriter->writeAttribute(v); includeCurrentRecord = false; }