/*
*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: iaom
*/
#include "database.h"
using namespace UkuiSearch;
Database::Database(const DataBaseType &type)
{
switch (type) {
case DataBaseType::Basic:
m_database = new Xapian::Database(INDEX_PATH.toStdString());
break;
case DataBaseType::Content:
m_database = new Xapian::Database(CONTENT_INDEX_PATH.toStdString());
break;
default:
break;
}
}
Database::~Database()
{
if(m_database) {
delete m_database;
m_database = nullptr;
}
}
uint Database::getIndexDocCount()
{
return m_database->get_doccount();
}