Commit 7287f0ac authored by Volker Krause's avatar Volker Krause
Browse files

Add IATA BCBP extractor

This was previously done manually in a few places, the new extractor
engine will apply this to any text-containing node.
parent 0247cdbb
......@@ -27,6 +27,8 @@ set(kitinerary_lib_srcs
engine/extractorresult.cpp
era/ssbticket.cpp
extractors/iatabcbpextractor.cpp
generic/genericextractor.cpp
generic/genericicalextractor.cpp
generic/genericpdfextractor.cpp
......
/*
SPDX-FileCopyrightText: 2021 Volker Krause <vkrause@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "iatabcbpextractor.h"
#include <KItinerary/ExtractorDocumentNode>
#include <KItinerary/ExtractorResult>
#include <KItinerary/IataBcbpParser>
using namespace KItinerary;
QString IataBcbpExtractor::name() const
{
return QStringLiteral("<IATA BCBP>");
}
bool IataBcbpExtractor::canHandle(const ExtractorDocumentNode &node) const
{
return node.isA<QString>() && IataBcbpParser::maybeIataBcbp(node.content<QString>());
}
ExtractorResult IataBcbpExtractor::extract(const ExtractorDocumentNode &node, [[maybe_unused]] const ExtractorEngine *engine) const
{
return IataBcbpParser::parse(node.content<QString>(), node.contextDateTime().date());
}
/*
SPDX-FileCopyrightText: 2021 Volker Krause <vkrause@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#ifndef KITINERARY_IATABCBPEXTRACTOR_H
#define KITINERARY_IATABCBPEXTRACTOR_H
#include <KItinerary/AbstractExtractor>
namespace KItinerary {
/** IATA boarding pass barcode extractor. */
class IataBcbpExtractor : public AbstractExtractor
{
public:
QString name() const override;
bool canHandle(const ExtractorDocumentNode &node) const override;
ExtractorResult extract(const ExtractorDocumentNode &node, const ExtractorEngine *engine) const override;
};
}
#endif // KITINERARY_IATABCBPEXTRACTOR_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