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"
18 #include "lldb/Interpreter/Options.h"
19 
20 namespace lldb_private {
21 
22 //-------------------------------------------------------------------------
23 // CommandObjectHelp
24 //-------------------------------------------------------------------------
25 
26 class CommandObjectHelp : public CommandObject
27 {
28 public:
29 
30     CommandObjectHelp (CommandInterpreter &interpreter);
31 
32     virtual
33     ~CommandObjectHelp ();
34 
35     virtual bool
36     Execute (Args& command,
37              CommandReturnObject &result);
38 
39     virtual int
40     HandleCompletion (Args &input,
41                       int &cursor_index,
42                       int &cursor_char_position,
43                       int match_start_point,
44                       int max_return_elements,
45                       bool &word_complete,
46                       StringList &matches);
47 
48     class CommandOptions : public Options
49     {
50     public:
51 
52         CommandOptions (CommandInterpreter &interpreter) :
53         Options (interpreter)
54         {
55         }
56 
57         virtual
58         ~CommandOptions (){}
59 
60         virtual Error
61         SetOptionValue (uint32_t option_idx, const char *option_arg)
62         {
63             Error error;
64             char short_option = (char) m_getopt_table[option_idx].val;
65 
66             switch (short_option)
67             {
68                 case 'a':
69                     m_show_aliases = true;
70                     break;
71                 case 'u':
72                     m_show_user_defined = false;
73                     break;
74                 default:
75                     error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option);
76                     break;
77             }
78 
79             return error;
80         }
81 
82         void
83         OptionParsingStarting ()
84         {
85             m_show_aliases = false;
86             m_show_user_defined = true;
87         }
88 
89         const OptionDefinition*
90         GetDefinitions ()
91         {
92             return g_option_table;
93         }
94 
95         // Options table: Required for subclasses of Options.
96 
97         static OptionDefinition g_option_table[];
98 
99         // Instance variables to hold the values for command options.
100 
101         bool m_show_aliases;
102         bool m_show_user_defined;
103     };
104 
105     CommandOptions m_options;
106 
107     virtual Options *
108     GetOptions ()
109     {
110         return &m_options;
111     }
112 
113 };
114 
115 } // namespace lldb_private
116 
117 #endif  // liblldb_CommandObjectHelp_h_
118