/*
Copyright© 2021 John Sennesael
UsenetSearch 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.
UsenetSearch 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 UsenetSearch. If not, see .
*/
#pragma once
#include
#include
#include
#include
#include "usenetsearch/Application.h"
#include "usenetsearch/Filter.h"
#include "usenetsearch/UsenetClient.h"
#include "usenetsearch/ThreadPool.h"
namespace usenetsearch {
class SearchResult
{
std::uint32_t m_newsgroupId{0};
std::uint32_t m_articleId{0};
size_t m_numHits{0};
public:
SearchResult() = default;
SearchResult(const ArticleEntry& entry);
SearchResult(std::uint32_t newsgroupId, std::uint32_t articleId);
SearchResult(const SearchResult& other);
std::uint32_t ArticleId() const;
size_t Hits() const;
void Inc();
std::uint32_t NewsgroupId() const;
void operator=(const SearchResult& other);
bool operator==(const SearchResult& other) const;
bool operator!=(const SearchResult& other) const;
bool operator<(const SearchResult& other) const;
bool operator>(const SearchResult& other) const;
bool operator>=(const SearchResult& other) const;
bool operator<=(const SearchResult& other) const;
};
typedef std::vector SearchResults;
class Indexer
{
Application& m_app;
UsenetClient& m_client;
std::wstring_convert> m_conv;
ThreadPool m_threads;
public:
Indexer(Application& app, UsenetClient& client);
void Connect();
void Index(const std::vector& newsgroups);
std::unique_ptr Search(
const std::string& searchString
);
};
} // namespace usenetsearch