Opened 8 years ago

#825 new request

access Option from Commandline

Reported by: Peter Owned by: Jari Häkkinen
Priority: major Milestone: yat 0.x+
Component: utility Version: trunk
Keywords: Cc:


There is no way to access the Options contained in a Commandline. This quirky and forces users to create a separate class that also contains the Options. A problem that the objects are stored as pointers to the base class Option*, and typically you don't want to access only the base class interface, but for an OptionArg you want to access the value() of the option.

I think a convenient interface would be something like

template<class T>
const T& option(const std::string& str) const
{ return dynamic_cast<const T&>get(long_options_, str); }

and then the similar interface for short_options_ and possibly non-const variants.

Change History (0)

Note: See TracTickets for help on using tickets.