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
12f678e45dSDimitry Andric #include "lldb/Host/OptionParser.h"
13ac7ddfbfSEd Maste
14ac7ddfbfSEd Maste using namespace lldb;
15ac7ddfbfSEd Maste using namespace lldb_private;
16ac7ddfbfSEd Maste
OptionGroupBoolean(uint32_t usage_mask,bool required,const char * long_option,int short_option,const char * usage_text,bool default_value,bool no_argument_toggle_default)17435933ddSDimitry Andric OptionGroupBoolean::OptionGroupBoolean(uint32_t usage_mask, bool required,
18ac7ddfbfSEd Maste const char *long_option,
19435933ddSDimitry Andric int short_option, const char *usage_text,
20ac7ddfbfSEd Maste bool default_value,
21435933ddSDimitry Andric bool no_argument_toggle_default)
22435933ddSDimitry Andric : m_value(default_value, default_value) {
23ac7ddfbfSEd Maste m_option_definition.usage_mask = usage_mask;
24ac7ddfbfSEd Maste m_option_definition.required = required;
25ac7ddfbfSEd Maste m_option_definition.long_option = long_option;
26ac7ddfbfSEd Maste m_option_definition.short_option = short_option;
270127ef0fSEd Maste m_option_definition.validator = nullptr;
28435933ddSDimitry Andric m_option_definition.option_has_arg = no_argument_toggle_default
29435933ddSDimitry Andric ? OptionParser::eNoArgument
30435933ddSDimitry Andric : OptionParser::eRequiredArgument;
31*b5893f02SDimitry Andric m_option_definition.enum_values = {};
32ac7ddfbfSEd Maste m_option_definition.completion_type = 0;
33ac7ddfbfSEd Maste m_option_definition.argument_type = eArgTypeBoolean;
34ac7ddfbfSEd Maste m_option_definition.usage_text = usage_text;
35ac7ddfbfSEd Maste }
36ac7ddfbfSEd Maste
~OptionGroupBoolean()37435933ddSDimitry Andric OptionGroupBoolean::~OptionGroupBoolean() {}
38ac7ddfbfSEd Maste
SetOptionValue(uint32_t option_idx,llvm::StringRef option_value,ExecutionContext * execution_context)395517e702SDimitry Andric Status OptionGroupBoolean::SetOptionValue(uint32_t option_idx,
40435933ddSDimitry Andric llvm::StringRef option_value,
41435933ddSDimitry Andric ExecutionContext *execution_context) {
425517e702SDimitry Andric Status error;
43435933ddSDimitry Andric if (m_option_definition.option_has_arg == OptionParser::eNoArgument) {
444ba319b5SDimitry Andric // Not argument, toggle the default value and mark the option as having
454ba319b5SDimitry Andric // been set
46ac7ddfbfSEd Maste m_value.SetCurrentValue(!m_value.GetDefaultValue());
47ac7ddfbfSEd Maste m_value.SetOptionWasSet();
48435933ddSDimitry Andric } else {
49435933ddSDimitry Andric error = m_value.SetValueFromString(option_value);
50ac7ddfbfSEd Maste }
51ac7ddfbfSEd Maste return error;
52ac7ddfbfSEd Maste }
53ac7ddfbfSEd Maste
OptionParsingStarting(ExecutionContext * execution_context)54435933ddSDimitry Andric void OptionGroupBoolean::OptionParsingStarting(
55435933ddSDimitry Andric ExecutionContext *execution_context) {
56ac7ddfbfSEd Maste m_value.Clear();
57ac7ddfbfSEd Maste }
58