DirectZ
Loading...
Searching...
No Matches
dz::ProgramArgs Struct Reference

Parses and stores command line program arguments. More...

#include <ProgramArgs.hpp>

Public Member Functions

 ProgramArgs (int argc, char **argv)
 Constructs the ProgramArgs object by parsing command line arguments.

Public Attributes

std::unordered_map< std::string, std::string > options
 Map storing options parsed from command line arguments.
std::vector< std::string > arguments
 Vector of positional arguments parsed from command line.

Detailed Description

Parses and stores command line program arguments.

Splits command line input into options (key-value pairs) and positional arguments. The options map keys are strings stripped of the leading dash. The arguments vector holds all positional arguments in order.

Constructor & Destructor Documentation

◆ ProgramArgs()

dz::ProgramArgs::ProgramArgs ( int argc,
char ** argv )
inline

Constructs the ProgramArgs object by parsing command line arguments.

Parses argc and argv from main() according to rules:

  • Arguments starting with '-' are treated as options.
  • If an option is followed by a non-option argument, that is its value.
  • Otherwise, the option value is an empty string.
  • Non-option arguments are collected as positional arguments.
Parameters
argcNumber of command line arguments.
argvArray of C-string arguments.

Member Data Documentation

◆ arguments

std::vector<std::string> dz::ProgramArgs::arguments

Vector of positional arguments parsed from command line.

Arguments that do not begin with a dash are stored here, preserving order.

◆ options

std::unordered_map<std::string, std::string> dz::ProgramArgs::options

Map storing options parsed from command line arguments.

Keys are option names (without leading dash). Values are option values, or empty string if no value was provided.


The documentation for this struct was generated from the following file: