Akonadi Search

xapiandocument.h
1 /*
2  * SPDX-FileCopyrightText: 2014 Vishesh Handa <[email protected]>
3  *
4  * SPDX-License-Identifier: LGPL-2.1-or-later
5  *
6  */
7 
8 #pragma once
9 
10 #include <QString>
11 #include <xapian.h>
12 
13 #include "search_xapian_export.h"
14 #include "xapiantermgenerator.h"
15 
16 namespace Akonadi
17 {
18 namespace Search
19 {
20 /**
21  * This class is just a light wrapper over Xapian::Document
22  * which provides nice Qt apis.
23  */
24 class AKONADI_SEARCH_XAPIAN_EXPORT XapianDocument
25 {
26 public:
28  XapianDocument(const Xapian::Document &doc);
29 
30  void addTerm(const QString &term, const QString &prefix = QString());
31  void addBoolTerm(const QString &term, const QString &prefix = QString());
32  void addBoolTerm(int term, const QString &prefix);
33 
34  void indexText(const QString &text, int wdfInc = 1);
35  void indexText(const QString &text, const QString &prefix, int wdfInc = 1);
36 
37  void addValue(int pos, const QString &value);
38 
39  Xapian::Document doc() const;
40 
41  QString fetchTermStartsWith(const QByteArray &term);
42 
43  /**
44  * Remove all the terms which start with the prefix \p prefix
45  *
46  * \return true if the document was modified
47  */
48  bool removeTermStartsWith(const QByteArray &prefix);
49 
50 private:
51  Xapian::Document m_doc;
52  XapianTermGenerator m_termGen;
53 };
54 }
55 }
This class is just a light wrapper over Xapian::Document which provides nice Qt apis.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Tue Dec 5 2023 04:11:35 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.