File indexing completed on 2024-05-05 03:54:41

0001 /*
0002     SPDX-FileCopyrightText: 2014 Vishesh Handa <me@vhanda.in>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-or-later
0005 */
0006 
0007 #ifndef KFILEMETADATA_SimpleExtractionResult_H
0008 #define KFILEMETADATA_SimpleExtractionResult_H
0009 
0010 #include "extractionresult.h"
0011 #include <QList>
0012 #include <QString>
0013 
0014 #include <memory>
0015 
0016 namespace KFileMetaData {
0017 
0018 class SimpleExtractionResultPrivate;
0019 
0020 /**
0021  * \class SimpleExtractionResult simpleextractionresult.h <KFileMetaData/SimpleExtractionResult>
0022  *
0023  * A simple ExtractionResult implementation which stores
0024  * all the data in memory.
0025  *
0026  * This should ideally not be used in production applications as
0027  * it holds all of the plain text in memory, and that can get quite large
0028  * when extracting certain documents.
0029  */
0030 class KFILEMETADATA_EXPORT SimpleExtractionResult : public ExtractionResult
0031 {
0032 public:
0033     SimpleExtractionResult(const QString& url, const QString& mimetype = QString(), const Flags& flags = Flags{ExtractPlainText | ExtractMetaData});
0034     SimpleExtractionResult(const SimpleExtractionResult& rhs);
0035     ~SimpleExtractionResult() override;
0036 
0037     SimpleExtractionResult& operator=(const SimpleExtractionResult& rhs);
0038     bool operator==(const SimpleExtractionResult& rhs) const;
0039 
0040     void add(Property::Property property, const QVariant& value) override;
0041     void addType(Type::Type type) override;
0042     void append(const QString& text) override;
0043 
0044     /**
0045      * Returns the properties of the extraction result.
0046      */
0047     PropertyMultiMap properties() const;
0048 
0049     QString text() const;
0050     QList<Type::Type> types() const;
0051 
0052 private:
0053     const std::unique_ptr<SimpleExtractionResultPrivate> d;
0054 };
0055 
0056 }
0057 
0058 #endif // KFILEMETADATA_SimpleExtractionResult_H