xref: /src/contrib/llvm-project/lldb/source/Interpreter/OptionGroupString.cpp (revision fe6060f10f634930ff71b7c50291ddc610da2475)
1cfca06d7SDimitry Andric //===-- OptionGroupString.cpp ---------------------------------------------===//
2f034231aSEd Maste //
35f29bb8aSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
45f29bb8aSDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
55f29bb8aSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6f034231aSEd Maste //
7f034231aSEd Maste //===----------------------------------------------------------------------===//
8f034231aSEd Maste 
9f034231aSEd Maste #include "lldb/Interpreter/OptionGroupString.h"
10f034231aSEd Maste 
1174a628f7SDimitry Andric #include "lldb/Host/OptionParser.h"
12f034231aSEd Maste 
13f034231aSEd Maste using namespace lldb;
14f034231aSEd Maste using namespace lldb_private;
15f034231aSEd Maste 
OptionGroupString(uint32_t usage_mask,bool required,const char * long_option,int short_option,uint32_t completion_type,lldb::CommandArgumentType argument_type,const char * usage_text,const char * default_value)1614f1b3e8SDimitry Andric OptionGroupString::OptionGroupString(uint32_t usage_mask, bool required,
1714f1b3e8SDimitry Andric                                      const char *long_option, int short_option,
18f034231aSEd Maste                                      uint32_t completion_type,
19f034231aSEd Maste                                      lldb::CommandArgumentType argument_type,
20f034231aSEd Maste                                      const char *usage_text,
2114f1b3e8SDimitry Andric                                      const char *default_value)
2214f1b3e8SDimitry Andric     : m_value(default_value, default_value) {
23f034231aSEd Maste   m_option_definition.usage_mask = usage_mask;
24f034231aSEd Maste   m_option_definition.required = required;
25f034231aSEd Maste   m_option_definition.long_option = long_option;
26f034231aSEd Maste   m_option_definition.short_option = short_option;
270cac4ca3SEd Maste   m_option_definition.validator = nullptr;
28f21a844fSEd Maste   m_option_definition.option_has_arg = OptionParser::eRequiredArgument;
2994994d37SDimitry Andric   m_option_definition.enum_values = {};
30f034231aSEd Maste   m_option_definition.completion_type = completion_type;
31f034231aSEd Maste   m_option_definition.argument_type = argument_type;
32f034231aSEd Maste   m_option_definition.usage_text = usage_text;
33f034231aSEd Maste }
34f034231aSEd Maste 
SetOptionValue(uint32_t option_idx,llvm::StringRef option_arg,ExecutionContext * execution_context)35b76161e4SDimitry Andric Status OptionGroupString::SetOptionValue(uint32_t option_idx,
3614f1b3e8SDimitry Andric                                          llvm::StringRef option_arg,
3714f1b3e8SDimitry Andric                                          ExecutionContext *execution_context) {
38b76161e4SDimitry Andric   Status error(m_value.SetValueFromString(option_arg));
39f034231aSEd Maste   return error;
40f034231aSEd Maste }
41f034231aSEd Maste 
OptionParsingStarting(ExecutionContext * execution_context)4214f1b3e8SDimitry Andric void OptionGroupString::OptionParsingStarting(
4314f1b3e8SDimitry Andric     ExecutionContext *execution_context) {
44f034231aSEd Maste   m_value.Clear();
45f034231aSEd Maste }
46