Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1 | //===-- CommandObjectHelp.h -------------------------------------*- 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 | |
| 10 | #ifndef liblldb_CommandObjectHelp_h_ |
| 11 | #define liblldb_CommandObjectHelp_h_ |
| 12 | |
| 13 | // C Includes |
| 14 | // C++ Includes |
| 15 | // Other libraries and framework includes |
| 16 | // Project includes |
| 17 | #include "lldb/Interpreter/CommandObject.h" |
Enrico Granata | 1ac6d1f | 2011-09-09 17:49:36 +0000 | [diff] [blame] | 18 | #include "lldb/Interpreter/Options.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 19 | |
| 20 | namespace lldb_private { |
| 21 | |
| 22 | //------------------------------------------------------------------------- |
| 23 | // CommandObjectHelp |
| 24 | //------------------------------------------------------------------------- |
| 25 | |
Jim Ingham | da26bd2 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 26 | class CommandObjectHelp : public CommandObjectParsed |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 27 | { |
| 28 | public: |
| 29 | |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 30 | CommandObjectHelp (CommandInterpreter &interpreter); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 31 | |
| 32 | virtual |
| 33 | ~CommandObjectHelp (); |
| 34 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 35 | virtual int |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 36 | HandleCompletion (Args &input, |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 37 | int &cursor_index, |
| 38 | int &cursor_char_position, |
| 39 | int match_start_point, |
| 40 | int max_return_elements, |
Jim Ingham | 802f8b0 | 2010-06-30 05:02:46 +0000 | [diff] [blame] | 41 | bool &word_complete, |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 42 | StringList &matches); |
Enrico Granata | 1ac6d1f | 2011-09-09 17:49:36 +0000 | [diff] [blame] | 43 | |
| 44 | class CommandOptions : public Options |
| 45 | { |
| 46 | public: |
| 47 | |
| 48 | CommandOptions (CommandInterpreter &interpreter) : |
| 49 | Options (interpreter) |
| 50 | { |
| 51 | } |
| 52 | |
| 53 | virtual |
| 54 | ~CommandOptions (){} |
| 55 | |
| 56 | virtual Error |
| 57 | SetOptionValue (uint32_t option_idx, const char *option_arg) |
| 58 | { |
| 59 | Error error; |
Greg Clayton | 6475c42 | 2012-12-04 00:32:51 +0000 | [diff] [blame] | 60 | const int short_option = m_getopt_table[option_idx].val; |
Enrico Granata | 1ac6d1f | 2011-09-09 17:49:36 +0000 | [diff] [blame] | 61 | |
| 62 | switch (short_option) |
| 63 | { |
| 64 | case 'a': |
| 65 | m_show_aliases = true; |
| 66 | break; |
| 67 | case 'u': |
| 68 | m_show_user_defined = false; |
| 69 | break; |
| 70 | default: |
Greg Clayton | 9c23673 | 2011-10-26 00:56:27 +0000 | [diff] [blame] | 71 | error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option); |
Enrico Granata | 1ac6d1f | 2011-09-09 17:49:36 +0000 | [diff] [blame] | 72 | break; |
| 73 | } |
| 74 | |
| 75 | return error; |
| 76 | } |
| 77 | |
| 78 | void |
| 79 | OptionParsingStarting () |
| 80 | { |
| 81 | m_show_aliases = false; |
| 82 | m_show_user_defined = true; |
| 83 | } |
| 84 | |
| 85 | const OptionDefinition* |
| 86 | GetDefinitions () |
| 87 | { |
| 88 | return g_option_table; |
| 89 | } |
| 90 | |
| 91 | // Options table: Required for subclasses of Options. |
| 92 | |
| 93 | static OptionDefinition g_option_table[]; |
| 94 | |
| 95 | // Instance variables to hold the values for command options. |
| 96 | |
| 97 | bool m_show_aliases; |
| 98 | bool m_show_user_defined; |
| 99 | }; |
| 100 | |
Enrico Granata | 1ac6d1f | 2011-09-09 17:49:36 +0000 | [diff] [blame] | 101 | virtual Options * |
| 102 | GetOptions () |
| 103 | { |
| 104 | return &m_options; |
| 105 | } |
Jim Ingham | da26bd2 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 106 | |
| 107 | protected: |
| 108 | virtual bool |
| 109 | DoExecute (Args& command, |
| 110 | CommandReturnObject &result); |
Enrico Granata | 035ef3d | 2013-06-12 01:50:57 +0000 | [diff] [blame] | 111 | |
Jim Ingham | da26bd2 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 112 | private: |
| 113 | CommandOptions m_options; |
| 114 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 115 | }; |
| 116 | |
| 117 | } // namespace lldb_private |
| 118 | |
| 119 | #endif // liblldb_CommandObjectHelp_h_ |