Commit a48fcd32 authored by Volker Krause's avatar Volker Krause
Browse files

Turn ExtractorValidator into a class

Necessary for it to hold individual configuration parameters.
parent 915487db
...@@ -112,7 +112,7 @@ QVector<QVariant> ExtractorPostprocessor::result() const ...@@ -112,7 +112,7 @@ QVector<QVariant> ExtractorPostprocessor::result() const
{ {
if (!d->m_resultFinalized) { if (!d->m_resultFinalized) {
for (auto it = d->m_data.begin(); it != d->m_data.end();) { for (auto it = d->m_data.begin(); it != d->m_data.end();) {
if (ExtractorValidator::isValidElement(*it)) { if (d->m_validator.isValidElement(*it)) {
++it; ++it;
} else { } else {
//qCDebug(Log).noquote() << "Discarding element:" << QJsonDocument(JsonLdDocument::toJson({*it})).toJson(); //qCDebug(Log).noquote() << "Discarding element:" << QJsonDocument(JsonLdDocument::toJson({*it})).toJson();
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
02110-1301, USA. 02110-1301, USA.
*/ */
#include "extractorvalidator.h"
#include <QDateTime> #include <QDateTime>
#include <QVariant> #include <QVariant>
#include <QVector> #include <QVector>
...@@ -79,6 +81,7 @@ public: ...@@ -79,6 +81,7 @@ public:
QVector<QVariant> m_data; QVector<QVariant> m_data;
QDateTime m_contextDate; QDateTime m_contextDate;
ExtractorValidator m_validator;
bool m_resultFinalized = false; bool m_resultFinalized = false;
}; };
......
...@@ -32,6 +32,15 @@ ...@@ -32,6 +32,15 @@
using namespace KItinerary; using namespace KItinerary;
namespace KItinerary {
class ExtractorValidatorPrivate {
public:
};
}
ExtractorValidator::ExtractorValidator() = default;
ExtractorValidator::~ExtractorValidator() = default;
static bool filterElement(const QVariant &elem); static bool filterElement(const QVariant &elem);
static bool filterLodgingReservation(const LodgingReservation &res) static bool filterLodgingReservation(const LodgingReservation &res)
......
...@@ -15,22 +15,40 @@ ...@@ -15,22 +15,40 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
#ifndef EXTRACTORVALIDATOR_H #ifndef KITINERARY_EXTRACTORVALIDATOR_H
#define EXTRACTORVALIDATOR_H #define KITINERARY_EXTRACTORVALIDATOR_H
#include "kitinerary_export.h"
#include <memory>
class QVariant; class QVariant;
namespace KItinerary {
class ExtractorValidatorPrivate;
/** /**
* Validates extractor results. * Validates extractor results.
* Used to discard incomplete or otherwise invalid data. * Used to discard incomplete or otherwise invalid data.
*/ */
namespace ExtractorValidator class KITINERARY_EXPORT ExtractorValidator
{ {
public:
ExtractorValidator();
~ExtractorValidator();
ExtractorValidator(const ExtractorValidator&) = delete;
ExtractorValidator& operator=(const ExtractorValidator&) = delete;
/** Checks if the given element is valid. /** Checks if the given element is valid.
* This will accept both Reservation object and things * This will accept both Reservation object and things
* that can be reserved as top-level objects. * that can be reserved as top-level objects.
*/ */
bool isValidElement(const QVariant &elem); bool isValidElement(const QVariant &elem);
private:
std::unique_ptr<ExtractorValidatorPrivate> d;
};
} }
#endif // EXTRACTORVALIDATOR_H #endif // EXTRACTORVALIDATOR_H
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