xref: /llvm-project/lldb/source/Interpreter/OptionGroupString.cpp (revision 54d03a4985bc9a0a84c4dff835ec6ed0f607582f)
1*80814287SRaphael Isemann //===-- OptionGroupString.cpp ---------------------------------------------===//
21d19a2f2SGreg Clayton //
32946cd70SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
42946cd70SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
52946cd70SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
61d19a2f2SGreg Clayton //
71d19a2f2SGreg Clayton //===----------------------------------------------------------------------===//
81d19a2f2SGreg Clayton 
91d19a2f2SGreg Clayton #include "lldb/Interpreter/OptionGroupString.h"
101d19a2f2SGreg Clayton 
113eb2b44dSZachary Turner #include "lldb/Host/OptionParser.h"
121d19a2f2SGreg Clayton 
131d19a2f2SGreg Clayton using namespace lldb;
141d19a2f2SGreg Clayton using namespace lldb_private;
151d19a2f2SGreg Clayton 
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)16b9c1b51eSKate Stone OptionGroupString::OptionGroupString(uint32_t usage_mask, bool required,
17b9c1b51eSKate Stone                                      const char *long_option, int short_option,
181d19a2f2SGreg Clayton                                      uint32_t completion_type,
191d19a2f2SGreg Clayton                                      lldb::CommandArgumentType argument_type,
201d19a2f2SGreg Clayton                                      const char *usage_text,
21b9c1b51eSKate Stone                                      const char *default_value)
22b9c1b51eSKate Stone     : m_value(default_value, default_value) {
231d19a2f2SGreg Clayton   m_option_definition.usage_mask = usage_mask;
241d19a2f2SGreg Clayton   m_option_definition.required = required;
251d19a2f2SGreg Clayton   m_option_definition.long_option = long_option;
261d19a2f2SGreg Clayton   m_option_definition.short_option = short_option;
27df734cddSZachary Turner   m_option_definition.validator = nullptr;
28e2607b50SVirgile Bello   m_option_definition.option_has_arg = OptionParser::eRequiredArgument;
298fe53c49STatyana Krasnukha   m_option_definition.enum_values = {};
301d19a2f2SGreg Clayton   m_option_definition.completion_type = completion_type;
311d19a2f2SGreg Clayton   m_option_definition.argument_type = argument_type;
321d19a2f2SGreg Clayton   m_option_definition.usage_text = usage_text;
331d19a2f2SGreg Clayton }
341d19a2f2SGreg Clayton 
SetOptionValue(uint32_t option_idx,llvm::StringRef option_arg,ExecutionContext * execution_context)3597206d57SZachary Turner Status OptionGroupString::SetOptionValue(uint32_t option_idx,
368cef4b0bSZachary Turner                                          llvm::StringRef option_arg,
37b9c1b51eSKate Stone                                          ExecutionContext *execution_context) {
3897206d57SZachary Turner   Status error(m_value.SetValueFromString(option_arg));
391d19a2f2SGreg Clayton   return error;
401d19a2f2SGreg Clayton }
411d19a2f2SGreg Clayton 
OptionParsingStarting(ExecutionContext * execution_context)42b9c1b51eSKate Stone void OptionGroupString::OptionParsingStarting(
43b9c1b51eSKate Stone     ExecutionContext *execution_context) {
441d19a2f2SGreg Clayton   m_value.Clear();
451d19a2f2SGreg Clayton }
46