Unravel Engine C++ Reference
Loading...
Searching...
No Matches
cmd_line::parser Class Reference

#include <parser.h>

Public Member Functions

 parser (int argc, const char **argv)
 
 parser (int argc, char **argv)
 
 parser (const parser &)=delete
 
 parser (parser &&)=delete
 
parseroperator= (const parser &)=delete
 
parseroperator= (parser &&)=delete
 
auto has_help () const -> bool
 
void enable_help ()
 
void disable_help ()
 
void reset ()
 
template<typename T >
void set_default (bool is_required, const std::string &description="")
 
template<typename T >
void set_required (const std::string &name, const std::string &alternative, const std::string &description="", bool dominant=false)
 
template<typename T >
void set_optional (const std::string &name, const std::string &alternative, T defaultValue, const std::string &description="", bool dominant=false)
 
template<typename T >
void set_callback (const std::string &name, const std::string &alternative, std::function< T(callback_args &)> callback, const std::string &description="", bool dominant=false)
 
void run_and_exit_if_error ()
 
auto run () -> bool
 
auto run (std::ostream &output) -> bool
 
auto run (std::ostream &output, std::ostream &error) -> bool
 
template<typename T >
auto get (const std::string &name) const -> T
 
template<typename T >
auto try_get (const std::string &name, T &result) const -> bool
 
template<typename T >
auto get_if (const std::string &name, std::function< T(T)> callback) const -> T
 
auto requirements () const -> int
 
auto commands () const -> int
 
auto app_name () const -> const std::string &
 
auto usage () const -> std::string
 

Protected Member Functions

auto find (const std::string &name) -> cmd_base *
 
auto find_default () -> cmd_base *
 
void print_help (std::stringstream &ss) const
 
auto howto_required (const std::unique_ptr< cmd_base > &command) const -> std::string
 
auto howto_use (const std::unique_ptr< cmd_base > &command) const -> std::string
 
auto no_default () const -> std::string
 

Detailed Description

Definition at line 61 of file parser.h.

Constructor & Destructor Documentation

◆ parser() [1/4]

cmd_line::parser::parser ( int argc,
const char ** argv )
explicit

Definition at line 133 of file parser.cpp.

◆ parser() [2/4]

cmd_line::parser::parser ( int argc,
char ** argv )
explicit

Definition at line 142 of file parser.cpp.

◆ parser() [3/4]

cmd_line::parser::parser ( const parser & )
delete

◆ parser() [4/4]

cmd_line::parser::parser ( parser && )
delete

Member Function Documentation

◆ app_name()

auto cmd_line::parser::app_name ( ) const -> const std::string&

Definition at line 311 of file parser.cpp.

◆ commands()

auto cmd_line::parser::commands ( ) const -> int

Definition at line 306 of file parser.cpp.

◆ disable_help()

void cmd_line::parser::disable_help ( )

Definition at line 180 of file parser.cpp.

◆ enable_help()

void cmd_line::parser::enable_help ( )

Definition at line 165 of file parser.cpp.

◆ find()

auto cmd_line::parser::find ( const std::string & name) -> cmd_base*
protected

Definition at line 395 of file parser.cpp.

◆ find_default()

auto cmd_line::parser::find_default ( ) -> cmd_base*
protected

Definition at line 381 of file parser.cpp.

◆ get()

template<typename T >
auto cmd_line::parser::get ( const std::string & name) const -> T
inline

Definition at line 335 of file parser.h.

◆ get_if()

template<typename T >
auto cmd_line::parser::get_if ( const std::string & name,
std::function< T(T)> callback ) const -> T
inline

Definition at line 378 of file parser.h.

◆ has_help()

auto cmd_line::parser::has_help ( ) const -> bool

Definition at line 151 of file parser.cpp.

◆ howto_required()

auto cmd_line::parser::howto_required ( const std::unique_ptr< cmd_base > & command) const -> std::string
protected

Definition at line 354 of file parser.cpp.

◆ howto_use()

auto cmd_line::parser::howto_use ( const std::unique_ptr< cmd_base > & command) const -> std::string
protected

Definition at line 363 of file parser.cpp.

◆ no_default()

auto cmd_line::parser::no_default ( ) const -> std::string
protected

Definition at line 372 of file parser.cpp.

◆ operator=() [1/2]

parser & cmd_line::parser::operator= ( const parser & )
delete

◆ operator=() [2/2]

parser & cmd_line::parser::operator= ( parser && )
delete

◆ print_help()

void cmd_line::parser::print_help ( std::stringstream & ss) const
protected

Definition at line 346 of file parser.cpp.

◆ requirements()

auto cmd_line::parser::requirements ( ) const -> int

Definition at line 290 of file parser.cpp.

◆ reset()

void cmd_line::parser::reset ( )

Definition at line 192 of file parser.cpp.

◆ run() [1/3]

auto cmd_line::parser::run ( ) -> bool

Definition at line 206 of file parser.cpp.

◆ run() [2/3]

auto cmd_line::parser::run ( std::ostream & output) -> bool

Definition at line 211 of file parser.cpp.

◆ run() [3/3]

auto cmd_line::parser::run ( std::ostream & output,
std::ostream & error ) -> bool

Definition at line 216 of file parser.cpp.

◆ run_and_exit_if_error()

void cmd_line::parser::run_and_exit_if_error ( )

Definition at line 198 of file parser.cpp.

◆ set_callback()

template<typename T >
void cmd_line::parser::set_callback ( const std::string & name,
const std::string & alternative,
std::function< T(callback_args &)> callback,
const std::string & description = "",
bool dominant = false )
inline

Definition at line 315 of file parser.h.

◆ set_default()

template<typename T >
void cmd_line::parser::set_default ( bool is_required,
const std::string & description = "" )
inline

Definition at line 286 of file parser.h.

◆ set_optional()

template<typename T >
void cmd_line::parser::set_optional ( const std::string & name,
const std::string & alternative,
T defaultValue,
const std::string & description = "",
bool dominant = false )
inline

Definition at line 303 of file parser.h.

◆ set_required()

template<typename T >
void cmd_line::parser::set_required ( const std::string & name,
const std::string & alternative,
const std::string & description = "",
bool dominant = false )
inline

Definition at line 293 of file parser.h.

◆ try_get()

template<typename T >
auto cmd_line::parser::try_get ( const std::string & name,
T & result ) const -> bool
inline

Definition at line 364 of file parser.h.

◆ usage()

auto cmd_line::parser::usage ( ) const -> std::string

Definition at line 316 of file parser.cpp.


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