2023-10-06 21:39:07 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <string_view>
|
|
|
|
#include <optional>
|
|
|
|
#include <vector>
|
|
|
|
#include <array>
|
|
|
|
#include <algorithm>
|
2023-10-07 22:36:20 +00:00
|
|
|
#include <iostream>
|
|
|
|
#include <fstream>
|
|
|
|
#include <functional>
|
|
|
|
#include <cctype>
|
|
|
|
#include <sstream>
|
2023-10-06 21:39:07 +00:00
|
|
|
|
2023-10-08 23:29:40 +00:00
|
|
|
#include "logger/logger.h"
|
2023-10-06 21:39:07 +00:00
|
|
|
|
|
|
|
class Settings {
|
|
|
|
public:
|
|
|
|
enum Action {
|
|
|
|
convert,
|
|
|
|
help,
|
2023-10-07 22:36:20 +00:00
|
|
|
config,
|
2023-10-06 21:39:07 +00:00
|
|
|
_actionsSize
|
|
|
|
};
|
|
|
|
|
2023-10-07 22:36:20 +00:00
|
|
|
enum Type {
|
|
|
|
mp3,
|
|
|
|
_typesSize
|
|
|
|
};
|
|
|
|
|
2023-10-06 21:39:07 +00:00
|
|
|
Settings(int argc, char **argv);
|
|
|
|
|
|
|
|
std::string getInput() const;
|
|
|
|
std::string getOutput() const;
|
2023-10-07 22:36:20 +00:00
|
|
|
std::string getConfigPath() const;
|
|
|
|
bool isConfigDefault() const;
|
2023-10-08 23:29:40 +00:00
|
|
|
Logger::Severity getLogLevel() const;
|
2023-10-07 22:36:20 +00:00
|
|
|
Type getType() const;
|
2023-10-06 21:39:07 +00:00
|
|
|
Action getAction() const;
|
2023-10-09 21:47:00 +00:00
|
|
|
unsigned int getThreads() const;
|
2023-10-06 21:39:07 +00:00
|
|
|
|
2023-10-07 22:36:20 +00:00
|
|
|
bool readConfigFile();
|
|
|
|
void readConfigLine(const std::string& line);
|
|
|
|
std::string defaultConfig() const;
|
|
|
|
|
|
|
|
static Action stringToAction(const std::string& source);
|
|
|
|
static Action stringToAction(const std::string_view& source);
|
|
|
|
static Type stringToType(const std::string& source);
|
|
|
|
|
2023-10-06 21:39:07 +00:00
|
|
|
private:
|
|
|
|
void parseArguments();
|
|
|
|
|
2023-10-07 22:36:20 +00:00
|
|
|
static void strip(std::string& line);
|
|
|
|
static void stripComment(std::string& line);
|
2023-10-09 21:47:00 +00:00
|
|
|
static std::string resolvePath(const std::string& line);
|
2023-10-06 21:39:07 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
std::vector<std::string_view> arguments;
|
|
|
|
std::optional<Action> action;
|
2023-10-07 22:36:20 +00:00
|
|
|
std::optional<Type> outputType;
|
2023-10-06 21:39:07 +00:00
|
|
|
std::optional<std::string> input;
|
|
|
|
std::optional<std::string> output;
|
2023-10-08 23:29:40 +00:00
|
|
|
std::optional<Logger::Severity> logLevel;
|
2023-10-07 22:36:20 +00:00
|
|
|
std::optional<std::string> configPath;
|
2023-10-09 21:47:00 +00:00
|
|
|
std::optional<unsigned int> threads;
|
2023-10-06 21:39:07 +00:00
|
|
|
};
|