HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
Public Member Functions
v1::CommandLineParser Class Reference

#include <hikogui/CommandLineParser.hpp>

Public Member Functions

 CommandLineParser (std::string synopsis)
 
void add (std::string name, datum_type_t type, std::string help, std::function< int(std::string_view)> enum_conversion={}) noexcept
 Add a configuration option.
 
bool has_error () const noexcept
 check if an error has occured during parsing.
 
void print_help ()
 Print help text for the command line arguments.
 
datum parse (int argc, char const *const argv[]) noexcept
 Parse the arguments.
 

Detailed Description

A parser to parse command line arguments.

Member Function Documentation

◆ add()

void v1::CommandLineParser::add ( std::string name,
datum_type_t type,
std::string help,
std::function< int(std::string_view)> enum_conversion = {} )
inlinenoexcept

Add a configuration option.

Parameters
nameName of the option. Excluding the leading dashes
typeType of the option's argument
helpDescription text of the option.
enum_conversionA function that converts a string to an integer.

◆ has_error()

bool v1::CommandLineParser::has_error ( ) const
inlinenoexcept

check if an error has occured during parsing.

◆ parse()

datum v1::CommandLineParser::parse ( int argc,
char const *const argv[] )
inlinenoexcept

Parse the arguments.

The result will be a map of option/value pairs. Special options are:

  • 'executable-path' The path to the exectuable.
  • 'arguments' A list of strings of the non-option arguments.
Parameters
argumentsa list of command line arguments, including the exectable name as the first argument.
Returns
The result as a map-datum, with option names as the keys.

◆ print_help()

void v1::CommandLineParser::print_help ( )
inline

Print help text for the command line arguments.

This will also print any error messages that happened during the parsing.


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