]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - source/Commands/CommandObjectHelp.h
Vendor import of lldb release_39 branch r276489:
[FreeBSD/FreeBSD.git] / source / Commands / CommandObjectHelp.h
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 CommandObjectParsed
27 {
28 public:
29
30     CommandObjectHelp (CommandInterpreter &interpreter);
31
32     ~CommandObjectHelp() override;
33
34     int
35     HandleCompletion(Args &input,
36                      int &cursor_index,
37                      int &cursor_char_position,
38                      int match_start_point,
39                      int max_return_elements,
40                      bool &word_complete,
41                      StringList &matches) override;
42     
43     static void
44     GenerateAdditionalHelpAvenuesMessage (Stream *s,
45                                           const char* command,
46                                           const char* prefix = nullptr,
47                                           const char* subcommand = nullptr,
48                                           bool include_apropos = true,
49                                           bool include_type_lookup = true);
50     
51     class CommandOptions : public Options
52     {
53     public:
54         
55         CommandOptions (CommandInterpreter &interpreter) :
56         Options (interpreter)
57         {
58         }
59         
60         ~CommandOptions() override {}
61         
62         Error
63         SetOptionValue(uint32_t option_idx, const char *option_arg) override
64         {
65             Error error;
66             const int short_option = m_getopt_table[option_idx].val;
67             
68             switch (short_option)
69             {
70                 case 'a':
71                     m_show_aliases = false;
72                     break;
73                 case 'u':
74                     m_show_user_defined = false;
75                     break;
76                 case 'h':
77                     m_show_hidden = true;
78                     break;
79                 default:
80                     error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
81                     break;
82             }
83             
84             return error;
85         }
86         
87         void
88         OptionParsingStarting() override
89         {
90             m_show_aliases = true;
91             m_show_user_defined = true;
92             m_show_hidden = false;
93         }
94         
95         const OptionDefinition*
96         GetDefinitions() override
97         {
98             return g_option_table;
99         }
100         
101         // Options table: Required for subclasses of Options.
102         
103         static OptionDefinition g_option_table[];
104         
105         // Instance variables to hold the values for command options.
106         
107         bool m_show_aliases;
108         bool m_show_user_defined;
109         bool m_show_hidden;
110     };
111     
112     Options *
113     GetOptions() override
114     {
115         return &m_options;
116     }
117     
118 protected:
119     bool
120     DoExecute(Args& command,
121               CommandReturnObject &result) override;
122     
123 private:
124     CommandOptions m_options;
125 };
126
127 } // namespace lldb_private
128
129 #endif // liblldb_CommandObjectHelp_h_