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

#include <ttauri/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 (std::vector< std::string > const &arguments) noexcept
 Parse the arguments.
 

Detailed Description

A parser to parse command line arguments.

Member Function Documentation

◆ add()

void tt::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 tt::CommandLineParser::has_error ( ) const
inlinenoexcept

check if an error has occured during parsing.

◆ parse()

datum tt::CommandLineParser::parse ( std::vector< std::string > const & arguments)
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 tt::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: