File indexing completed on 2024-05-12 05:11:21

0001 /*
0002  * SPDX-FileCopyrightText: 2014 Vishesh Handa <me@vhanda.in>
0003  *
0004  * SPDX-License-Identifier: LGPL-2.1-or-later
0005  *
0006  */
0007 
0008 #pragma once
0009 
0010 #include <xapian.h>
0011 
0012 #include "search_xapian_export.h"
0013 #include <QString>
0014 
0015 namespace Akonadi
0016 {
0017 namespace Search
0018 {
0019 /** Xapian query parser. */
0020 class AKONADI_SEARCH_XAPIAN_EXPORT XapianQueryParser
0021 {
0022 public:
0023     XapianQueryParser();
0024 
0025     void setDatabase(Xapian::Database *db);
0026     Xapian::Query parseQuery(const QString &str, const QString &prefix = QString());
0027 
0028     /**
0029      * Expands word to every possible option which it can be expanded to.
0030      */
0031     Xapian::Query expandWord(const QString &word, const QString &prefix = QString());
0032 
0033     /**
0034      * Set if each word in the string should be treated as a partial word
0035      * and should be expanded to every possible word.
0036      */
0037     void setAutoExapand(bool autoexpand);
0038 
0039 private:
0040     Xapian::Database *m_db = nullptr;
0041     bool m_autoExpand = true;
0042 };
0043 }
0044 }