LLDB  mainline
OptionGroupBoolean.cpp
Go to the documentation of this file.
1 //===-- OptionGroupBoolean.cpp ----------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
10 
11 #include "lldb/Host/OptionParser.h"
12 
13 using namespace lldb;
14 using namespace lldb_private;
15 
16 OptionGroupBoolean::OptionGroupBoolean(uint32_t usage_mask, bool required,
17  const char *long_option,
18  int short_option, const char *usage_text,
19  bool default_value,
20  bool no_argument_toggle_default)
21  : m_value(default_value, default_value) {
22  m_option_definition.usage_mask = usage_mask;
23  m_option_definition.required = required;
24  m_option_definition.long_option = long_option;
25  m_option_definition.short_option = short_option;
26  m_option_definition.validator = nullptr;
27  m_option_definition.option_has_arg = no_argument_toggle_default
30  m_option_definition.enum_values = {};
31  m_option_definition.completion_type = 0;
32  m_option_definition.argument_type = eArgTypeBoolean;
33  m_option_definition.usage_text = usage_text;
34 }
35 
37 
39  llvm::StringRef option_value,
40  ExecutionContext *execution_context) {
41  Status error;
42  if (m_option_definition.option_has_arg == OptionParser::eNoArgument) {
43  // Not argument, toggle the default value and mark the option as having
44  // been set
47  } else {
48  error = m_value.SetValueFromString(option_value);
49  }
50  return error;
51 }
52 
54  ExecutionContext *execution_context) {
55  m_value.Clear();
56 }
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_value, ExecutionContext *execution_context) override
Status SetValueFromString(llvm::StringRef value, VarSetOperationType op=eVarSetOperationAssign) override
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
void OptionParsingStarting(ExecutionContext *execution_context) override
Definition: SBAddress.h:15
An error handling class.
Definition: Status.h:44