Greg Clayton | effe5c9 | 2011-05-03 22:09:39 +0000 | [diff] [blame] | 1 | //===-- OptionGroupFile.cpp -------------------------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
Johnny Chen | 4bee32e | 2011-05-13 20:21:08 +0000 | [diff] [blame] | 10 | #include "lldb/Interpreter/OptionGroupFile.h" |
Greg Clayton | effe5c9 | 2011-05-03 22:09:39 +0000 | [diff] [blame] | 11 | |
| 12 | // C Includes |
| 13 | // C++ Includes |
| 14 | // Other libraries and framework includes |
| 15 | // Project includes |
Zachary Turner | 3eb2b44 | 2017-03-22 23:33:16 +0000 | [diff] [blame] | 16 | #include "lldb/Host/OptionParser.h" |
Greg Clayton | effe5c9 | 2011-05-03 22:09:39 +0000 | [diff] [blame] | 17 | |
| 18 | using namespace lldb; |
| 19 | using namespace lldb_private; |
| 20 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 21 | OptionGroupFile::OptionGroupFile(uint32_t usage_mask, bool required, |
| 22 | const char *long_option, int short_option, |
| 23 | uint32_t completion_type, |
| 24 | lldb::CommandArgumentType argument_type, |
| 25 | const char *usage_text) |
| 26 | : m_file() { |
| 27 | m_option_definition.usage_mask = usage_mask; |
| 28 | m_option_definition.required = required; |
| 29 | m_option_definition.long_option = long_option; |
| 30 | m_option_definition.short_option = short_option; |
| 31 | m_option_definition.validator = nullptr; |
| 32 | m_option_definition.option_has_arg = OptionParser::eRequiredArgument; |
| 33 | m_option_definition.enum_values = nullptr; |
| 34 | m_option_definition.completion_type = completion_type; |
| 35 | m_option_definition.argument_type = argument_type; |
| 36 | m_option_definition.usage_text = usage_text; |
Greg Clayton | effe5c9 | 2011-05-03 22:09:39 +0000 | [diff] [blame] | 37 | } |
| 38 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 39 | OptionGroupFile::~OptionGroupFile() {} |
| 40 | |
| 41 | Error OptionGroupFile::SetOptionValue(uint32_t option_idx, |
Zachary Turner | 8cef4b0 | 2016-09-23 17:48:13 +0000 | [diff] [blame] | 42 | llvm::StringRef option_arg, |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 43 | ExecutionContext *execution_context) { |
| 44 | Error error(m_file.SetValueFromString(option_arg)); |
| 45 | return error; |
Greg Clayton | effe5c9 | 2011-05-03 22:09:39 +0000 | [diff] [blame] | 46 | } |
| 47 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 48 | void OptionGroupFile::OptionParsingStarting( |
| 49 | ExecutionContext *execution_context) { |
| 50 | m_file.Clear(); |
Greg Clayton | effe5c9 | 2011-05-03 22:09:39 +0000 | [diff] [blame] | 51 | } |
| 52 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 53 | OptionGroupFileList::OptionGroupFileList( |
| 54 | uint32_t usage_mask, bool required, const char *long_option, |
| 55 | int short_option, uint32_t completion_type, |
| 56 | lldb::CommandArgumentType argument_type, const char *usage_text) |
| 57 | : m_file_list() { |
| 58 | m_option_definition.usage_mask = usage_mask; |
| 59 | m_option_definition.required = required; |
| 60 | m_option_definition.long_option = long_option; |
| 61 | m_option_definition.short_option = short_option; |
| 62 | m_option_definition.validator = nullptr; |
| 63 | m_option_definition.option_has_arg = OptionParser::eRequiredArgument; |
| 64 | m_option_definition.enum_values = nullptr; |
| 65 | m_option_definition.completion_type = completion_type; |
| 66 | m_option_definition.argument_type = argument_type; |
| 67 | m_option_definition.usage_text = usage_text; |
Greg Clayton | effe5c9 | 2011-05-03 22:09:39 +0000 | [diff] [blame] | 68 | } |
Greg Clayton | 644247c | 2011-07-07 01:59:51 +0000 | [diff] [blame] | 69 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 70 | OptionGroupFileList::~OptionGroupFileList() {} |
Greg Clayton | 644247c | 2011-07-07 01:59:51 +0000 | [diff] [blame] | 71 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 72 | Error OptionGroupFileList::SetOptionValue(uint32_t option_idx, |
Zachary Turner | 8cef4b0 | 2016-09-23 17:48:13 +0000 | [diff] [blame] | 73 | llvm::StringRef option_value, |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 74 | ExecutionContext *execution_context) { |
Zachary Turner | 8cef4b0 | 2016-09-23 17:48:13 +0000 | [diff] [blame] | 75 | Error error(m_file_list.SetValueFromString(option_value)); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 76 | return error; |
Greg Clayton | 644247c | 2011-07-07 01:59:51 +0000 | [diff] [blame] | 77 | } |
| 78 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 79 | void OptionGroupFileList::OptionParsingStarting( |
| 80 | ExecutionContext *execution_context) { |
| 81 | m_file_list.Clear(); |
Greg Clayton | 644247c | 2011-07-07 01:59:51 +0000 | [diff] [blame] | 82 | } |