Path: blob/main/contrib/llvm-project/lldb/source/Interpreter/OptionGroupBoolean.cpp
39587 views
//===-- OptionGroupBoolean.cpp --------------------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#include "lldb/Interpreter/OptionGroupBoolean.h"910#include "lldb/Host/OptionParser.h"1112using namespace lldb;13using namespace lldb_private;1415OptionGroupBoolean::OptionGroupBoolean(uint32_t usage_mask, bool required,16const char *long_option,17int short_option, const char *usage_text,18bool default_value,19bool no_argument_toggle_default)20: m_value(default_value, default_value) {21m_option_definition.usage_mask = usage_mask;22m_option_definition.required = required;23m_option_definition.long_option = long_option;24m_option_definition.short_option = short_option;25m_option_definition.validator = nullptr;26m_option_definition.option_has_arg = no_argument_toggle_default27? OptionParser::eNoArgument28: OptionParser::eRequiredArgument;29m_option_definition.enum_values = {};30m_option_definition.completion_type = 0;31m_option_definition.argument_type = eArgTypeBoolean;32m_option_definition.usage_text = usage_text;33}3435Status OptionGroupBoolean::SetOptionValue(uint32_t option_idx,36llvm::StringRef option_value,37ExecutionContext *execution_context) {38Status error;39if (m_option_definition.option_has_arg == OptionParser::eNoArgument) {40// Not argument, toggle the default value and mark the option as having41// been set42m_value.SetCurrentValue(!m_value.GetDefaultValue());43m_value.SetOptionWasSet();44} else {45error = m_value.SetValueFromString(option_value);46}47return error;48}4950void OptionGroupBoolean::OptionParsingStarting(51ExecutionContext *execution_context) {52m_value.Clear();53}545556