]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/source/Commands/CommandObjectHelp.h
MFV r319738: 8155 simplify dmu_write_policy handling of pre-compressed buffers
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / 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 public:
28   CommandObjectHelp(CommandInterpreter &interpreter);
29
30   ~CommandObjectHelp() override;
31
32   int HandleCompletion(Args &input, int &cursor_index,
33                        int &cursor_char_position, int match_start_point,
34                        int max_return_elements, bool &word_complete,
35                        StringList &matches) override;
36
37   static void GenerateAdditionalHelpAvenuesMessage(
38       Stream *s, llvm::StringRef command, llvm::StringRef prefix,
39       llvm::StringRef subcommand, bool include_apropos = true,
40       bool include_type_lookup = true);
41
42   class CommandOptions : public Options {
43   public:
44     CommandOptions() : Options() {}
45
46     ~CommandOptions() override {}
47
48     Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
49                          ExecutionContext *execution_context) override {
50       Error error;
51       const int short_option = m_getopt_table[option_idx].val;
52
53       switch (short_option) {
54       case 'a':
55         m_show_aliases = false;
56         break;
57       case 'u':
58         m_show_user_defined = false;
59         break;
60       case 'h':
61         m_show_hidden = true;
62         break;
63       default:
64         error.SetErrorStringWithFormat("unrecognized option '%c'",
65                                        short_option);
66         break;
67       }
68
69       return error;
70     }
71
72     void OptionParsingStarting(ExecutionContext *execution_context) override {
73       m_show_aliases = true;
74       m_show_user_defined = true;
75       m_show_hidden = false;
76     }
77
78     llvm::ArrayRef<OptionDefinition> GetDefinitions() override;
79
80     // Instance variables to hold the values for command options.
81
82     bool m_show_aliases;
83     bool m_show_user_defined;
84     bool m_show_hidden;
85   };
86
87   Options *GetOptions() override { return &m_options; }
88
89 protected:
90   bool DoExecute(Args &command, CommandReturnObject &result) override;
91
92 private:
93   CommandOptions m_options;
94 };
95
96 } // namespace lldb_private
97
98 #endif // liblldb_CommandObjectHelp_h_