1 //===-- OptionGroupBoolean.cpp ----------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "lldb/Interpreter/OptionGroupBoolean.h"
14 // Other libraries and framework includes
18 using namespace lldb_private;
20 OptionGroupBoolean::OptionGroupBoolean(uint32_t usage_mask, bool required,
21 const char *long_option,
22 int short_option, const char *usage_text,
24 bool no_argument_toggle_default)
25 : m_value(default_value, default_value) {
26 m_option_definition.usage_mask = usage_mask;
27 m_option_definition.required = required;
28 m_option_definition.long_option = long_option;
29 m_option_definition.short_option = short_option;
30 m_option_definition.validator = nullptr;
31 m_option_definition.option_has_arg = no_argument_toggle_default
32 ? OptionParser::eNoArgument
33 : OptionParser::eRequiredArgument;
34 m_option_definition.enum_values = nullptr;
35 m_option_definition.completion_type = 0;
36 m_option_definition.argument_type = eArgTypeBoolean;
37 m_option_definition.usage_text = usage_text;
40 OptionGroupBoolean::~OptionGroupBoolean() {}
42 Error OptionGroupBoolean::SetOptionValue(uint32_t option_idx,
43 llvm::StringRef option_value,
44 ExecutionContext *execution_context) {
46 if (m_option_definition.option_has_arg == OptionParser::eNoArgument) {
47 // Not argument, toggle the default value and mark the option as having been
49 m_value.SetCurrentValue(!m_value.GetDefaultValue());
50 m_value.SetOptionWasSet();
52 error = m_value.SetValueFromString(option_value);
57 void OptionGroupBoolean::OptionParsingStarting(
58 ExecutionContext *execution_context) {