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;
3335617911SEd Maste     m_option_definition.option_has_arg = no_argument_toggle_default ? OptionParser::eNoArgument : OptionParser::eRequiredArgument;
34ac7ddfbfSEd Maste     m_option_definition.enum_values = NULL;
35ac7ddfbfSEd Maste     m_option_definition.completion_type = 0;
36ac7ddfbfSEd Maste     m_option_definition.argument_type = eArgTypeBoolean;
37ac7ddfbfSEd Maste     m_option_definition.usage_text = usage_text;
38ac7ddfbfSEd Maste }
39ac7ddfbfSEd Maste 
40ac7ddfbfSEd Maste OptionGroupBoolean::~OptionGroupBoolean ()
41ac7ddfbfSEd Maste {
42ac7ddfbfSEd Maste }
43ac7ddfbfSEd Maste 
44ac7ddfbfSEd Maste Error
45ac7ddfbfSEd Maste OptionGroupBoolean::SetOptionValue (CommandInterpreter &interpreter,
46ac7ddfbfSEd Maste                                     uint32_t option_idx,
47ac7ddfbfSEd Maste                                     const char *option_arg)
48ac7ddfbfSEd Maste {
49ac7ddfbfSEd Maste     Error error;
5035617911SEd Maste     if (m_option_definition.option_has_arg == OptionParser::eNoArgument)
51ac7ddfbfSEd Maste     {
52ac7ddfbfSEd Maste         // Not argument, toggle the default value and mark the option as having been set
53ac7ddfbfSEd Maste         m_value.SetCurrentValue (!m_value.GetDefaultValue());
54ac7ddfbfSEd Maste         m_value.SetOptionWasSet ();
55ac7ddfbfSEd Maste     }
56ac7ddfbfSEd Maste     else
57ac7ddfbfSEd Maste     {
58ac7ddfbfSEd Maste         error = m_value.SetValueFromCString (option_arg);
59ac7ddfbfSEd Maste     }
60ac7ddfbfSEd Maste     return error;
61ac7ddfbfSEd Maste }
62ac7ddfbfSEd Maste 
63ac7ddfbfSEd Maste void
64ac7ddfbfSEd Maste OptionGroupBoolean::OptionParsingStarting (CommandInterpreter &interpreter)
65ac7ddfbfSEd Maste {
66ac7ddfbfSEd Maste     m_value.Clear();
67ac7ddfbfSEd Maste }
68