diff --git a/src/Utils/Utils.vcxproj b/src/Utils/Utils.vcxproj index 2f96dc40..8c485f0d 100644 --- a/src/Utils/Utils.vcxproj +++ b/src/Utils/Utils.vcxproj @@ -19,11 +19,15 @@ + + + + diff --git a/src/Utils/Utils/Arguments/ArgumentParser.cpp b/src/Utils/Utils/Arguments/ArgumentParser.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/Utils/Utils/Arguments/ArgumentParser.h b/src/Utils/Utils/Arguments/ArgumentParser.h new file mode 100644 index 00000000..b9d0d1a4 --- /dev/null +++ b/src/Utils/Utils/Arguments/ArgumentParser.h @@ -0,0 +1,19 @@ +#pragma once +#include "CommandLineOption.h" +#include +#include + +class ArgumentParser +{ +public: + ArgumentParser(const CommandLineOption** options, size_t optionCount); + + bool ParseArguments(std::vector& args); + bool ParseArguments(int argc, const char** argv); + + std::vector GetArguments(); + + bool IsOptionSpecified(const CommandLineOption* option); + std::string GetValueForOption(const CommandLineOption* option); + std::vector GetParametersForOption(const CommandLineOption* option); +}; \ No newline at end of file diff --git a/src/Utils/Utils/Arguments/CommandLineOption.cpp b/src/Utils/Utils/Arguments/CommandLineOption.cpp new file mode 100644 index 00000000..7c5130e9 --- /dev/null +++ b/src/Utils/Utils/Arguments/CommandLineOption.cpp @@ -0,0 +1,60 @@ +#include "CommandLineOption.h" +#include + +CommandLineOption::CommandLineOption() +{ + m_short_name = ""; + m_long_name = ""; + m_description = ""; + m_category = ""; + m_multi_use = false; +} + +CommandLineOption::Builder& CommandLineOption::Builder::Create() +{ + return *new Builder(); +} + +CommandLineOption::Builder& CommandLineOption::Builder::WithShortName(std::string shortName) +{ + m_option.m_short_name = std::move(shortName); + return *this; +} + +CommandLineOption::Builder& CommandLineOption::Builder::WithLongName(std::string longName) +{ + m_option.m_long_name = std::move(longName); + return *this; +} + +CommandLineOption::Builder& CommandLineOption::Builder::WithDescription(std::string description) +{ + m_option.m_description = std::move(description); + return *this; +} + +CommandLineOption::Builder& CommandLineOption::Builder::WithCategory(std::string category) +{ + m_option.m_category = std::move(category); + return *this; +} + +CommandLineOption::Builder& CommandLineOption::Builder::WithParameter(std::string parameterName) +{ + m_option.m_parameters.push_back(std::move(parameterName)); + return *this; +} + +CommandLineOption::Builder& CommandLineOption::Builder::Reusable() +{ + m_option.m_multi_use = true; + return *this; +} + +CommandLineOption* CommandLineOption::Builder::Build() const +{ + auto* result = new CommandLineOption(m_option); + delete this; + + return result; +} \ No newline at end of file diff --git a/src/Utils/Utils/Arguments/CommandLineOption.h b/src/Utils/Utils/Arguments/CommandLineOption.h new file mode 100644 index 00000000..1d915cb3 --- /dev/null +++ b/src/Utils/Utils/Arguments/CommandLineOption.h @@ -0,0 +1,35 @@ +#pragma once +#include +#include + +class CommandLineOption +{ +protected: + CommandLineOption(); + +public: + std::string m_short_name; + std::string m_long_name; + std::string m_description; + std::string m_category; + bool m_multi_use; + std::vector m_parameters; + + class Builder; +}; + +class CommandLineOption::Builder +{ + CommandLineOption m_option; + +public: + static Builder& Create(); + + Builder& WithShortName(std::string shortName); + Builder& WithLongName(std::string longName); + Builder& WithDescription(std::string description); + Builder& WithCategory(std::string category); + Builder& WithParameter(std::string parameterName); + Builder& Reusable(); + CommandLineOption* Build() const; +}; \ No newline at end of file