Commit 517230ac authored by Volker Krause's avatar Volker Krause
Browse files

Add abstract base classes for extractors

The current script extractors will be rebased onto this, while also
allowing built-in C++ extractors next to them using the same interface.
This will replace the current generic/custom extractor split.
parent 537968ac
......@@ -21,6 +21,7 @@ set(kitinerary_lib_srcs
datatypes/rentalcar.cpp
datatypes/visit.cpp
engine/abstractextractor.cpp
engine/extractordocumentnode.cpp
engine/extractordocumentprocessor.cpp
engine/extractorresult.cpp
......@@ -211,6 +212,7 @@ ecm_generate_headers(KItinerary_Datatypes_FORWARDING_HEADERS
)
ecm_generate_headers(KItinerary_Engine_FORWARDING_HEADERS
HEADER_NAMES
AbstractExtractor
ExtractorDocumentNode
ExtractorResult
PREFIX KItinerary
......
/*
SPDX-FileCopyrightText: 2021 Volker Krause <vkrause@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "abstractextractor.h"
using namespace KItinerary;
AbstractExtractor::~AbstractExtractor() = default;
/*
SPDX-FileCopyrightText: 2021 Volker Krause <vkrause@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#ifndef KITINERARY_ABSTRACTEXTRACTOR_H
#define KITINERARY_ABSTRACTEXTRACTOR_H
#include "kitinerary_export.h"
class QString;
namespace KItinerary {
class ExtractorDocumentNode;
class ExtractorEngine;
class ExtractorResult;
/** Abstract base class for data extractors. */
class KITINERARY_EXPORT AbstractExtractor
{
public:
virtual ~AbstractExtractor();
/** Identifier for this extractor.
* Mainly used for diagnostics and tooling.
*/
virtual QString name() const = 0;
/** Fast check whether this extractor is applicable for @p node. */
virtual bool canHandle(const ExtractorDocumentNode &node) const = 0;
/** Extract data from @p node. */
virtual ExtractorResult extract(const ExtractorDocumentNode &node, const ExtractorEngine *engine) const = 0;
};
}
#endif // KITINERARY_ABSTRACTEXTRACTOR_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