1
0
forked from blue/mlc
mlc/src/settings.h

67 lines
1.5 KiB
C
Raw Normal View History

#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>
#include "logger/logger.h"
class Settings {
public:
enum Action {
convert,
help,
2023-10-07 22:36:20 +00:00
config,
_actionsSize
};
2023-10-07 22:36:20 +00:00
enum Type {
mp3,
_typesSize
};
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;
Logger::Severity getLogLevel() const;
2023-10-07 22:36:20 +00:00
Type getType() const;
Action getAction() const;
unsigned int getThreads() const;
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);
private:
void parseArguments();
2023-10-07 22:36:20 +00:00
static void strip(std::string& line);
static void stripComment(std::string& line);
static std::string resolvePath(const std::string& line);
private:
std::vector<std::string_view> arguments;
std::optional<Action> action;
2023-10-07 22:36:20 +00:00
std::optional<Type> outputType;
std::optional<std::string> input;
std::optional<std::string> output;
std::optional<Logger::Severity> logLevel;
2023-10-07 22:36:20 +00:00
std::optional<std::string> configPath;
std::optional<unsigned int> threads;
};