20 #ifndef PROGRAM_OPTIONS_ACCUMULATOR_HPP
21 #define PROGRAM_OPTIONS_ACCUMULATOR_HPP
23 #include <boost/program_options/value_semantic.hpp>
24 #include <boost/any.hpp>
25 #include <boost/function.hpp>
58 virtual std::string
name()
const {
return std::string(); }
73 virtual void parse(boost::any& value_store,
74 const std::vector<std::string>& new_tokens,
77 assert(new_tokens.empty());
78 if (value_store.empty()) value_store =
T();
79 boost::any_cast<
T&>(value_store) += _interval;
84 value_store = _default;
89 virtual void notify(
const boost::any& value_store)
const {
90 if (_notifier) _notifier(boost::any_cast<T>(value_store));
96 boost::function1<void, const T&> _notifier;
virtual bool apply_default(boost::any &value_store) const
If the option doesn't appear, this is the default value.
Definition: accumulator.h:83
accumulator_type * notifier(boost::function1< void, const T & > f)
Set the notifier function.
Definition: accumulator.h:38
virtual bool is_required() const
Requiring one or more appearances is unlikely.
Definition: accumulator.h:68
virtual std::string name() const
Definition: accumulator.h:58
accumulator_type * default_value(const T &t)
Set the default value for this option.
Definition: accumulator.h:44
accumulator_type()
Definition: accumulator.h:35
Definition: GnashKey.h:152
Definition: GnashKey.h:166
virtual void parse(boost::any &value_store, const std::vector< std::string > &new_tokens, bool) const
Every appearance of the option simply increments the value.
Definition: accumulator.h:73
An accumulating option value to handle multiple incrementing options.
Definition: accumulator.h:31
accumulator_type< T > * accumulator()
Definition: accumulator.h:102
virtual unsigned max_tokens() const
Definition: accumulator.h:62
virtual bool is_composing() const
Accumulating from different sources is silly.
Definition: accumulator.h:65
Definition: GnashKey.h:132
accumulator_type * implicit_value(const T &t)
Set the implicit value for this option.
Definition: accumulator.h:53
virtual ~accumulator_type()
Definition: accumulator.h:93
virtual void notify(const boost::any &value_store) const
Notify the user function with the value of the value store.
Definition: accumulator.h:89
virtual unsigned min_tokens() const
There are no tokens for an accumulator_type.
Definition: accumulator.h:61