/*
 * SPDX-FileCopyrightText: 2014 Vishesh Handa <me@vhanda.in>
 *
 * SPDX-License-Identifier: LGPL-2.1-or-later
 *
 */

#ifndef AKONADI_SEARCH_XAPIAN_TERMGENERATOR_H
#define AKONADI_SEARCH_XAPIAN_TERMGENERATOR_H

#include <xapian.h>

#include <QString>
#include "search_xapian_export.h"

namespace Akonadi {
namespace Search {
/** Xapian term generator. */
class AKONADI_SEARCH_XAPIAN_EXPORT XapianTermGenerator
{
public:
    explicit XapianTermGenerator(Xapian::Document *doc);

    void indexText(const QString &text);
    void indexText(const QString &text, const QString &prefix, int wdfInc = 1);

    void setPosition(int position);
    int position() const;

    void setDocument(Xapian::Document *doc);

    static QStringList termList(const QString &text);
private:
    Xapian::Document *m_doc = nullptr;
    Xapian::TermGenerator m_termGen;

    int m_position;
};
}
}

#endif // AKONADI_SEARCH_XAPIAN_TERMGENERATOR_H
