src/FilesystemCommand.h
branchv_0
changeset 58 4679f67a8324
parent 57 c40a241d6e0c
child 59 7471529c0d11
--- a/src/FilesystemCommand.h	Tue Jan 21 00:19:56 2020 +0100
+++ b/src/FilesystemCommand.h	Fri Jan 24 16:53:31 2020 +0100
@@ -49,7 +49,7 @@
 
 class FilesystemCommand {
 protected:
-	std::wstring_convert<codecvt_utf8<wchar_t>> convertor; // TODO: support also other encodings.
+	std::wstring_convert<codecvt_utf8<wchar_t>> convertor; // TODO: support also other encodings.	
 
 	std::map<string_t, std::shared_ptr<AttributeFinder>> createAttributeFinders() {
 		return {
@@ -71,6 +71,21 @@
 		return originalName.tellp();
 	}
 
+	string_t fetchRelationName(Configuration* configuration) {
+		return configuration->relation.empty() ? L"filesystem" : configuration->relation;
+	}
+
+	void writeHeader(RelationalWriter* writer, std::map<string_t, std::shared_ptr < AttributeFinder>> attributeFinders, string_t relationName, std::vector<RequestedField>* fields) {
+		std::vector<AttributeMetadata> attributesMetadata;
+		for (RequestedField field : *fields) {
+			std::shared_ptr<AttributeFinder> finder = attributeFinders[field.group];
+			if (finder) for (AttributeMetadata m : finder->toMetadata(writer, relationName, field)) attributesMetadata.push_back(m);
+			else throw RelpipeWriterException(L"Unsupported field group: " + field.group);
+		}
+
+		writer->startRelation(relationName, attributesMetadata, true);
+	}
+
 public:
 
 	virtual ~FilesystemCommand() = default;