Baloo

result.h
1 /*
2  This file is part of the KDE Baloo Project
3  SPDX-FileCopyrightText: 2013 Vishesh Handa <[email protected]>
4 
5  SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
6 */
7 
8 #ifndef EXTRACTIONRESULT_H
9 #define EXTRACTIONRESULT_H
10 
11 #include <KFileMetaData/ExtractionResult>
12 
13 #include "document.h"
14 #include "termgenerator.h"
15 
16 /**
17  * \class Result result.h
18  *
19  * \brief The result class is where all the data extracted by
20  * the KFileMetaData extractors is saved to.
21  * It implements the KFileMetaData::ExtractionResult interface.
22  * The results can be retrieved as a Baloo::Document using
23  * \c document() and stored in the database.
24  *
25  */
27 {
28 public:
29  Result();
30  Result(const QString& url, const QString& mimetype, const Flags& flags = ExtractMetaData | ExtractPlainText);
31 
32  void add(KFileMetaData::Property::Property property, const QVariant& value) override;
33  void append(const QString& text) override;
34  void addType(KFileMetaData::Type::Type type) override;
35 
36  /**
37  * Can be used to add extraction results to an existing
38  * Baloo::Document. Has to be called before passing the
39  * Result to KFileMetaData::Extractor::extract().
40  * \param doc The Baloo::Document
41  */
42  void setDocument(const Baloo::Document& doc);
43 
44  /**
45  * Returns the Baloo document to which the results from the extractors
46  * are saved.
47  */
49  return m_doc;
50  }
51 
52  /**
53  * Applies the finishing touches on the document, and makes
54  * it ready to be pushed into the db.
55  */
56  void finish();
57 
58 private:
59  /**
60  * The document that represents the file that is to be indexed.
61  */
62  Baloo::Document m_doc;
63  /**
64  * Contains the position state of the metadata and adds it to the document.
65  */
66  Baloo::TermGenerator m_termGen;
67  /**
68  * Contains the position state of plain text and adds it to the document.
69  */
70  Baloo::TermGenerator m_termGenForText;
71  /**
72  * Contains all indexed property data from the extractors.
73  */
74  KFileMetaData::PropertyMultiMap m_map;
75 };
76 
77 #endif // EXTRACTIONRESULT_H
The result class is where all the data extracted by the KFileMetaData extractors is saved to....
Definition: result.h:26
void setDocument(const Baloo::Document &doc)
Can be used to add extraction results to an existing Baloo::Document.
Definition: result.cpp:113
Baloo::Document & document()
Returns the Baloo document to which the results from the extractors are saved.
Definition: result.h:48
A document represents an indexed file to be stored in the Baloo engine.
Definition: document.h:30
void finish()
Applies the finishing touches on the document, and makes it ready to be pushed into the db.
Definition: result.cpp:101
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Wed Nov 29 2023 03:56:26 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.