File indexing completed on 2025-02-16 13:03:42
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 <QVector> 0012 #include <QString> 0013 0014 #include <memory> 0015 0016 namespace KFileMetaData { 0017 enum PropertiesMapType { MultiMap }; 0018 0019 class SimpleExtractionResultPrivate; 0020 0021 /** 0022 * \class SimpleExtractionResult simpleextractionresult.h <KFileMetaData/SimpleExtractionResult> 0023 * 0024 * A simple ExtractionResult implementation which stores 0025 * all the data in memory. 0026 * 0027 * This should ideally not be used in production applications as 0028 * it holds all of the plain text in memory, and that can get quite large 0029 * when extracting certain documents. 0030 */ 0031 class KFILEMETADATA_EXPORT SimpleExtractionResult : public ExtractionResult 0032 { 0033 public: 0034 SimpleExtractionResult(const QString& url, const QString& mimetype = QString(), const Flags& flags = Flags{ExtractPlainText | ExtractMetaData}); 0035 SimpleExtractionResult(const SimpleExtractionResult& rhs); 0036 ~SimpleExtractionResult() override; 0037 0038 SimpleExtractionResult& operator=(const SimpleExtractionResult& rhs); 0039 bool operator==(const SimpleExtractionResult& rhs) const; 0040 0041 void add(Property::Property property, const QVariant& value) override; 0042 void addType(Type::Type type) override; 0043 void append(const QString& text) override; 0044 0045 #if KFILEMETADATA_ENABLE_DEPRECATED_SINCE(5, 89) 0046 /// @deprecated Since 5.89, use properties(PropertiesMapType) overload instead 0047 KFILEMETADATA_DEPRECATED_VERSION(5, 89, "Use properties(PropertiesMapType) overload instead") 0048 PropertyMap properties() const; 0049 #endif 0050 0051 /** 0052 * Returns the properties of the extraction result. 0053 * Because QMap::insertMulti is deprecated, this overload returns a QMultiMap. 0054 * To automaticalls use the overload with the default value, define the KFILEMETADATA_DISABLE_DEPRECATED_BEFORE_AND_AT 0055 * in the cmake code to the deprecating version of this method or greater. 0056 * For example: 0057 * @code 0058 * add_definitions(-DKFILEMETADATA_DISABLE_DEPRECATED_BEFORE_AND_AT=0x055900) 0059 * @endcode 0060 * @since 5.89 0061 */ 0062 #if KFILEMETADATA_ENABLE_DEPRECATED_SINCE(5, 89) 0063 PropertyMultiMap properties(PropertiesMapType) const; 0064 #else 0065 PropertyMultiMap properties(PropertiesMapType = PropertiesMapType::MultiMap) const; 0066 #endif 0067 0068 QString text() const; 0069 QVector<Type::Type> types() const; 0070 0071 private: 0072 const std::unique_ptr<SimpleExtractionResultPrivate> d; 0073 }; 0074 0075 } 0076 0077 #endif // KFILEMETADATA_SimpleExtractionResult_H