1 //===-- OptionGroupFile.cpp -----------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8
9 #include "lldb/Interpreter/OptionGroupFile.h"
10
11 #include "lldb/Host/OptionParser.h"
12
13 using namespace lldb;
14 using namespace lldb_private;
15
OptionGroupFile(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)16 OptionGroupFile::OptionGroupFile(uint32_t usage_mask, bool required,
17 const char *long_option, int short_option,
18 uint32_t completion_type,
19 lldb::CommandArgumentType argument_type,
20 const char *usage_text)
21 : m_file() {
22 m_option_definition.usage_mask = usage_mask;
23 m_option_definition.required = required;
24 m_option_definition.long_option = long_option;
25 m_option_definition.short_option = short_option;
26 m_option_definition.validator = nullptr;
27 m_option_definition.option_has_arg = OptionParser::eRequiredArgument;
28 m_option_definition.enum_values = {};
29 m_option_definition.completion_type = completion_type;
30 m_option_definition.argument_type = argument_type;
31 m_option_definition.usage_text = usage_text;
32 }
33
~OptionGroupFile()34 OptionGroupFile::~OptionGroupFile() {}
35
SetOptionValue(uint32_t option_idx,llvm::StringRef option_arg,ExecutionContext * execution_context)36 Status OptionGroupFile::SetOptionValue(uint32_t option_idx,
37 llvm::StringRef option_arg,
38 ExecutionContext *execution_context) {
39 Status error(m_file.SetValueFromString(option_arg));
40 return error;
41 }
42
OptionParsingStarting(ExecutionContext * execution_context)43 void OptionGroupFile::OptionParsingStarting(
44 ExecutionContext *execution_context) {
45 m_file.Clear();
46 }
47
OptionGroupFileList(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)48 OptionGroupFileList::OptionGroupFileList(
49 uint32_t usage_mask, bool required, const char *long_option,
50 int short_option, uint32_t completion_type,
51 lldb::CommandArgumentType argument_type, const char *usage_text)
52 : m_file_list() {
53 m_option_definition.usage_mask = usage_mask;
54 m_option_definition.required = required;
55 m_option_definition.long_option = long_option;
56 m_option_definition.short_option = short_option;
57 m_option_definition.validator = nullptr;
58 m_option_definition.option_has_arg = OptionParser::eRequiredArgument;
59 m_option_definition.enum_values = {};
60 m_option_definition.completion_type = completion_type;
61 m_option_definition.argument_type = argument_type;
62 m_option_definition.usage_text = usage_text;
63 }
64
~OptionGroupFileList()65 OptionGroupFileList::~OptionGroupFileList() {}
66
67 Status
SetOptionValue(uint32_t option_idx,llvm::StringRef option_value,ExecutionContext * execution_context)68 OptionGroupFileList::SetOptionValue(uint32_t option_idx,
69 llvm::StringRef option_value,
70 ExecutionContext *execution_context) {
71 Status error(m_file_list.SetValueFromString(option_value));
72 return error;
73 }
74
OptionParsingStarting(ExecutionContext * execution_context)75 void OptionGroupFileList::OptionParsingStarting(
76 ExecutionContext *execution_context) {
77 m_file_list.Clear();
78 }
79