1//===-- OptionGroupBoolean.cpp ----------------------------------*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 10#include "lldb/Interpreter/OptionGroupBoolean.h" 11 12// C Includes 13// C++ Includes 14// Other libraries and framework includes 15// Project includes 16 17using namespace lldb; 18using namespace lldb_private; 19 20OptionGroupBoolean::OptionGroupBoolean (uint32_t usage_mask, 21 bool required, 22 const char *long_option, 23 int short_option, 24 const char *usage_text, 25 bool default_value, 26 bool no_argument_toggle_default) : 27 m_value (default_value, default_value) 28{ 29 m_option_definition.usage_mask = usage_mask; 30 m_option_definition.required = required; 31 m_option_definition.long_option = long_option; 32 m_option_definition.short_option = short_option; 33 m_option_definition.option_has_arg = no_argument_toggle_default ? no_argument : required_argument; 34 m_option_definition.enum_values = NULL; 35 m_option_definition.completion_type = 0; 36 m_option_definition.argument_type = eArgTypeBoolean; 37 m_option_definition.usage_text = usage_text; 38} 39 40OptionGroupBoolean::~OptionGroupBoolean () 41{ 42} 43 44Error 45OptionGroupBoolean::SetOptionValue (CommandInterpreter &interpreter, 46 uint32_t option_idx, 47 const char *option_arg) 48{ 49 Error error; 50 if (m_option_definition.option_has_arg == no_argument) 51 { 52 // Not argument, toggle the default value and mark the option as having been set 53 m_value.SetCurrentValue (!m_value.GetDefaultValue()); 54 m_value.SetOptionWasSet (); 55 } 56 else 57 { 58 error = m_value.SetValueFromCString (option_arg); 59 } 60 return error; 61} 62 63void 64OptionGroupBoolean::OptionParsingStarting (CommandInterpreter &interpreter) 65{ 66 m_value.Clear(); 67} 68