UsenetSearch/include/usenetsearch/Configuration.h

74 lines
2.4 KiB
C++

/*
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 <https://www.gnu.org/licenses/>.
*/
#pragma once
#include "usenetsearch/Except.h"
#include <filesystem>
#include <regex>
#include <string>
namespace usenetsearch {
struct ConfigurationException: public UsenetSearchException
{
ConfigurationException(int errorCode, const std::string& message):
UsenetSearchException(errorCode, message){}
virtual ~ConfigurationException() = default;
};
class Configuration
{
std::uint16_t m_batchSize{1};
std::vector<std::string> m_filterEraseSubtoken;
std::vector<std::regex> m_filterNewsgroupBlacklist;
std::vector<std::regex> m_filterNewsgroupWhitelist;
std::vector<std::string> m_filterWordsNoSubtoken;
std::uint16_t m_maxThreads{1};
std::uint8_t m_maxTreeDepth{5};
std::uint16_t m_minSubtokenWords{1};
std::string m_nntpServerHost{"127.0.0.1"};
std::string m_nntpServerPassword{"password"};
int m_nntpServerPort{119};
bool m_nntpServerSSL{false};
std::string m_nntpServerUser{"username"};
std::filesystem::path m_databasePath{"./db"};
public:
std::uint16_t BatchSize() const;
std::filesystem::path DatabasePath() const;
std::vector<std::string>& FilterEraseSubtoken();
std::vector<std::regex>& FilterNewsgroupBlacklist();
std::vector<std::regex>& FilterNewsgroupWhitelist();
std::vector<std::string>& FilterWordsNoSubtoken();
std::uint16_t MaxThreads() const;
std::uint8_t MaxTreeDepth() const;
std::uint16_t MinSubtokenWords() const;
std::string NNTPServerHost() const;
std::string NNTPServerPassword() const;
int NNTPServerPort() const;
bool NNTPServerSSL() const;
std::string NNTPServerUser() const;
void Open(const std::string& filename);
};
} // namespace usenetsearch