vg
tools for working with variation graphs
|
#include <options.hpp>
Public Member Functions | |
virtual | ~OptionGroup ()=default |
OptionGroup (const std::string &heading) | |
Make an option group woith the given heading. More... | |
virtual TickChainLink & | chain (TickChainLink &next) |
Chain through all options. More... | |
virtual void | reset_chain () |
Reset the chain to its initial values. More... | |
virtual bool | tick_chain () |
template<typename T , typename Spec = ValueArgSpec<T, Receiver>> | |
void | add_option (const std::string &name, char short_option, T Receiver::*dest, T default_value, const std::string &help, const ValidatorFunction< T > &validator=[](const T &ignored) {}) |
Add a new option that goes to the given field, with the given default. More... | |
template<typename T , typename Spec = ValueArgSpec<T, Receiver>> | |
void | add_option (const std::string &name, T Receiver::*dest, T default_value, const std::string &help, const ValidatorFunction< T > &validator=[](const T &ignored) {}) |
Add a new option that goes to the given field, with the given default. More... | |
template<typename T > | |
void | add_range (const std::string &name, char short_option, T Receiver::*dest, T default_value, const std::string &help, const ValidatorFunction< T > &validator=[](const T &ignored) {}) |
Add a new option that handles range values. More... | |
template<typename T > | |
void | add_range (const std::string &name, T Receiver::*dest, T default_value, const std::string &help, const ValidatorFunction< T > &validator=[](const T &ignored) {}) |
Add a new option that handles range values. More... | |
void | add_flag (const std::string &name, char short_option, bool Receiver::*dest, bool default_value, const std::string &help, const ValidatorFunction< bool > &validator=[](const bool &ignored) {}) |
Add a new option that is a boolean flag. More... | |
void | add_flag (const std::string &name, bool Receiver::*dest, bool default_value, const std::string &help, const ValidatorFunction< bool > &validator=[](const bool &ignored) {}) |
Add a new option that is a boolean flag. More... | |
virtual bool | parse (int option_id, const char *optarg) |
virtual bool | preset (const BaseValuation &entry) |
virtual bool | set (const BaseValuation &entry) |
virtual bool | query (BaseValuation &entry) const |
virtual void | print_options (ostream &out, OptionFormat format=OptionFormat::CLI) const |
Print all options set. More... | |
void | apply (Receiver &receiver) const |
Apply all flags to the receiver. More... | |
virtual std::vector< std::pair< std::string, std::string > > | get_help () const |
virtual void | make_long_options (std::vector< struct option > &dest) const |
Add to non-null-terminated input for getopt_long. More... | |
virtual void | make_short_options (std::string &dest) const |
Add to string input for getopt_long. More... | |
Public Member Functions inherited from vg::subcommand::BaseOptionGroup | |
virtual | ~BaseOptionGroup ()=default |
template<typename T > | |
T | get_option_value (const std::string &option) const |
template<typename T > | |
void | set_option_value (const std::string &option, const T &value) |
Allow the user to manually set an option value. More... | |
Public Member Functions inherited from vg::subcommand::TickChainLink | |
TickChainLink ()=default | |
TickChainLink (const TickChainLink &other)=delete | |
TickChainLink (TickChainLink &&other)=delete | |
TickChainLink & | operator= (const TickChainLink &other)=delete |
TickChainLink & | operator= (TickChainLink &&other)=delete |
virtual | ~TickChainLink ()=default |
virtual bool | is_static () const |
Return true if this link never changes. We assume we are static by default. More... | |
virtual std::function< void(const std::function< void(void)> &)> | get_iterator () |
Public Attributes | |
std::string | heading |
Heading we will appear under in the help. More... | |
std::vector< std::unique_ptr< BaseArgSpec< Receiver > > > | args |
Holds the argument definitions and parsing destinations. Because they are chained up they can't move. More... | |
std::unordered_map< int, size_t > | id_to_index |
Map from option ID to option index. More... | |
std::unordered_map< std::string, size_t > | option_to_index |
Map from long option to option index, to allow applying presets. More... | |
Public Attributes inherited from vg::subcommand::TickChainLink | |
std::function< void(void)> | reset_along_chain_parent |
This will be called when we want to reset_along_chain what we are chained onto. More... | |
std::function< bool(void)> | tick_along_chain_parent |
This will be called when we need to tick_along_chain our parent. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from vg::subcommand::TickChainLink | |
virtual bool | tick_along_chain () |
virtual void | reset_along_chain () |
Represents a set of command-line options that can be applied to an object. Internal values can be ranges that can be ticked. Comes with a heading.
|
virtualdefault |
|
inline |
Make an option group woith the given heading.
|
inline |
Add a new option that is a boolean flag.
|
inline |
Add a new option that is a boolean flag.
|
inline |
Add a new option that goes to the given field, with the given default.
|
inline |
Add a new option that goes to the given field, with the given default.
|
inline |
Add a new option that handles range values.
|
inline |
Add a new option that handles range values.
|
inline |
Apply all flags to the receiver.
|
inlinevirtual |
Chain through all options.
Reimplemented from vg::subcommand::TickChainLink.
|
inlinevirtual |
Get help, in the form of pairs of options and descriptions. Headings are descriptions without options.
Implements vg::subcommand::BaseOptionGroup.
|
inlinevirtual |
Add to non-null-terminated input for getopt_long.
Implements vg::subcommand::BaseOptionGroup.
|
inlinevirtual |
Add to string input for getopt_long.
Implements vg::subcommand::BaseOptionGroup.
|
inlinevirtual |
Parse the given option ID, with the given value if needed. Return true if we matched the ID, and false otherwise.
Implements vg::subcommand::BaseOptionGroup.
|
inlinevirtual |
Apply a preset value to its option. Returns true if it was found, and false otherwies.
Implements vg::subcommand::BaseOptionGroup.
|
inlinevirtual |
Print all options set.
Implements vg::subcommand::BaseOptionGroup.
|
inlinevirtual |
Fill in entry with the value of the correspondign option, if we have that option. If so, return true.
Implements vg::subcommand::BaseOptionGroup.
|
inlinevirtual |
Reset the chain to its initial values.
Reimplemented from vg::subcommand::TickChainLink.
|
inlinevirtual |
Apply a value to its option. Returns true if it was found, and false otherwies.
Implements vg::subcommand::BaseOptionGroup.
|
inlinevirtual |
Tick the chain. Return true if there's still a value for the chain, and false if the chain is out of values. Should be called on the last item in the chain. May delegate to a different item (for e.g. groups).
Reimplemented from vg::subcommand::TickChainLink.
std::vector<std::unique_ptr<BaseArgSpec<Receiver> > > vg::subcommand::OptionGroup< Receiver >::args |
Holds the argument definitions and parsing destinations. Because they are chained up they can't move.
std::string vg::subcommand::OptionGroup< Receiver >::heading |
Heading we will appear under in the help.
std::unordered_map<int, size_t> vg::subcommand::OptionGroup< Receiver >::id_to_index |
Map from option ID to option index.
std::unordered_map<std::string, size_t> vg::subcommand::OptionGroup< Receiver >::option_to_index |
Map from long option to option index, to allow applying presets.