LLDB  mainline
CommandObjectMultiword.h
Go to the documentation of this file.
1 //===-- CommandObjectMultiword.h --------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef liblldb_CommandObjectMultiword_h_
10 #define liblldb_CommandObjectMultiword_h_
11 
14 
15 namespace lldb_private {
16 
17 // CommandObjectMultiword
18 
20  // These two want to iterate over the subcommand dictionary.
21  friend class CommandInterpreter;
22  friend class CommandObjectSyntax;
23 
24 public:
25  CommandObjectMultiword(CommandInterpreter &interpreter, const char *name,
26  const char *help = nullptr,
27  const char *syntax = nullptr, uint32_t flags = 0);
28 
29  ~CommandObjectMultiword() override;
30 
31  bool IsMultiwordObject() override { return true; }
32 
33  CommandObjectMultiword *GetAsMultiwordCommand() override { return this; }
34 
35  bool LoadSubCommand(llvm::StringRef cmd_name,
36  const lldb::CommandObjectSP &command_obj) override;
37 
38  void GenerateHelpText(Stream &output_stream) override;
39 
40  lldb::CommandObjectSP GetSubcommandSP(llvm::StringRef sub_cmd,
41  StringList *matches = nullptr) override;
42 
43  CommandObject *GetSubcommandObject(llvm::StringRef sub_cmd,
44  StringList *matches = nullptr) override;
45 
46  void AproposAllSubCommands(llvm::StringRef prefix,
47  llvm::StringRef search_word,
48  StringList &commands_found,
49  StringList &commands_help) override;
50 
51  bool WantsRawCommandString() override { return false; }
52 
53  int HandleCompletion(CompletionRequest &request) override;
54 
55  const char *GetRepeatCommand(Args &current_command_args,
56  uint32_t index) override;
57 
58  bool Execute(const char *args_string, CommandReturnObject &result) override;
59 
60  bool IsRemovable() const override { return m_can_be_removed; }
61 
62  void SetRemovable(bool removable) { m_can_be_removed = removable; }
63 
64 protected:
66  return m_subcommand_dict;
67  }
68 
71 };
72 
74 public:
75  CommandObjectProxy(CommandInterpreter &interpreter, const char *name,
76  const char *help = nullptr, const char *syntax = nullptr,
77  uint32_t flags = 0);
78 
79  ~CommandObjectProxy() override;
80 
81  // Subclasses must provide a command object that will be transparently used
82  // for this object.
83  virtual CommandObject *GetProxyCommandObject() = 0;
84 
85  llvm::StringRef GetHelpLong() override;
86 
87  bool IsRemovable() const override;
88 
89  bool IsMultiwordObject() override;
90 
92 
93  void GenerateHelpText(Stream &result) override;
94 
95  lldb::CommandObjectSP GetSubcommandSP(llvm::StringRef sub_cmd,
96  StringList *matches = nullptr) override;
97 
98  CommandObject *GetSubcommandObject(llvm::StringRef sub_cmd,
99  StringList *matches = nullptr) override;
100 
101  void AproposAllSubCommands(llvm::StringRef prefix,
102  llvm::StringRef search_word,
103  StringList &commands_found,
104  StringList &commands_help) override;
105 
106  bool LoadSubCommand(llvm::StringRef cmd_name,
107  const lldb::CommandObjectSP &command_obj) override;
108 
109  bool WantsRawCommandString() override;
110 
111  bool WantsCompletion() override;
112 
113  Options *GetOptions() override;
114 
115  int HandleCompletion(CompletionRequest &request) override;
116 
118  CompletionRequest &request,
119  OptionElementVector &opt_element_vector) override;
120 
121  const char *GetRepeatCommand(Args &current_command_args,
122  uint32_t index) override;
123 
124  bool Execute(const char *args_string, CommandReturnObject &result) override;
125 
126 protected:
127  // These two want to iterate over the subcommand dictionary.
128  friend class CommandInterpreter;
129  friend class CommandObjectSyntax;
130 };
131 
132 } // namespace lldb_private
133 
134 #endif // liblldb_CommandObjectMultiword_h_
A command line argument class.
Definition: Args.h:32
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
virtual llvm::StringRef GetHelpLong()
bool LoadSubCommand(llvm::StringRef cmd_name, const lldb::CommandObjectSP &command_obj) override
virtual bool WantsCompletion()
CommandObjectMultiword * GetAsMultiwordCommand() override
const char * GetRepeatCommand(Args &current_command_args, uint32_t index) override
Get the command that appropriate for a "repeat" of the current command.
"lldb/Utility/ArgCompletionRequest.h"
std::vector< OptionArgElement > OptionElementVector
Definition: Options.h:41
int HandleCompletion(CompletionRequest &request) override
This default version handles calling option argument completions and then calls HandleArgumentComplet...
lldb::CommandObjectSP GetSubcommandSP(llvm::StringRef sub_cmd, StringList *matches=nullptr) override
void GenerateHelpText(Stream &output_stream) override
virtual Options * GetOptions()
CommandObject::CommandMap & GetSubcommandDictionary()
CommandObject::CommandMap m_subcommand_dict
A command line option parsing protocol class.
Definition: Options.h:62
std::map< std::string, lldb::CommandObjectSP > CommandMap
virtual int HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector)
The input array contains a parsed version of the line.
CommandObject * GetSubcommandObject(llvm::StringRef sub_cmd, StringList *matches=nullptr) override
CommandObjectMultiword(CommandInterpreter &interpreter, const char *name, const char *help=nullptr, const char *syntax=nullptr, uint32_t flags=0)
void AproposAllSubCommands(llvm::StringRef prefix, llvm::StringRef search_word, StringList &commands_found, StringList &commands_help) override
bool Execute(const char *args_string, CommandReturnObject &result) override