1*0b57cec5SDimitry Andric //===-- OptionGroupUUID.cpp -----------------------------------------------===//
2*0b57cec5SDimitry Andric //
3*0b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*0b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5*0b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*0b57cec5SDimitry Andric //
7*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
8*0b57cec5SDimitry Andric 
9*0b57cec5SDimitry Andric #include "lldb/Interpreter/OptionGroupUUID.h"
10*0b57cec5SDimitry Andric 
11*0b57cec5SDimitry Andric #include "lldb/Host/OptionParser.h"
12*0b57cec5SDimitry Andric 
13*0b57cec5SDimitry Andric using namespace lldb;
14*0b57cec5SDimitry Andric using namespace lldb_private;
15*0b57cec5SDimitry Andric 
16*0b57cec5SDimitry Andric static constexpr OptionDefinition g_option_table[] = {
17*0b57cec5SDimitry Andric     {LLDB_OPT_SET_1, false, "uuid", 'u', OptionParser::eRequiredArgument,
18*0b57cec5SDimitry Andric      nullptr, {}, 0, eArgTypeModuleUUID, "A module UUID value."},
19*0b57cec5SDimitry Andric };
20*0b57cec5SDimitry Andric 
GetDefinitions()21*0b57cec5SDimitry Andric llvm::ArrayRef<OptionDefinition> OptionGroupUUID::GetDefinitions() {
22*0b57cec5SDimitry Andric   return llvm::ArrayRef(g_option_table);
23*0b57cec5SDimitry Andric }
24*0b57cec5SDimitry Andric 
SetOptionValue(uint32_t option_idx,llvm::StringRef option_arg,ExecutionContext * execution_context)25*0b57cec5SDimitry Andric Status OptionGroupUUID::SetOptionValue(uint32_t option_idx,
26*0b57cec5SDimitry Andric                                        llvm::StringRef option_arg,
27*0b57cec5SDimitry Andric                                        ExecutionContext *execution_context) {
28*0b57cec5SDimitry Andric   Status error;
29*0b57cec5SDimitry Andric   const int short_option = g_option_table[option_idx].short_option;
30*0b57cec5SDimitry Andric 
31*0b57cec5SDimitry Andric   switch (short_option) {
32*0b57cec5SDimitry Andric   case 'u':
33*0b57cec5SDimitry Andric     error = m_uuid.SetValueFromString(option_arg);
34*0b57cec5SDimitry Andric     if (error.Success())
35*0b57cec5SDimitry Andric       m_uuid.SetOptionWasSet();
36*0b57cec5SDimitry Andric     break;
37*0b57cec5SDimitry Andric 
38*0b57cec5SDimitry Andric   default:
39*0b57cec5SDimitry Andric     llvm_unreachable("Unimplemented option");
40*0b57cec5SDimitry Andric   }
41*0b57cec5SDimitry Andric 
42*0b57cec5SDimitry Andric   return error;
43*0b57cec5SDimitry Andric }
44*0b57cec5SDimitry Andric 
OptionParsingStarting(ExecutionContext * execution_context)45*0b57cec5SDimitry Andric void OptionGroupUUID::OptionParsingStarting(
46*0b57cec5SDimitry Andric     ExecutionContext *execution_context) {
47*0b57cec5SDimitry Andric   m_uuid.Clear();
48*0b57cec5SDimitry Andric }
49*0b57cec5SDimitry Andric