File indexing completed on 2024-12-29 04:49:58

0001 /*
0002     SPDX-FileCopyrightText: 2019-2021 Volker Krause <vkrause@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "kitinerary_export.h"
0010 
0011 #include <QJsonArray>
0012 #include <QList>
0013 #include <QVariant>
0014 
0015 namespace KItinerary {
0016 
0017 /** Generic extraction result.
0018  *  This can represent results both in JSON-LD serialized form and in QVariant decoded form.
0019  */
0020 class KITINERARY_EXPORT ExtractorResult
0021 {
0022 public:
0023     ExtractorResult();
0024     ExtractorResult(const QJsonArray &result);
0025     ExtractorResult(const QList<QVariant> &result);
0026     ~ExtractorResult();
0027 
0028     /** Checks if there is any relevant result set in here. */
0029     bool isEmpty() const;
0030     /** Amount of contained result elements. */
0031     int size() const;
0032 
0033     /** JSON-LD data extracted from this document or page. */
0034     QJsonArray jsonLdResult() const;
0035     /** Result in decoded form. */
0036     QList<QVariant> result() const;
0037 
0038     /** Append another result to this one. */
0039     void append(ExtractorResult &&other);
0040 
0041 private:
0042     mutable QJsonArray m_jsonLdResult;
0043     mutable QList<QVariant> m_result;
0044 };
0045 
0046 }
0047