WPILibC++ 2025.1.1
Loading...
Searching...
No Matches
wpi::Argument Class Reference

#include <wpi/argparse.h>

Public Member Functions

template<std::size_t N>
 Argument (std::string_view prefix_chars, std::array< std::string_view, N > &&a)
 
Argumenthelp (std::string help_text)
 
Argumentmetavar (std::string metavar)
 
template<typename T >
Argumentdefault_value (T &&value)
 
Argumentdefault_value (const char *value)
 
Argumentrequired ()
 
Argumentimplicit_value (std::any value)
 
Argumentflag ()
 
template<class F , class... Args>
auto action (F &&callable, Args &&... bound_args) -> std::enable_if_t< std::is_invocable_v< F, Args..., std::string const >, Argument & >
 
auto & store_into (bool &var)
 
template<typename T , typename std::enable_if< std::is_integral< T >::value >::type * = nullptr>
auto & store_into (T &var)
 
auto & store_into (double &var)
 
auto & store_into (std::string &var)
 
auto & store_into (std::vector< std::string > &var)
 
auto & store_into (std::vector< int > &var)
 
auto & store_into (std::set< std::string > &var)
 
auto & store_into (std::set< int > &var)
 
auto & append ()
 
auto & hidden ()
 
template<char Shape, typename T >
auto scan () -> std::enable_if_t< std::is_arithmetic_v< T >, Argument & >
 
Argumentnargs (std::size_t num_args)
 
Argumentnargs (std::size_t num_args_min, std::size_t num_args_max)
 
Argumentnargs (nargs_pattern pattern)
 
Argumentremaining ()
 
template<typename T >
void add_choice (T &&choice)
 
Argumentchoices ()
 
template<typename T , typename... U>
Argumentchoices (T &&first, U &&... rest)
 
void find_default_value_in_choices_or_throw () const
 
template<typename Iterator >
void find_value_in_choices_or_throw (Iterator it) const
 
template<typename Iterator >
Iterator consume (Iterator start, Iterator end, std::string_view used_name={}, bool dry_run=false)
 
void validate () const
 
std::string get_names_csv (char separator=',') const
 
std::string get_usage_full () const
 
std::string get_inline_usage () const
 
std::size_t get_arguments_length () const
 
template<typename T >
bool operator!= (const T &rhs) const
 
template<typename T >
bool operator== (const T &rhs) const
 

Static Public Member Functions

static bool is_positional (std::string_view name, std::string_view prefix_chars)
 

Friends

class ArgumentParser
 
auto operator<< (std::ostream &stream, const ArgumentParser &parser) -> std::ostream &
 
std::ostream & operator<< (std::ostream &stream, const Argument &argument)
 

Constructor & Destructor Documentation

◆ Argument()

template<std::size_t N>
wpi::Argument::Argument ( std::string_view prefix_chars,
std::array< std::string_view, N > && a )
inlineexplicit

Member Function Documentation

◆ action()

template<class F , class... Args>
auto wpi::Argument::action ( F && callable,
Args &&... bound_args ) -> std::enable_if_t<std::is_invocable_v<F, Args..., std::string const>, Argument &>
inline

◆ add_choice()

template<typename T >
void wpi::Argument::add_choice ( T && choice)
inline

◆ append()

auto & wpi::Argument::append ( )
inline

◆ choices() [1/2]

Argument & wpi::Argument::choices ( )
inline

◆ choices() [2/2]

template<typename T , typename... U>
Argument & wpi::Argument::choices ( T && first,
U &&... rest )
inline

◆ consume()

template<typename Iterator >
Iterator wpi::Argument::consume ( Iterator start,
Iterator end,
std::string_view used_name = {},
bool dry_run = false )
inline

◆ default_value() [1/2]

Argument & wpi::Argument::default_value ( const char * value)
inline

◆ default_value() [2/2]

template<typename T >
Argument & wpi::Argument::default_value ( T && value)
inline

◆ find_default_value_in_choices_or_throw()

void wpi::Argument::find_default_value_in_choices_or_throw ( ) const
inline

◆ find_value_in_choices_or_throw()

template<typename Iterator >
void wpi::Argument::find_value_in_choices_or_throw ( Iterator it) const
inline

◆ flag()

Argument & wpi::Argument::flag ( )
inline

◆ get_arguments_length()

std::size_t wpi::Argument::get_arguments_length ( ) const
inline

◆ get_inline_usage()

std::string wpi::Argument::get_inline_usage ( ) const
inline

◆ get_names_csv()

std::string wpi::Argument::get_names_csv ( char separator = ',') const
inline

◆ get_usage_full()

std::string wpi::Argument::get_usage_full ( ) const
inline

◆ help()

Argument & wpi::Argument::help ( std::string help_text)
inline

◆ hidden()

auto & wpi::Argument::hidden ( )
inline

◆ implicit_value()

Argument & wpi::Argument::implicit_value ( std::any value)
inline

◆ is_positional()

static bool wpi::Argument::is_positional ( std::string_view name,
std::string_view prefix_chars )
inlinestatic

◆ metavar()

Argument & wpi::Argument::metavar ( std::string metavar)
inline

◆ nargs() [1/3]

Argument & wpi::Argument::nargs ( nargs_pattern pattern)
inline

◆ nargs() [2/3]

Argument & wpi::Argument::nargs ( std::size_t num_args)
inline

◆ nargs() [3/3]

Argument & wpi::Argument::nargs ( std::size_t num_args_min,
std::size_t num_args_max )
inline

◆ operator!=()

template<typename T >
bool wpi::Argument::operator!= ( const T & rhs) const
inline

◆ operator==()

template<typename T >
bool wpi::Argument::operator== ( const T & rhs) const
inline

◆ remaining()

Argument & wpi::Argument::remaining ( )
inline

◆ required()

Argument & wpi::Argument::required ( )
inline

◆ scan()

template<char Shape, typename T >
auto wpi::Argument::scan ( ) -> std::enable_if_t<std::is_arithmetic_v<T>, Argument &>
inline

◆ store_into() [1/8]

auto & wpi::Argument::store_into ( bool & var)
inline

◆ store_into() [2/8]

auto & wpi::Argument::store_into ( double & var)
inline

◆ store_into() [3/8]

auto & wpi::Argument::store_into ( std::set< int > & var)
inline

◆ store_into() [4/8]

auto & wpi::Argument::store_into ( std::set< std::string > & var)
inline

◆ store_into() [5/8]

auto & wpi::Argument::store_into ( std::string & var)
inline

◆ store_into() [6/8]

auto & wpi::Argument::store_into ( std::vector< int > & var)
inline

◆ store_into() [7/8]

auto & wpi::Argument::store_into ( std::vector< std::string > & var)
inline

◆ store_into() [8/8]

template<typename T , typename std::enable_if< std::is_integral< T >::value >::type * = nullptr>
auto & wpi::Argument::store_into ( T & var)
inline

◆ validate()

void wpi::Argument::validate ( ) const
inline

Friends And Related Symbol Documentation

◆ ArgumentParser

friend class ArgumentParser
friend

◆ operator<< [1/2]

std::ostream & operator<< ( std::ostream & stream,
const Argument & argument )
friend

◆ operator<< [2/2]

auto operator<< ( std::ostream & stream,
const ArgumentParser & parser ) -> std::ostream &
friend

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