1cfca06d7SDimitry Andric //===-- OptionGroupFile.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/OptionGroupFile.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
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)1614f1b3e8SDimitry Andric OptionGroupFile::OptionGroupFile(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,
20344a3780SDimitry Andric const char *usage_text) {
21f034231aSEd Maste m_option_definition.usage_mask = usage_mask;
22f034231aSEd Maste m_option_definition.required = required;
23f034231aSEd Maste m_option_definition.long_option = long_option;
24f034231aSEd Maste m_option_definition.short_option = short_option;
250cac4ca3SEd Maste m_option_definition.validator = nullptr;
26f21a844fSEd Maste m_option_definition.option_has_arg = OptionParser::eRequiredArgument;
2794994d37SDimitry Andric m_option_definition.enum_values = {};
28f034231aSEd Maste m_option_definition.completion_type = completion_type;
29f034231aSEd Maste m_option_definition.argument_type = argument_type;
30f034231aSEd Maste m_option_definition.usage_text = usage_text;
31f034231aSEd Maste }
32f034231aSEd Maste
SetOptionValue(uint32_t option_idx,llvm::StringRef option_arg,ExecutionContext * execution_context)33b76161e4SDimitry Andric Status OptionGroupFile::SetOptionValue(uint32_t option_idx,
3414f1b3e8SDimitry Andric llvm::StringRef option_arg,
3514f1b3e8SDimitry Andric ExecutionContext *execution_context) {
36b76161e4SDimitry Andric Status error(m_file.SetValueFromString(option_arg));
37f034231aSEd Maste return error;
38f034231aSEd Maste }
39f034231aSEd Maste
OptionParsingStarting(ExecutionContext * execution_context)4014f1b3e8SDimitry Andric void OptionGroupFile::OptionParsingStarting(
4114f1b3e8SDimitry Andric ExecutionContext *execution_context) {
42f034231aSEd Maste m_file.Clear();
43f034231aSEd Maste }
44f034231aSEd Maste
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)4514f1b3e8SDimitry Andric OptionGroupFileList::OptionGroupFileList(
4614f1b3e8SDimitry Andric uint32_t usage_mask, bool required, const char *long_option,
4714f1b3e8SDimitry Andric int short_option, uint32_t completion_type,
4814f1b3e8SDimitry Andric lldb::CommandArgumentType argument_type, const char *usage_text)
4914f1b3e8SDimitry Andric : m_file_list() {
50f034231aSEd Maste m_option_definition.usage_mask = usage_mask;
51f034231aSEd Maste m_option_definition.required = required;
52f034231aSEd Maste m_option_definition.long_option = long_option;
53f034231aSEd Maste m_option_definition.short_option = short_option;
540cac4ca3SEd Maste m_option_definition.validator = nullptr;
55f21a844fSEd Maste m_option_definition.option_has_arg = OptionParser::eRequiredArgument;
5694994d37SDimitry Andric m_option_definition.enum_values = {};
57f034231aSEd Maste m_option_definition.completion_type = completion_type;
58f034231aSEd Maste m_option_definition.argument_type = argument_type;
59f034231aSEd Maste m_option_definition.usage_text = usage_text;
60f034231aSEd Maste }
61f034231aSEd Maste
62344a3780SDimitry Andric OptionGroupFileList::~OptionGroupFileList() = default;
63f034231aSEd Maste
64b76161e4SDimitry Andric Status
SetOptionValue(uint32_t option_idx,llvm::StringRef option_value,ExecutionContext * execution_context)65b76161e4SDimitry Andric OptionGroupFileList::SetOptionValue(uint32_t option_idx,
6614f1b3e8SDimitry Andric llvm::StringRef option_value,
6714f1b3e8SDimitry Andric ExecutionContext *execution_context) {
68b76161e4SDimitry Andric Status error(m_file_list.SetValueFromString(option_value));
69f034231aSEd Maste return error;
70f034231aSEd Maste }
71f034231aSEd Maste
OptionParsingStarting(ExecutionContext * execution_context)7214f1b3e8SDimitry Andric void OptionGroupFileList::OptionParsingStarting(
7314f1b3e8SDimitry Andric ExecutionContext *execution_context) {
74f034231aSEd Maste m_file_list.Clear();
75f034231aSEd Maste }
76