ark::core::ArgumentParseResult

Defined in header “ark/core/argument_parser.hh”.


This object is returned after parsing a series of arguments, and contains the results of the parse. Use this to determine which arguments were selected.

Methods

  • size_t count(const std::string_view & name)
    Returns the number of times the given argument appeared.

  • std::optional< std::string > argument(const std::string_view & name)
    Returns the first (and possibly only) argument match for the given name. Returns an empty optional if the argument doesn’t exist.

  • std::vector< std::string > arguments(const std::string_view & name)
    Returns all of the arguments associated with the given option. If the option was specified multiple times, the arguments to that option will be returned in the order in which they were parsed.

    Returns an empty list if this argument wasn’t specified.

  • const std::string & program_name()
    Returns the name of the binary (retrieved by parsing arguments). This is assumed to be the first argument passed in.

  • const std::vector< std::string > & errors()
    Returns all of the accumulated errors.

  • const std::vector< ParseResult > & arguments()
    Returns an ordered list of all command line arguments, as parsed.

  • operator bool()
    Returns false if this parse had errors.

  • std::string operator[](const std::string_view & name)
    A convenience operator for argument(). Returns the first (and only) argument match for the given name. Throws if the argument isn’t specified.