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 | |
| 20 | OptionGroupFile::OptionGroupFile (uint32_t usage_mask, |
| 21 | bool required, |
| 22 | const char *long_option, |
Greg Clayton | 3bcdfc0 | 2012-12-04 00:32:51 +0000 | [diff] [blame] | 23 | int short_option, |
Greg Clayton | effe5c9 | 2011-05-03 22:09:39 +0000 | [diff] [blame] | 24 | uint32_t completion_type, |
| 25 | lldb::CommandArgumentType argument_type, |
| 26 | const char *usage_text) : |
| 27 | m_file () |
| 28 | { |
| 29 | m_option_definition.usage_mask = usage_mask; |
| 30 | m_option_definition.required = required; |
| 31 | m_option_definition.long_option = long_option; |
| 32 | m_option_definition.short_option = short_option; |
Zachary Turner | df734cd | 2014-07-09 16:32:07 +0000 | [diff] [blame] | 33 | m_option_definition.validator = nullptr; |
Virgile Bello | e2607b5 | 2013-09-05 16:42:23 +0000 | [diff] [blame] | 34 | m_option_definition.option_has_arg = OptionParser::eRequiredArgument; |
Ed Maste | d78c957 | 2014-04-20 00:31:37 +0000 | [diff] [blame] | 35 | m_option_definition.enum_values = nullptr; |
Greg Clayton | effe5c9 | 2011-05-03 22:09:39 +0000 | [diff] [blame] | 36 | m_option_definition.completion_type = completion_type; |
| 37 | m_option_definition.argument_type = argument_type; |
| 38 | m_option_definition.usage_text = usage_text; |
| 39 | } |
| 40 | |
| 41 | OptionGroupFile::~OptionGroupFile () |
| 42 | { |
| 43 | } |
| 44 | |
| 45 | Error |
| 46 | OptionGroupFile::SetOptionValue (CommandInterpreter &interpreter, |
Greg Clayton | 1c5f186 | 2012-11-30 19:05:35 +0000 | [diff] [blame] | 47 | uint32_t option_idx, |
| 48 | const char *option_arg) |
Greg Clayton | effe5c9 | 2011-05-03 22:09:39 +0000 | [diff] [blame] | 49 | { |
Pavel Labath | c95f7e2 | 2015-02-20 11:14:59 +0000 | [diff] [blame] | 50 | Error error (m_file.SetValueFromString (option_arg)); |
Greg Clayton | effe5c9 | 2011-05-03 22:09:39 +0000 | [diff] [blame] | 51 | return error; |
| 52 | } |
| 53 | |
| 54 | void |
| 55 | OptionGroupFile::OptionParsingStarting (CommandInterpreter &interpreter) |
| 56 | { |
| 57 | m_file.Clear(); |
| 58 | } |
Greg Clayton | 644247c | 2011-07-07 01:59:51 +0000 | [diff] [blame] | 59 | |
| 60 | |
| 61 | OptionGroupFileList::OptionGroupFileList (uint32_t usage_mask, |
| 62 | bool required, |
| 63 | const char *long_option, |
Greg Clayton | 3bcdfc0 | 2012-12-04 00:32:51 +0000 | [diff] [blame] | 64 | int short_option, |
Greg Clayton | 644247c | 2011-07-07 01:59:51 +0000 | [diff] [blame] | 65 | uint32_t completion_type, |
| 66 | lldb::CommandArgumentType argument_type, |
| 67 | const char *usage_text) : |
| 68 | m_file_list () |
| 69 | { |
| 70 | m_option_definition.usage_mask = usage_mask; |
| 71 | m_option_definition.required = required; |
| 72 | m_option_definition.long_option = long_option; |
| 73 | m_option_definition.short_option = short_option; |
Zachary Turner | df734cd | 2014-07-09 16:32:07 +0000 | [diff] [blame] | 74 | m_option_definition.validator = nullptr; |
Virgile Bello | e2607b5 | 2013-09-05 16:42:23 +0000 | [diff] [blame] | 75 | m_option_definition.option_has_arg = OptionParser::eRequiredArgument; |
Ed Maste | d78c957 | 2014-04-20 00:31:37 +0000 | [diff] [blame] | 76 | m_option_definition.enum_values = nullptr; |
Greg Clayton | 644247c | 2011-07-07 01:59:51 +0000 | [diff] [blame] | 77 | m_option_definition.completion_type = completion_type; |
| 78 | m_option_definition.argument_type = argument_type; |
| 79 | m_option_definition.usage_text = usage_text; |
| 80 | } |
| 81 | |
| 82 | OptionGroupFileList::~OptionGroupFileList () |
| 83 | { |
| 84 | } |
| 85 | |
| 86 | Error |
| 87 | OptionGroupFileList::SetOptionValue (CommandInterpreter &interpreter, |
Greg Clayton | 3bcdfc0 | 2012-12-04 00:32:51 +0000 | [diff] [blame] | 88 | uint32_t option_idx, |
| 89 | const char *option_arg) |
Greg Clayton | 644247c | 2011-07-07 01:59:51 +0000 | [diff] [blame] | 90 | { |
Pavel Labath | c95f7e2 | 2015-02-20 11:14:59 +0000 | [diff] [blame] | 91 | Error error (m_file_list.SetValueFromString (option_arg)); |
Greg Clayton | 644247c | 2011-07-07 01:59:51 +0000 | [diff] [blame] | 92 | return error; |
| 93 | } |
| 94 | |
| 95 | void |
| 96 | OptionGroupFileList::OptionParsingStarting (CommandInterpreter &interpreter) |
| 97 | { |
| 98 | m_file_list.Clear(); |
| 99 | } |