Commit 9a5f9e4c authored by Volker Krause's avatar Volker Krause
Browse files

Add a method to write extractor meta data for the new script extractors

Needed by KItinerary Workbench.
parent 4b4aa729
Pipeline #55774 passed with stages
in 12 minutes and 57 seconds
......@@ -434,3 +434,29 @@ QJsonValue ExtractorRepository::extractorToJson(const Extractor &extractor) cons
}
return a;
}
QJsonValue ExtractorRepository::extractorToJson(const ScriptExtractor *extractor) const
{
QJsonArray a;
bool added = false;
for (const auto &ext : d->m_extractorsNew) {
auto e = dynamic_cast<ScriptExtractor*>(ext.get());
if (!e || e->fileName() != extractor->fileName()) {
continue;
}
if (extractor->name() == e->name()) {
a.push_back(extractor->toJson());
added = true;
} else {
a.push_back(e->toJson());
}
}
if (!added) {
a.push_back(extractor->toJson());
}
if (a.size() == 1) {
return a.at(0);
}
return a;
}
......@@ -36,6 +36,7 @@ class AbstractExtractor;
class Extractor;
class ExtractorDocumentNode;
class ExtractorRepositoryPrivate;
class ScriptExtractor;
/**
* Collection of all known data extractors.
......@@ -93,6 +94,7 @@ public:
* Only for tooling, do not use otherwise.
*/
QJsonValue extractorToJson(const Extractor &extractor) const;
QJsonValue extractorToJson(const ScriptExtractor *extractor) const;
///@endcond
private:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment