#pragma once #include #include #include #include #include /* * Allows syntax: * --help : long flags * --path=/home/lion : long assignments */ class ArgsParser { public: enum Flags : int { NONE = 0, REQUIRED = 1, // argument is required HAS_VALUE = 2, // argument must have a value }; ArgsParser() = default; void Parse(const std::vector& ArgList); // prints errors if any errors occurred, in that case also returns false bool Verify(); void RegisterArgument(std::vector&& ArgumentNames, int Flags); // pass all possible names for this argument (short, long, etc) bool FoundArgument(const std::vector& Names); std::optional GetValueOfArgument(const std::vector& Names); private: void ConsumeLongAssignment(const std::string& Arg); void ConsumeLongFlag(const std::string& Arg); bool IsRegistered(const std::string& Name); struct Argument { std::string Name; std::optional Value; }; struct RegisteredArgument { std::vector Names; int Flags; }; std::vector mRegisteredArguments; std::vector mFoundArgs; };