1ac7ddfbfSEd Maste //===-- OptionGroupBoolean.cpp ----------------------------------*- C++ -*-===// 2ac7ddfbfSEd Maste // 3ac7ddfbfSEd Maste // The LLVM Compiler Infrastructure 4ac7ddfbfSEd Maste // 5ac7ddfbfSEd Maste // This file is distributed under the University of Illinois Open Source 6ac7ddfbfSEd Maste // License. See LICENSE.TXT for details. 7ac7ddfbfSEd Maste // 8ac7ddfbfSEd Maste //===----------------------------------------------------------------------===// 9ac7ddfbfSEd Maste 10ac7ddfbfSEd Maste #include "lldb/Interpreter/OptionGroupBoolean.h" 11ac7ddfbfSEd Maste 12ac7ddfbfSEd Maste // C Includes 13ac7ddfbfSEd Maste // C++ Includes 14ac7ddfbfSEd Maste // Other libraries and framework includes 15ac7ddfbfSEd Maste // Project includes 16f678e45dSDimitry Andric #include "lldb/Host/OptionParser.h" 17ac7ddfbfSEd Maste 18ac7ddfbfSEd Maste using namespace lldb; 19ac7ddfbfSEd Maste using namespace lldb_private; 20ac7ddfbfSEd Maste 21435933ddSDimitry Andric OptionGroupBoolean::OptionGroupBoolean(uint32_t usage_mask, bool required, 22ac7ddfbfSEd Maste const char *long_option, 23435933ddSDimitry Andric int short_option, const char *usage_text, 24ac7ddfbfSEd Maste bool default_value, 25435933ddSDimitry Andric bool no_argument_toggle_default) 26435933ddSDimitry Andric : m_value(default_value, default_value) { 27ac7ddfbfSEd Maste m_option_definition.usage_mask = usage_mask; 28ac7ddfbfSEd Maste m_option_definition.required = required; 29ac7ddfbfSEd Maste m_option_definition.long_option = long_option; 30ac7ddfbfSEd Maste m_option_definition.short_option = short_option; 310127ef0fSEd Maste m_option_definition.validator = nullptr; 32435933ddSDimitry Andric m_option_definition.option_has_arg = no_argument_toggle_default 33435933ddSDimitry Andric ? OptionParser::eNoArgument 34435933ddSDimitry Andric : OptionParser::eRequiredArgument; 350127ef0fSEd Maste m_option_definition.enum_values = nullptr; 36ac7ddfbfSEd Maste m_option_definition.completion_type = 0; 37ac7ddfbfSEd Maste m_option_definition.argument_type = eArgTypeBoolean; 38ac7ddfbfSEd Maste m_option_definition.usage_text = usage_text; 39ac7ddfbfSEd Maste } 40ac7ddfbfSEd Maste 41435933ddSDimitry Andric OptionGroupBoolean::~OptionGroupBoolean() {} 42ac7ddfbfSEd Maste 435517e702SDimitry Andric Status OptionGroupBoolean::SetOptionValue(uint32_t option_idx, 44435933ddSDimitry Andric llvm::StringRef option_value, 45435933ddSDimitry Andric ExecutionContext *execution_context) { 465517e702SDimitry Andric Status error; 47435933ddSDimitry Andric if (m_option_definition.option_has_arg == OptionParser::eNoArgument) { 48435933ddSDimitry Andric // Not argument, toggle the default value and mark the option as having been 49435933ddSDimitry Andric // set 50ac7ddfbfSEd Maste m_value.SetCurrentValue(!m_value.GetDefaultValue()); 51ac7ddfbfSEd Maste m_value.SetOptionWasSet(); 52435933ddSDimitry Andric } else { 53435933ddSDimitry Andric error = m_value.SetValueFromString(option_value); 54ac7ddfbfSEd Maste } 55ac7ddfbfSEd Maste return error; 56ac7ddfbfSEd Maste } 57ac7ddfbfSEd Maste 58435933ddSDimitry Andric void OptionGroupBoolean::OptionParsingStarting( 59435933ddSDimitry Andric ExecutionContext *execution_context) { 60ac7ddfbfSEd Maste m_value.Clear(); 61ac7ddfbfSEd Maste } 62