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

#include <options.hpp>

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

Public Member Functions

 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 preset (const BaseValuation &entry)=0
 
virtual void set (const BaseValuation &entry)=0
 
virtual void query (BaseValuation &entry) const =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

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 Receiver>
struct vg::subcommand::BaseArgSpec< Receiver >

Interface for a command-line argument that goes into a field on an object of the given type.

Constructor & Destructor Documentation

◆ BaseArgSpec() [1/2]

template<typename Receiver >
vg::subcommand::BaseArgSpec< Receiver >::BaseArgSpec ( const std::string &  option,
char  short_option,
const std::string &  help 
)
inline

Make an option with a long and short option name.

◆ BaseArgSpec() [2/2]

template<typename Receiver >
vg::subcommand::BaseArgSpec< Receiver >::BaseArgSpec ( const std::string &  option,
const std::string &  help 
)
inline

Make an option with a long option name only.

◆ ~BaseArgSpec()

template<typename Receiver >
virtual vg::subcommand::BaseArgSpec< Receiver >::~BaseArgSpec ( )
virtualdefault

Member Function Documentation

◆ apply()

template<typename Receiver >
virtual void vg::subcommand::BaseArgSpec< Receiver >::apply ( Receiver &  receiver) const
pure virtual

◆ get_option_struct()

template<typename Receiver >
virtual struct option vg::subcommand::BaseArgSpec< Receiver >::get_option_struct ( ) const
pure virtual

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

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

◆ parse()

template<typename Receiver >
virtual void vg::subcommand::BaseArgSpec< Receiver >::parse ( const char *  optarg)
pure virtual

◆ preset()

template<typename Receiver >
virtual void vg::subcommand::BaseArgSpec< Receiver >::preset ( const BaseValuation entry)
pure virtual

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

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

◆ print()

template<typename Receiver >
virtual void vg::subcommand::BaseArgSpec< Receiver >::print ( ostream &  out,
const char *  sep = "",
const char *  after = "",
bool  slug = false 
) const
inlinevirtual

Print option and value to the given stream, without newlines, between the given separators. If slug is set, use short option if available and don't include spaces.

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

◆ print_default()

template<typename Receiver >
virtual void vg::subcommand::BaseArgSpec< Receiver >::print_default ( ostream &  out) const
pure virtual

◆ print_metavar()

template<typename Receiver >
virtual void vg::subcommand::BaseArgSpec< Receiver >::print_metavar ( ostream &  out,
const char *  sep = "" 
) const
pure virtual

◆ print_value()

template<typename Receiver >
virtual void vg::subcommand::BaseArgSpec< Receiver >::print_value ( ostream &  out,
const char *  sep = "" 
) const
pure virtual

◆ query()

template<typename Receiver >
virtual void vg::subcommand::BaseArgSpec< Receiver >::query ( BaseValuation entry) const
pure virtual

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

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

◆ set()

template<typename Receiver >
virtual void vg::subcommand::BaseArgSpec< Receiver >::set ( const BaseValuation entry)
pure virtual

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

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

Member Data Documentation

◆ help

template<typename Receiver >
std::string vg::subcommand::BaseArgSpec< Receiver >::help

Help for the option.

◆ option

template<typename Receiver >
std::string vg::subcommand::BaseArgSpec< Receiver >::option

Name of the option (long opt)

◆ option_id

template<typename Receiver >
int vg::subcommand::BaseArgSpec< Receiver >::option_id

Int value to represent the option.

◆ short_option

template<typename Receiver >
char vg::subcommand::BaseArgSpec< Receiver >::short_option

Character of the option (short opt), or 0.


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