equal
deleted
inserted
replaced
47 namespace fs = std::filesystem; |
47 namespace fs = std::filesystem; |
48 using namespace relpipe::writer; |
48 using namespace relpipe::writer; |
49 |
49 |
50 class FilesystemCommand { |
50 class FilesystemCommand { |
51 protected: |
51 protected: |
52 std::wstring_convert<codecvt_utf8<wchar_t>> convertor; // TODO: support also other encodings. |
52 std::wstring_convert<codecvt_utf8<wchar_t>> convertor; // TODO: support also other encodings. |
53 |
53 |
54 std::map<string_t, std::shared_ptr<AttributeFinder>> createAttributeFinders() { |
54 std::map<string_t, std::shared_ptr<AttributeFinder>> createAttributeFinders() { |
55 return { |
55 return { |
56 {RequestedField::GROUP_FILE, std::make_shared<FileAttributeFinder>()}, |
56 {RequestedField::GROUP_FILE, std::make_shared<FileAttributeFinder>()}, |
57 {RequestedField::GROUP_STREAMLET, std::make_shared<StreamletAttributeFinder>()}, |
57 {RequestedField::GROUP_STREAMLET, std::make_shared<StreamletAttributeFinder>()}, |
69 else originalName << ch; |
69 else originalName << ch; |
70 } |
70 } |
71 return originalName.tellp(); |
71 return originalName.tellp(); |
72 } |
72 } |
73 |
73 |
|
74 string_t fetchRelationName(Configuration* configuration) { |
|
75 return configuration->relation.empty() ? L"filesystem" : configuration->relation; |
|
76 } |
|
77 |
|
78 void writeHeader(RelationalWriter* writer, std::map<string_t, std::shared_ptr < AttributeFinder>> attributeFinders, string_t relationName, std::vector<RequestedField>* fields) { |
|
79 std::vector<AttributeMetadata> attributesMetadata; |
|
80 for (RequestedField field : *fields) { |
|
81 std::shared_ptr<AttributeFinder> finder = attributeFinders[field.group]; |
|
82 if (finder) for (AttributeMetadata m : finder->toMetadata(writer, relationName, field)) attributesMetadata.push_back(m); |
|
83 else throw RelpipeWriterException(L"Unsupported field group: " + field.group); |
|
84 } |
|
85 |
|
86 writer->startRelation(relationName, attributesMetadata, true); |
|
87 } |
|
88 |
74 public: |
89 public: |
75 |
90 |
76 virtual ~FilesystemCommand() = default; |
91 virtual ~FilesystemCommand() = default; |
77 |
92 |
78 virtual void process(int inputFD, int outputFD, Configuration& configuration) = 0; |
93 virtual void process(int inputFD, int outputFD, Configuration& configuration) = 0; |