32using std::string_view;
49 [[nodiscard]]
virtual auto get_name() const noexcept -> string_view = 0;
57 [[nodiscard]] virtual auto
get_type() const noexcept -> string_view = 0;
60 [[nodiscard]] virtual auto
get_help() const noexcept -> string_view = 0;
65 [[nodiscard]] virtual auto
has_value() const noexcept ->
bool {
return true; }
68 using Variant = std::variant<bool, int, string_view>;
96 string name,
bool defaultValue,
98 Callback&& changeCallback = [](
bool) { });
103 [[nodiscard]]
auto get_value() const noexcept ->
bool {
return value; }
115 [[nodiscard]]
auto get_name() const noexcept -> string_view
override {
return optionName; }
119 [[nodiscard]] auto
get_type() const noexcept -> string_view
override {
return "Toggle"; }
121 [[nodiscard]]
auto get_help() const noexcept -> string_view
override {
return help; }
128 bool optionDefault {
true };
130 bool value { optionDefault };
134 Callback onChange { [](bool) { } };
148 int minValue,
int maxValue,
151 Callback&& changeCallback = [](
int) { });
156 [[nodiscard]]
auto get_value() const noexcept ->
int {
return value; }
168 [[nodiscard]]
auto get_name() const noexcept -> string_view
override {
return optionName; }
172 [[nodiscard]] auto
get_type() const noexcept -> string_view
override {
return "Integer"; }
174 [[nodiscard]]
auto get_help() const noexcept -> string_view
override {
return help; }
182 int optionMax { 100 };
184 int optionDefault { 0 };
186 int value { optionDefault };
190 Callback onChange { [](int) { } };
204 std::vector<string> values,
207 Callback&& changeCallback = [](string_view) { });
209 [[nodiscard]]
auto get_value() const noexcept -> string_view {
return value; }
221 [[nodiscard]]
auto get_name() const noexcept -> string_view
override {
return optionName; }
225 [[nodiscard]] auto
get_type() const noexcept -> string_view
override {
return "Multichoice"; }
227 [[nodiscard]]
auto get_help() const noexcept -> string_view
override {
return help; }
234 std::vector<string> possibleValues;
236 string optionDefault;
238 string value { optionDefault };
242 Callback onChange { [](string_view) { } };
258 Callback&& changeCallback = [](string_view) { });
260 [[nodiscard]]
auto get_value() const noexcept -> string_view
262 if (value ==
"<empty>")
275 [[nodiscard]]
auto get_name() const noexcept -> string_view
override {
return optionName; }
279 [[nodiscard]] auto
get_type() const noexcept -> string_view
override {
return "String"; }
281 [[nodiscard]]
auto get_help() const noexcept -> string_view
override {
return help; }
292 Callback onChange { [](string_view) { } };
312 [[nodiscard]]
auto get_name() const noexcept -> string_view
override {
return optionName; }
316 [[nodiscard]] auto
get_type() const noexcept -> string_view
override {
return "Button"; }
318 [[nodiscard]]
auto get_help() const noexcept -> string_view
override {
return help; }
320 [[nodiscard]]
auto has_value() const noexcept ->
bool override {
return false; }
325 [[noreturn]]
static void throw_value_error()
327 throw std::logic_error {
"get_value_variant() called on option of Action type" };
auto get_type() const noexcept -> string_view override
Action(string name, Callback &&action, string helpString)
auto get_default_value_variant() const -> Variant override
auto get_declaration_string() const -> string override
auto has_value() const noexcept -> bool override
std::function< void()> Callback
auto get_help() const noexcept -> string_view override
auto get_value_variant() const -> Variant override
auto get_name() const noexcept -> string_view override
void handle_setvalue(string_view arguments) override
auto get_default_value_variant() const -> Variant override
auto get_help() const noexcept -> string_view override
std::function< void(bool)> Callback
auto get_value() const noexcept -> bool
BoolOption(string name, bool defaultValue, string helpString, Callback &&changeCallback=[](bool) { })
void set_value(bool newValue)
auto get_default_value() const noexcept -> bool
void handle_setvalue(string_view arguments) override
auto get_value_variant() const -> Variant override
auto get_declaration_string() const -> string override
auto get_name() const noexcept -> string_view override
auto get_type() const noexcept -> string_view override
auto get_type() const noexcept -> string_view override
auto get_default_value_variant() const -> Variant override
auto get_name() const noexcept -> string_view override
auto get_help() const noexcept -> string_view override
auto get_declaration_string() const -> string override
ComboOption(string name, std::vector< string > values, string defaultValue, string helpString, Callback &&changeCallback=[](string_view) { })
std::function< void(string_view)> Callback
void set_value(string_view newValue)
auto get_value_variant() const -> Variant override
auto get_value() const noexcept -> string_view
auto get_default_value() const noexcept -> string_view
void handle_setvalue(string_view arguments) override
void handle_setvalue(string_view arguments) override
std::function< void(int)> Callback
void set_value(int newValue)
auto get_name() const noexcept -> string_view override
auto get_value() const noexcept -> int
auto get_help() const noexcept -> string_view override
auto get_value_variant() const -> Variant override
auto get_default_value() const noexcept -> int
IntOption(string name, int minValue, int maxValue, int defaultValue, string helpString, Callback &&changeCallback=[](int) { })
auto get_declaration_string() const -> string override
auto get_type() const noexcept -> string_view override
auto get_default_value_variant() const -> Variant override
Option & operator=(Option &&)=default
std::variant< bool, int, string_view > Variant
virtual auto get_declaration_string() const -> string=0
virtual auto get_help() const noexcept -> string_view=0
Option(const Option &)=default
virtual auto has_value() const noexcept -> bool
Option(Option &&)=default
Option & operator=(const Option &)=default
virtual auto get_name() const noexcept -> string_view=0
virtual auto get_default_value_variant() const -> Variant=0
virtual auto get_type() const noexcept -> string_view=0
virtual void handle_setvalue(string_view arguments)=0
virtual auto get_value_variant() const -> Variant=0
StringOption(string name, string defaultValue, string helpString, Callback &&changeCallback=[](string_view) { })
auto get_type() const noexcept -> string_view override
void set_value(string_view newValue)
auto get_declaration_string() const -> string override
std::function< void(string_view)> Callback
auto get_value_variant() const -> Variant override
auto get_value() const noexcept -> string_view
auto get_name() const noexcept -> string_view override
void handle_setvalue(string_view arguments) override
auto get_default_value_variant() const -> Variant override
auto get_help() const noexcept -> string_view override