diff -r eb1ecb37c6b7 -r b4f29fb16159 src/AttributeFinder.h --- a/src/AttributeFinder.h Wed Jan 16 18:19:50 2019 +0100 +++ b/src/AttributeFinder.h Wed Jan 16 19:31:37 2019 +0100 @@ -37,41 +37,14 @@ protected: fs::path currentFile; string currentFileRaw; -public: - - /** - * Single requested fields might generate multiple attributes in the relation. - * But usually it is 1:1. - * @param field requested field from the user (usually from CLI arguments) - * @return attribute metadata to be used in the RelationalWriter.startRelation() - */ - virtual vector toMetadata(const RequestedField& field) = 0; - - /** - * Writing of the record for current file is starting. - * Following writeField() calls are related to this file. - * @param file path to the file - * @param fileRaw raw file name as it was on the input - */ - virtual void startFile(const fs::path& file, const string& fileRaw) { - currentFile = file; - currentFileRaw = fileRaw; - } - - /** - * Writing of the record for current file is finished. All resources linked to this file should be released. - */ - virtual void endFile() { - currentFile.clear(); - currentFileRaw.clear(); - } + bool currentFileExists; /** * Writes field attribute(s). The attribute count must match with count of AttributeMetadata returned in toMetadata(). * @param writer * @param field */ - virtual void writeField(RelationalWriter* writer, const RequestedField& field) = 0; + virtual void writeFieldOfExistingFile(RelationalWriter* writer, const RequestedField& field) = 0; /** * Writes empty attribute(s) in case of non-existent file or an error. @@ -98,6 +71,41 @@ } } +public: + + /** + * Single requested fields might generate multiple attributes in the relation. + * But usually it is 1:1. + * @param field requested field from the user (usually from CLI arguments) + * @return attribute metadata to be used in the RelationalWriter.startRelation() + */ + virtual vector toMetadata(const RequestedField& field) = 0; + + /** + * Writing of the record for current file is starting. + * Following writeField() calls are related to this file. + * @param file path to the file + * @param fileRaw raw file name as it was on the input + */ + virtual void startFile(const fs::path& file, const string& fileRaw, bool exists) { + currentFile = file; + currentFileRaw = fileRaw; + currentFileExists = exists; + } + + virtual void writeField(RelationalWriter* writer, const RequestedField& field) { + if (currentFileExists) writeFieldOfExistingFile(writer, field); + else writeEmptyField(writer, field); + } + + /** + * Writing of the record for current file is finished. All resources linked to this file should be released. + */ + virtual void endFile() { + currentFile.clear(); + currentFileRaw.clear(); + } + virtual ~AttributeFinder() { } };