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 16ac7ddfbfSEd Maste 17ac7ddfbfSEd Maste using namespace lldb; 18ac7ddfbfSEd Maste using namespace lldb_private; 19ac7ddfbfSEd Maste 20ac7ddfbfSEd Maste OptionGroupBoolean::OptionGroupBoolean (uint32_t usage_mask, 21ac7ddfbfSEd Maste bool required, 22ac7ddfbfSEd Maste const char *long_option, 23ac7ddfbfSEd Maste int short_option, 24ac7ddfbfSEd Maste const char *usage_text, 25ac7ddfbfSEd Maste bool default_value, 26ac7ddfbfSEd Maste bool no_argument_toggle_default) : 27ac7ddfbfSEd Maste m_value (default_value, default_value) 28ac7ddfbfSEd Maste { 29ac7ddfbfSEd Maste m_option_definition.usage_mask = usage_mask; 30ac7ddfbfSEd Maste m_option_definition.required = required; 31ac7ddfbfSEd Maste m_option_definition.long_option = long_option; 32ac7ddfbfSEd Maste m_option_definition.short_option = short_option; 330127ef0fSEd Maste m_option_definition.validator = nullptr; 3435617911SEd Maste m_option_definition.option_has_arg = no_argument_toggle_default ? OptionParser::eNoArgument : 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 41ac7ddfbfSEd Maste OptionGroupBoolean::~OptionGroupBoolean () 42ac7ddfbfSEd Maste { 43ac7ddfbfSEd Maste } 44ac7ddfbfSEd Maste 45ac7ddfbfSEd Maste Error 46ac7ddfbfSEd Maste OptionGroupBoolean::SetOptionValue (CommandInterpreter &interpreter, 47ac7ddfbfSEd Maste uint32_t option_idx, 48ac7ddfbfSEd Maste const char *option_arg) 49ac7ddfbfSEd Maste { 50ac7ddfbfSEd Maste Error error; 5135617911SEd Maste if (m_option_definition.option_has_arg == OptionParser::eNoArgument) 52ac7ddfbfSEd Maste { 53ac7ddfbfSEd Maste // Not argument, toggle the default value and mark the option as having been set 54ac7ddfbfSEd Maste m_value.SetCurrentValue (!m_value.GetDefaultValue()); 55ac7ddfbfSEd Maste m_value.SetOptionWasSet (); 56ac7ddfbfSEd Maste } 57ac7ddfbfSEd Maste else 58ac7ddfbfSEd Maste { 59ac7ddfbfSEd Maste error = m_value.SetValueFromCString (option_arg); 60ac7ddfbfSEd Maste } 61ac7ddfbfSEd Maste return error; 62ac7ddfbfSEd Maste } 63ac7ddfbfSEd Maste 64ac7ddfbfSEd Maste void 65ac7ddfbfSEd Maste OptionGroupBoolean::OptionParsingStarting (CommandInterpreter &interpreter) 66ac7ddfbfSEd Maste { 67ac7ddfbfSEd Maste m_value.Clear(); 68ac7ddfbfSEd Maste } 69