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