Class CommandLineArgumentParser

Class Documentation

class inexor::vulkan_renderer::tools::CommandLineArgumentParser

A simple command line argument parser.


Support equals arguments and arguments with multiple values (e.g. gpus=1,2,3).

Support short arguments, including stacking (e.g. -abc).


Only supports arguments with zero or one values (e.g. vsync or gpu 1)


Only supports long arguments (e.g. <arg>)

Public Functions

void parse_args(int argc, char **argv)

Parses the command line arguments.

  • argc – The number of arguments passed in the command line.

  • argv – An array of strings containing argc elements.

template<typename T>
inline std::optional<T> arg(const std::string &name) const

Attempts to retrieve the argument name as type T.


name – The whole name of the argument (e.g. renderdoc)


std::nullopt if argument name wasn’t specified by the user at all, true if the argument was specified but doesn’t take any values and the first value of the argument lexically casted to type T.

inline std::size_t parsed_arg_count() const

Returns the number of parsed command line arguments.

Private Functions

std::optional<CommandLineArgumentTemplate> make_arg_template(const std::string &argument_name) const

Private Members

const std::vector<CommandLineArgumentTemplate> m_accepted_args{{"--gpu", true}, {"--no-separate-data-queue", false}, {"--no-stats", false}, {"--no-validation", false}, {"--no-vk-debug-markers", false}, {"--renderdoc", false}, {"--vsync", false}, {"--stop-on-validation-message", false}}
std::unordered_map<std::string, CommandLineArgumentValue> m_parsed_arguments