vg
tools for working with variation graphs
Public Member Functions | Public Attributes | List of all members
vg::subcommand::ArgSpec< T, Receiver > Struct Template Referenceabstract

#include <options.hpp>

Inheritance diagram for vg::subcommand::ArgSpec< T, Receiver >:
vg::subcommand::BaseArgSpec< Receiver > vg::subcommand::TickChainLink vg::subcommand::ValueArgSpec< T, Receiver, Range< T > > vg::subcommand::ValueArgSpec< T, Receiver, Holder > vg::subcommand::RangeArgSpec< T, Receiver >

Public Member Functions

 ArgSpec (const std::string &option, char short_option, T Receiver::*dest, const T &default_value, const std::string &help, const ValidatorFunction< T > &validator)
 Make an option with a long and short option name. More...
 
 ArgSpec (const std::string &option, T Receiver::*dest, const T &default_value, const std::string &help, const ValidatorFunction< T > &validator)
 Make an option with a long option name only. More...
 
virtual ~ArgSpec ()=default
 
virtual void set_value (const T &value)=0
 Allow setting our stored value. More...
 
virtual T get_value () const =0
 And getting our current effective value. More...
 
virtual bool was_set () const =0
 Return true if a value has been set from parsing or a preset. More...
 
virtual void preset (const BaseValuation &entry)
 
virtual void set (const BaseValuation &entry)
 
virtual void query (BaseValuation &entry) const
 
- Public Member Functions inherited from vg::subcommand::BaseArgSpec< Receiver >
 BaseArgSpec (const std::string &option, char short_option, const std::string &help)
 Make an option with a long and short option name. More...
 
 BaseArgSpec (const std::string &option, const std::string &help)
 Make an option with a long option name only. More...
 
virtual ~BaseArgSpec ()=default
 
virtual void parse (const char *optarg)=0
 
virtual void apply (Receiver &receiver) const =0
 Apply the value to the right field of the given object. More...
 
virtual void print_value (ostream &out, const char *sep="") const =0
 Print value to the given stream after the given separator. More...
 
virtual void print_metavar (ostream &out, const char *sep="") const =0
 Print value metavar placeholder to the given stream after the given separator. More...
 
virtual void print_default (ostream &out) const =0
 Print default value to the given stream, if appropriate. More...
 
virtual void print (ostream &out, const char *sep="", const char *after="", bool slug=false) const
 
virtual struct option get_option_struct () const =0
 Get the getopt structure for this option. Option must outlive it and not move. More...
 

Public Attributes

T Receiver::* dest
 Field in the receiving type we set. More...
 
default_value
 Original default value. More...
 
ValidatorFunction< T > validator
 Function to check value with. More...
 
- Public Attributes inherited from vg::subcommand::BaseArgSpec< Receiver >
std::string option
 Name of the option (long opt) More...
 
std::string help
 Help for the option. More...
 
char short_option
 Character of the option (short opt), or 0. More...
 
int option_id
 Int value to represent the option. More...
 

Detailed Description

template<typename T, typename Receiver>
struct vg::subcommand::ArgSpec< T, Receiver >

Interface for a command-line argument that corresponds to a value of a given type. Storage method is left to be implemented by inheritor.

Constructor & Destructor Documentation

◆ ArgSpec() [1/2]

template<typename T , typename Receiver >
vg::subcommand::ArgSpec< T, Receiver >::ArgSpec ( const std::string &  option,
char  short_option,
T Receiver::*  dest,
const T &  default_value,
const std::string &  help,
const ValidatorFunction< T > &  validator 
)
inline

Make an option with a long and short option name.

◆ ArgSpec() [2/2]

template<typename T , typename Receiver >
vg::subcommand::ArgSpec< T, Receiver >::ArgSpec ( const std::string &  option,
T Receiver::*  dest,
const T &  default_value,
const std::string &  help,
const ValidatorFunction< T > &  validator 
)
inline

Make an option with a long option name only.

◆ ~ArgSpec()

template<typename T , typename Receiver >
virtual vg::subcommand::ArgSpec< T, Receiver >::~ArgSpec ( )
virtualdefault

Member Function Documentation

◆ get_value()

template<typename T , typename Receiver >
virtual T vg::subcommand::ArgSpec< T, Receiver >::get_value ( ) const
pure virtual

And getting our current effective value.

Implemented in vg::subcommand::ValueArgSpec< T, Receiver, Holder >, and vg::subcommand::ValueArgSpec< bool, Receiver >.

◆ preset()

template<typename T , typename Receiver >
virtual void vg::subcommand::ArgSpec< T, Receiver >::preset ( const BaseValuation entry)
inlinevirtual

Apply a preset item, or fail if it doesn't match. The preset value will sit under any parsed value but above the default.

Implements vg::subcommand::BaseArgSpec< Receiver >.

◆ query()

template<typename T , typename Receiver >
virtual void vg::subcommand::ArgSpec< T, Receiver >::query ( BaseValuation entry) const
inlinevirtual

Put our current effective value into the given BaseValuation, which must be for the right option and have the right type.

Implements vg::subcommand::BaseArgSpec< Receiver >.

◆ set()

template<typename T , typename Receiver >
virtual void vg::subcommand::ArgSpec< T, Receiver >::set ( const BaseValuation entry)
inlinevirtual

Apply a valuation, or fail if it doesn't match. The value will replace any parsed value! Validation will not be run!

Implements vg::subcommand::BaseArgSpec< Receiver >.

◆ set_value()

template<typename T , typename Receiver >
virtual void vg::subcommand::ArgSpec< T, Receiver >::set_value ( const T &  value)
pure virtual

◆ was_set()

template<typename T , typename Receiver >
virtual bool vg::subcommand::ArgSpec< T, Receiver >::was_set ( ) const
pure virtual

Return true if a value has been set from parsing or a preset.

Implemented in vg::subcommand::ValueArgSpec< T, Receiver, Holder >, and vg::subcommand::ValueArgSpec< bool, Receiver >.

Member Data Documentation

◆ default_value

template<typename T , typename Receiver >
T vg::subcommand::ArgSpec< T, Receiver >::default_value

Original default value.

◆ dest

template<typename T , typename Receiver >
T Receiver::* vg::subcommand::ArgSpec< T, Receiver >::dest

Field in the receiving type we set.

◆ validator

template<typename T , typename Receiver >
ValidatorFunction<T> vg::subcommand::ArgSpec< T, Receiver >::validator

Function to check value with.


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