MCPcopy Create free account
hub / github.com/davidgiven/fluxengine / ActionFlag

Class ActionFlag

lib/config/flags.h:79–122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77};
78
79class ActionFlag : Flag
80{
81public:
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
118private:
119 const std::function<void(const std::string&)> _callback;
120 const std::function<void(void)> _voidCallback;
121 bool _hasArgument;
122};
123
124class SettableFlag : public Flag
125{

Callers 1

flags.ccFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected