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

#include <options.hpp>

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

Public Member Functions

 ValueArgSpec (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...
 
 ValueArgSpec (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 ~ValueArgSpec ()=default
 
virtual void set_value (const T &replacement)
 Allow setting our stored value. More...
 
virtual T get_value () const
 And getting our current effective value. More...
 
virtual bool was_set () const
 Return true if a value has been set from parsing or a preset. More...
 
virtual void parse (const char *optarg)
 
virtual void apply (Receiver &receiver) const
 Apply the value to the right field of the given object. More...
 
virtual void print_metavar (ostream &out, const char *sep="") const
 Print value metavar placeholder to the given stream after the given separator. More...
 
virtual void print_value (ostream &out, const char *sep="") const
 Print value to the given stream after the given separator. More...
 
virtual void print_default (ostream &out) const
 Print default value to the given stream, if appropriate. More...
 
virtual struct option get_option_struct () const
 Get the getopt structure for this option. Option must outlive it and not move. More...
 
- Public Member Functions inherited from 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)
 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 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 print (ostream &out, const char *sep="", const char *after="", bool slug=false) const
 

Public Attributes

Holder value
 
bool value_set = false
 
- Public Attributes inherited from vg::subcommand::ArgSpec< T, Receiver >
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, typename Holder = T>
struct vg::subcommand::ValueArgSpec< T, Receiver, Holder >

Definition structure for normal value-having options. Lets you specify storage type for the actual value.

Constructor & Destructor Documentation

◆ ValueArgSpec() [1/2]

template<typename T , typename Receiver , typename Holder = T>
vg::subcommand::ValueArgSpec< T, Receiver, Holder >::ValueArgSpec ( 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.

◆ ValueArgSpec() [2/2]

template<typename T , typename Receiver , typename Holder = T>
vg::subcommand::ValueArgSpec< T, Receiver, Holder >::ValueArgSpec ( 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.

◆ ~ValueArgSpec()

template<typename T , typename Receiver , typename Holder = T>
virtual vg::subcommand::ValueArgSpec< T, Receiver, Holder >::~ValueArgSpec ( )
virtualdefault

Member Function Documentation

◆ apply()

template<typename T , typename Receiver , typename Holder = T>
virtual void vg::subcommand::ValueArgSpec< T, Receiver, Holder >::apply ( Receiver &  receiver) const
inlinevirtual

Apply the value to the right field of the given object.

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

◆ get_option_struct()

template<typename T , typename Receiver , typename Holder = T>
virtual struct option vg::subcommand::ValueArgSpec< T, Receiver, Holder >::get_option_struct ( ) const
inlinevirtual

Get the getopt structure for this option. Option must outlive it and not move.

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

◆ get_value()

template<typename T , typename Receiver , typename Holder = T>
virtual T vg::subcommand::ValueArgSpec< T, Receiver, Holder >::get_value ( ) const
inlinevirtual

And getting our current effective value.

Implements vg::subcommand::ArgSpec< T, Receiver >.

◆ parse()

template<typename T , typename Receiver , typename Holder = T>
virtual void vg::subcommand::ValueArgSpec< T, Receiver, Holder >::parse ( const char *  optarg)
inlinevirtual

Parse the argument's value from the command line. Throws std::domain_error if validation fails.

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

Reimplemented in vg::subcommand::FlagArgSpec< Receiver >.

◆ print_default()

template<typename T , typename Receiver , typename Holder = T>
virtual void vg::subcommand::ValueArgSpec< T, Receiver, Holder >::print_default ( ostream &  out) const
inlinevirtual

Print default value to the given stream, if appropriate.

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

Reimplemented in vg::subcommand::FlagArgSpec< Receiver >.

◆ print_metavar()

template<typename T , typename Receiver , typename Holder = T>
virtual void vg::subcommand::ValueArgSpec< T, Receiver, Holder >::print_metavar ( ostream &  out,
const char *  sep = "" 
) const
inlinevirtual

Print value metavar placeholder to the given stream after the given separator.

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

Reimplemented in vg::subcommand::FlagArgSpec< Receiver >.

◆ print_value()

template<typename T , typename Receiver , typename Holder = T>
virtual void vg::subcommand::ValueArgSpec< T, Receiver, Holder >::print_value ( ostream &  out,
const char *  sep = "" 
) const
inlinevirtual

Print value to the given stream after the given separator.

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

Reimplemented in vg::subcommand::FlagArgSpec< Receiver >.

◆ set_value()

template<typename T , typename Receiver , typename Holder = T>
virtual void vg::subcommand::ValueArgSpec< T, Receiver, Holder >::set_value ( const T &  value)
inlinevirtual

Allow setting our stored value.

Implements vg::subcommand::ArgSpec< T, Receiver >.

◆ was_set()

template<typename T , typename Receiver , typename Holder = T>
virtual bool vg::subcommand::ValueArgSpec< T, Receiver, Holder >::was_set ( ) const
inlinevirtual

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

Implements vg::subcommand::ArgSpec< T, Receiver >.

Member Data Documentation

◆ value

template<typename T , typename Receiver , typename Holder = T>
Holder vg::subcommand::ValueArgSpec< T, Receiver, Holder >::value

◆ value_set

template<typename T , typename Receiver , typename Holder = T>
bool vg::subcommand::ValueArgSpec< T, Receiver, Holder >::value_set = false

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