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 |
| 16 | |
| 17 | using namespace lldb; |
| 18 | using namespace lldb_private; |
| 19 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 20 | OptionGroupFile::OptionGroupFile(uint32_t usage_mask, bool required, |
| 21 | const char *long_option, int short_option, |
| 22 | uint32_t completion_type, |
| 23 | lldb::CommandArgumentType argument_type, |
| 24 | const char *usage_text) |
| 25 | : m_file() { |
| 26 | m_option_definition.usage_mask = usage_mask; |
| 27 | m_option_definition.required = required; |
| 28 | m_option_definition.long_option = long_option; |
| 29 | m_option_definition.short_option = short_option; |
| 30 | m_option_definition.validator = nullptr; |
| 31 | m_option_definition.option_has_arg = OptionParser::eRequiredArgument; |
| 32 | m_option_definition.enum_values = nullptr; |
| 33 | m_option_definition.completion_type = completion_type; |
| 34 | m_option_definition.argument_type = argument_type; |
| 35 | m_option_definition.usage_text = usage_text; |
Greg Clayton | effe5c9 | 2011-05-03 22:09:39 +0000 | [diff] [blame] | 36 | } |
| 37 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 38 | OptionGroupFile::~OptionGroupFile() {} |
| 39 | |
| 40 | Error OptionGroupFile::SetOptionValue(uint32_t option_idx, |
Zachary Turner | 8cef4b0 | 2016-09-23 17:48:13 +0000 | [diff] [blame^] | 41 | llvm::StringRef option_arg, |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 42 | ExecutionContext *execution_context) { |
| 43 | Error error(m_file.SetValueFromString(option_arg)); |
| 44 | return error; |
Greg Clayton | effe5c9 | 2011-05-03 22:09:39 +0000 | [diff] [blame] | 45 | } |
| 46 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 47 | void OptionGroupFile::OptionParsingStarting( |
| 48 | ExecutionContext *execution_context) { |
| 49 | m_file.Clear(); |
Greg Clayton | effe5c9 | 2011-05-03 22:09:39 +0000 | [diff] [blame] | 50 | } |
| 51 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 52 | OptionGroupFileList::OptionGroupFileList( |
| 53 | uint32_t usage_mask, bool required, const char *long_option, |
| 54 | int short_option, uint32_t completion_type, |
| 55 | lldb::CommandArgumentType argument_type, const char *usage_text) |
| 56 | : m_file_list() { |
| 57 | m_option_definition.usage_mask = usage_mask; |
| 58 | m_option_definition.required = required; |
| 59 | m_option_definition.long_option = long_option; |
| 60 | m_option_definition.short_option = short_option; |
| 61 | m_option_definition.validator = nullptr; |
| 62 | m_option_definition.option_has_arg = OptionParser::eRequiredArgument; |
| 63 | m_option_definition.enum_values = nullptr; |
| 64 | m_option_definition.completion_type = completion_type; |
| 65 | m_option_definition.argument_type = argument_type; |
| 66 | m_option_definition.usage_text = usage_text; |
Greg Clayton | effe5c9 | 2011-05-03 22:09:39 +0000 | [diff] [blame] | 67 | } |
Greg Clayton | 644247c | 2011-07-07 01:59:51 +0000 | [diff] [blame] | 68 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 69 | OptionGroupFileList::~OptionGroupFileList() {} |
Greg Clayton | 644247c | 2011-07-07 01:59:51 +0000 | [diff] [blame] | 70 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 71 | Error OptionGroupFileList::SetOptionValue(uint32_t option_idx, |
Zachary Turner | 8cef4b0 | 2016-09-23 17:48:13 +0000 | [diff] [blame^] | 72 | llvm::StringRef option_value, |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 73 | ExecutionContext *execution_context) { |
Zachary Turner | 8cef4b0 | 2016-09-23 17:48:13 +0000 | [diff] [blame^] | 74 | Error error(m_file_list.SetValueFromString(option_value)); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 75 | return error; |
Greg Clayton | 644247c | 2011-07-07 01:59:51 +0000 | [diff] [blame] | 76 | } |
| 77 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 78 | void OptionGroupFileList::OptionParsingStarting( |
| 79 | ExecutionContext *execution_context) { |
| 80 | m_file_list.Clear(); |
Greg Clayton | 644247c | 2011-07-07 01:59:51 +0000 | [diff] [blame] | 81 | } |