API quick reference

class GOpp::Parser

Intent

Parser is the object that user should interact with. Its responsibilites include:

  • parsing arguments and assigning them to appropiate parameters.
  • providing interface to check state of parsed arguments.

Assumptions

After being handed command line arguments in constructor, Parser should not be mutated in any way. It can be thought of as a container (and interpreter) for Command objects.


GOpp::Parser::Parser(const std::vector<std::string> Parameters, const std::vector<Command::Definition> CommandParameters)
Parameters:
  • Parameters – Command line parameters. Size will be deduced from vector size.
  • CommandParameters – Definitions of viable parameters, along with their accepted arguments and flags.
Returns:

None:

Throws:
  • invalid_argument – If ‘argc’ is smaller than 1.
  • logic_error – If CommandParameters Contains clashing names.
GOpp::Parser::Parser(const std::initializer_list<std::string> Parameters, const std::initializer_list<Command::Definition> CommandParameters)

Delegates work to vector-based constructor.

Parameters:
  • Parameters – Command line parameters. Size will be deduced from container size.
  • CommandParameters – Definitions of viable parameters, along with their accepted arguments and flags.
Returns:

None

Throws:
  • invalid_argument – If argc is smaller than 1.
  • logic_error – If CommandParameters contains clashing names.

GOpp::Parser::Parser(int argc, char **argv, const std::initializer_list<Command::Definition> CommandParameters)

Uses C-style arguments and molds them to fit initializer-list constructor.

Parameters:
  • argc – Argument count.
  • argv – C-style string argument array.
  • CommandParameters – Definitions of viable parameters, along with their accepted arguments and flags.
Returns:

None:

Throws:
  • invalid_argument – If argc is smaller than 1.
  • logic_error – If CommandParameters contains clashing names.