# HG changeset patch # User František Kučera # Date 1549219957 -3600 # Node ID f7f9a2553128cb6a2d5a289d004b978d163d536b # Parent 65f9d6b94f5cc6f413b6f6624acefbb3deaea024 Guile --before-records, --after-records and relpipe-relation-name variable diff -r 65f9d6b94f5c -r f7f9a2553128 src/GuileHandler.h --- a/src/GuileHandler.h Sun Feb 03 19:29:52 2019 +0100 +++ b/src/GuileHandler.h Sun Feb 03 19:52:37 2019 +0100 @@ -59,7 +59,6 @@ RelationConfiguration* currentRelationConfiguration = nullptr; vector currentReaderMetadata; vector currentWriterMetadata; - vector currentRecord; integer_t currentAttributeIndex = 0; boolean_t includeCurrentRecord = false; @@ -153,6 +152,7 @@ } void startRelation(string_t name, vector attributes) override { + if (currentRelationConfiguration) evalGuileCode(currentRelationConfiguration->guileAfterRecords); for (auto attribute : currentReaderMetadata) undefineGuileVariable(attribute.getAttributeName()); currentReaderMetadata = attributes; // TODO: move to a reusable method (or use same metadata on both reader and writer side?) @@ -162,8 +162,7 @@ currentWriterMetadata.push_back({readerMetadata.getAttributeName(), relationalWriter->toTypeId(readerMetadata.getTypeName())}); } - currentRecord.resize(attributes.size()); - + currentRelationConfiguration = nullptr; for (int i = 0; i < configuration.relationConfigurations.size(); i++) { if (regex_match(name, wregex(configuration.relationConfigurations[i].relation))) { currentRelationConfiguration = &configuration.relationConfigurations[i]; @@ -172,6 +171,12 @@ } relationalWriter->startRelation(name, currentWriterMetadata, true); + + if (currentRelationConfiguration) { + // TODO: better variable name, object, function? + defineGuileVariable(L"relpipe-relation-name", &name, typeid (name), TypeId::STRING); + evalGuileCode(currentRelationConfiguration->guileBeforeRecords); + } } void attribute(const void* value, const std::type_info& type) override { @@ -195,7 +200,7 @@ } void endOfPipe() { - + if (currentRelationConfiguration) evalGuileCode(currentRelationConfiguration->guileAfterRecords); } };