--- 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<AttributeMetadata> currentReaderMetadata;
vector<writer::AttributeMetadata> currentWriterMetadata;
- vector<string_t> currentRecord;
integer_t currentAttributeIndex = 0;
boolean_t includeCurrentRecord = false;
@@ -153,6 +152,7 @@
}
void startRelation(string_t name, vector<AttributeMetadata> 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);
}
};