| 77 | }; |
| 78 | |
| 79 | class ActionFlag : Flag |
| 80 | { |
| 81 | public: |
| 82 | ActionFlag(const std::vector<std::string>& names, |
| 83 | const std::string helptext, |
| 84 | std::function<void(void)> callback): |
| 85 | Flag(names, helptext), |
| 86 | _voidCallback(callback), |
| 87 | _hasArgument(false) |
| 88 | { |
| 89 | } |
| 90 | |
| 91 | ActionFlag(const std::vector<std::string>& names, |
| 92 | const std::string helptext, |
| 93 | std::function<void(const std::string&)> callback): |
| 94 | Flag(names, helptext), |
| 95 | _callback(callback), |
| 96 | _hasArgument(true) |
| 97 | { |
| 98 | } |
| 99 | |
| 100 | bool hasArgument() const override |
| 101 | { |
| 102 | return _hasArgument; |
| 103 | } |
| 104 | |
| 105 | const std::string defaultValueAsString() const override |
| 106 | { |
| 107 | return ""; |
| 108 | } |
| 109 | |
| 110 | void set(const std::string& value) override |
| 111 | { |
| 112 | if (_hasArgument) |
| 113 | _callback(value); |
| 114 | else |
| 115 | _voidCallback(); |
| 116 | } |
| 117 | |
| 118 | private: |
| 119 | const std::function<void(const std::string&)> _callback; |
| 120 | const std::function<void(void)> _voidCallback; |
| 121 | bool _hasArgument; |
| 122 | }; |
| 123 | |
| 124 | class SettableFlag : public Flag |
| 125 | { |