equal
deleted
inserted
replaced
52 class GuileHandler : public RelationalReaderValueHadler { |
52 class GuileHandler : public RelationalReaderValueHadler { |
53 private: |
53 private: |
54 std::wstring_convert<codecvt_utf8<wchar_t>> convertor; // TODO: support also other encodings or use always UTF-8 between C++ and Guile |
54 std::wstring_convert<codecvt_utf8<wchar_t>> convertor; // TODO: support also other encodings or use always UTF-8 between C++ and Guile |
55 |
55 |
56 Configuration configuration; |
56 Configuration configuration; |
57 shared_ptr<writer::RelationalWriter> relationalWriter; |
57 writer::RelationalWriter* relationalWriter; |
58 |
58 |
59 wregex relationNameRegEx; |
59 wregex relationNameRegEx; |
60 |
60 |
61 vector<AttributeMetadata> currentReaderMetadata; |
61 vector<AttributeMetadata> currentReaderMetadata; |
62 vector<writer::AttributeMetadata> currentWriterMetadata; |
62 vector<writer::AttributeMetadata> currentWriterMetadata; |
144 } |
144 } |
145 } |
145 } |
146 |
146 |
147 public: |
147 public: |
148 |
148 |
149 GuileHandler(ostream& output, Configuration& configuration, const vector<string_t>& arguments) : configuration(configuration) { |
149 GuileHandler(writer::RelationalWriter* relationalWriter, Configuration& configuration, const vector<string_t>& arguments) : relationalWriter(relationalWriter), configuration(configuration) { |
150 relationalWriter.reset(writer::Factory::create(output)); |
|
151 |
150 |
152 // FIXME: remove and work directly with configuration in startRelation() and attribute() |
151 // FIXME: remove and work directly with configuration in startRelation() and attribute() |
153 // i.e. support multiple relationConfigurations |
152 // i.e. support multiple relationConfigurations |
154 if (configuration.relationConfigurations.size() == 1) { |
153 if (configuration.relationConfigurations.size() == 1) { |
155 relationNameRegEx = wregex(configuration.relationConfigurations[0].relation); |
154 relationNameRegEx = wregex(configuration.relationConfigurations[0].relation); |
180 if (filterCurrentRelation) { |
179 if (filterCurrentRelation) { |
181 defineGuileVariable(a2v(currentReaderMetadata[currentAttributeIndex].getAttributeName()), value, type, currentReaderMetadata[currentAttributeIndex].getTypeId()); |
180 defineGuileVariable(a2v(currentReaderMetadata[currentAttributeIndex].getAttributeName()), value, type, currentReaderMetadata[currentAttributeIndex].getTypeId()); |
182 |
181 |
183 currentAttributeIndex++; |
182 currentAttributeIndex++; |
184 |
183 |
|
184 // TODO: > 0 ?: |
185 if (currentAttributeIndex > 0 && currentAttributeIndex % currentReaderMetadata.size() == 0) { |
185 if (currentAttributeIndex > 0 && currentAttributeIndex % currentReaderMetadata.size() == 0) { |
186 includeCurrentRecord = scm_to_bool(evalGuileCode(guileCodeWhereCondition)); |
186 includeCurrentRecord = scm_to_bool(evalGuileCode(guileCodeWhereCondition)); |
187 if (includeCurrentRecord) for (auto attribute : currentWriterMetadata) writeGuileValueToAttribute(attribute); |
187 if (includeCurrentRecord) for (auto attribute : currentWriterMetadata) writeGuileValueToAttribute(attribute); |
188 includeCurrentRecord = false; |
188 includeCurrentRecord = false; |
189 } |
189 } |