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 LLDB_INTERPRETER_COMMANDOBJECTMULTIWORD_H
10 #define LLDB_INTERPRETER_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  llvm::Error LoadUserSubcommand(llvm::StringRef cmd_name,
39  const lldb::CommandObjectSP &command_obj,
40  bool can_replace) override;
41 
42  llvm::Error RemoveUserSubcommand(llvm::StringRef cmd_name, bool multiword_okay);
43 
44  void GenerateHelpText(Stream &output_stream) override;
45 
46  lldb::CommandObjectSP GetSubcommandSP(llvm::StringRef sub_cmd,
47  StringList *matches = nullptr) override;
48 
49  lldb::CommandObjectSP GetSubcommandSPExact(llvm::StringRef sub_cmd) override;
50 
51  CommandObject *GetSubcommandObject(llvm::StringRef sub_cmd,
52  StringList *matches = nullptr) override;
53 
54  void AproposAllSubCommands(llvm::StringRef prefix,
55  llvm::StringRef search_word,
56  StringList &commands_found,
57  StringList &commands_help) override;
58 
59  bool WantsRawCommandString() override { return false; }
60 
61  void HandleCompletion(CompletionRequest &request) override;
62 
63  const char *GetRepeatCommand(Args &current_command_args,
64  uint32_t index) override;
65 
66  bool Execute(const char *args_string, CommandReturnObject &result) override;
67 
68  bool IsRemovable() const override { return m_can_be_removed; }
69 
70  void SetRemovable(bool removable) { m_can_be_removed = removable; }
71 
72 protected:
74  return m_subcommand_dict;
75  }
76 
79 };
80 
82 public:
83  CommandObjectProxy(CommandInterpreter &interpreter, const char *name,
84  const char *help = nullptr, const char *syntax = nullptr,
85  uint32_t flags = 0);
86 
87  ~CommandObjectProxy() override;
88 
89  // Subclasses must provide a command object that will be transparently used
90  // for this object.
91  virtual CommandObject *GetProxyCommandObject() = 0;
92 
93  llvm::StringRef GetSyntax() override;
94 
95  llvm::StringRef GetHelp() override;
96 
97  llvm::StringRef GetHelpLong() override;
98 
99  bool IsRemovable() const override;
100 
101  bool IsMultiwordObject() override;
102 
104 
105  void GenerateHelpText(Stream &result) override;
106 
107  lldb::CommandObjectSP GetSubcommandSP(llvm::StringRef sub_cmd,
108  StringList *matches = nullptr) override;
109 
110  CommandObject *GetSubcommandObject(llvm::StringRef sub_cmd,
111  StringList *matches = nullptr) override;
112 
113  void AproposAllSubCommands(llvm::StringRef prefix,
114  llvm::StringRef search_word,
115  StringList &commands_found,
116  StringList &commands_help) override;
117 
118  bool LoadSubCommand(llvm::StringRef cmd_name,
119  const lldb::CommandObjectSP &command_obj) override;
120 
121  bool WantsRawCommandString() override;
122 
123  bool WantsCompletion() override;
124 
125  Options *GetOptions() override;
126 
127  void HandleCompletion(CompletionRequest &request) override;
128 
129  void
131  OptionElementVector &opt_element_vector) override;
132 
133  const char *GetRepeatCommand(Args &current_command_args,
134  uint32_t index) override;
135 
136  /// \return
137  /// An error message to be displayed when the command is executed (i.e.
138  /// Execute is called) and \a GetProxyCommandObject returned null.
139  virtual llvm::StringRef GetUnsupportedError();
140 
141  bool Execute(const char *args_string, CommandReturnObject &result) override;
142 
143 protected:
144  // These two want to iterate over the subcommand dictionary.
145  friend class CommandInterpreter;
146  friend class CommandObjectSyntax;
147 };
148 
149 } // namespace lldb_private
150 
151 #endif // LLDB_INTERPRETER_COMMANDOBJECTMULTIWORD_H
lldb_private::CommandObjectProxy::IsMultiwordObject
bool IsMultiwordObject() override
Definition: CommandObjectMultiword.cpp:373
lldb_private::CommandObjectMultiword::GetSubcommandDictionary
CommandObject::CommandMap & GetSubcommandDictionary()
Definition: CommandObjectMultiword.h:73
lldb_private::CommandObjectMultiword::m_subcommand_dict
CommandObject::CommandMap m_subcommand_dict
Definition: CommandObjectMultiword.h:77
lldb_private::CommandObjectProxy::HandleArgumentCompletion
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The input array contains a parsed version of the line.
Definition: CommandObjectMultiword.cpp:450
lldb_private::CommandObjectProxy::GetOptions
Options * GetOptions() override
Definition: CommandObjectMultiword.cpp:337
lldb_private::CommandObjectMultiword::GetAsMultiwordCommand
CommandObjectMultiword * GetAsMultiwordCommand() override
Definition: CommandObjectMultiword.h:33
lldb_private::CommandObjectProxy::WantsRawCommandString
bool WantsRawCommandString() override
Definition: CommandObjectMultiword.cpp:430
lldb_private::CommandObjectProxy::GetHelpLong
llvm::StringRef GetHelpLong() override
Definition: CommandObjectMultiword.cpp:358
lldb_private::CommandObjectProxy::CommandObjectSyntax
friend class CommandObjectSyntax
Definition: CommandObjectMultiword.h:146
lldb_private::CommandObjectMultiword::WantsRawCommandString
bool WantsRawCommandString() override
Definition: CommandObjectMultiword.h:59
lldb_private::CommandObjectProxy::~CommandObjectProxy
~CommandObjectProxy() override
lldb_private::CommandObjectProxy::GetHelp
llvm::StringRef GetHelp() override
Definition: CommandObjectMultiword.cpp:344
lldb_private::Stream
Definition: Stream.h:28
lldb_private::Args
Definition: Args.h:33
lldb_private::CommandObjectMultiword::GetSubcommandSP
lldb::CommandObjectSP GetSubcommandSP(llvm::StringRef sub_cmd, StringList *matches=nullptr) override
Definition: CommandObjectMultiword.cpp:41
lldb_private::CommandObjectProxy::CommandObjectProxy
CommandObjectProxy(CommandInterpreter &interpreter, const char *name, const char *help=nullptr, const char *syntax=nullptr, uint32_t flags=0)
Definition: CommandObjectMultiword.cpp:330
CompletionRequest.h
lldb_private::CommandObjectMultiword::SetRemovable
void SetRemovable(bool removable)
Definition: CommandObjectMultiword.h:70
lldb_private::CommandObjectMultiword
Definition: CommandObjectMultiword.h:19
lldb_private::Options
Definition: Options.h:57
lldb_private::CommandObjectProxy::GetSyntax
llvm::StringRef GetSyntax() override
Definition: CommandObjectMultiword.cpp:351
lldb_private::CommandObjectMultiword::LoadUserSubcommand
llvm::Error LoadUserSubcommand(llvm::StringRef cmd_name, const lldb::CommandObjectSP &command_obj, bool can_replace) override
Definition: CommandObjectMultiword.cpp:98
lldb_private::CommandObjectMultiword::CommandObjectMultiword
CommandObjectMultiword(CommandInterpreter &interpreter, const char *name, const char *help=nullptr, const char *syntax=nullptr, uint32_t flags=0)
Definition: CommandObjectMultiword.cpp:19
lldb_private::CommandObjectMultiword::LoadSubCommand
bool LoadSubCommand(llvm::StringRef cmd_name, const lldb::CommandObjectSP &command_obj) override
Definition: CommandObjectMultiword.cpp:80
lldb_private::CommandObjectProxy::AproposAllSubCommands
void AproposAllSubCommands(llvm::StringRef prefix, llvm::StringRef search_word, StringList &commands_found, StringList &commands_help) override
Definition: CommandObjectMultiword.cpp:412
lldb_private::CommandObjectProxy::GetUnsupportedError
virtual llvm::StringRef GetUnsupportedError()
Definition: CommandObjectMultiword.cpp:465
lldb_private::CommandObjectProxy::Execute
bool Execute(const char *args_string, CommandReturnObject &result) override
Definition: CommandObjectMultiword.cpp:469
lldb_private::CommandObjectMultiword::IsMultiwordObject
bool IsMultiwordObject() override
Definition: CommandObjectMultiword.h:31
lldb_private::CommandObjectProxy::LoadSubCommand
bool LoadSubCommand(llvm::StringRef cmd_name, const lldb::CommandObjectSP &command_obj) override
Definition: CommandObjectMultiword.cpp:422
lldb_private::CommandObjectProxy::GetSubcommandSP
lldb::CommandObjectSP GetSubcommandSP(llvm::StringRef sub_cmd, StringList *matches=nullptr) override
Definition: CommandObjectMultiword.cpp:396
lldb_private::StringList
Definition: StringList.h:25
lldb_private::CommandObjectMultiword::HandleCompletion
void HandleCompletion(CompletionRequest &request) override
This default version handles calling option argument completions and then calls HandleArgumentComplet...
Definition: CommandObjectMultiword.cpp:255
lldb_private::CommandObject::CommandMap
std::map< std::string, lldb::CommandObjectSP > CommandMap
Definition: CommandObject.h:110
lldb_private::CommandObjectMultiword::m_can_be_removed
bool m_can_be_removed
Definition: CommandObjectMultiword.h:78
lldb_private::CommandInterpreter
Definition: CommandInterpreter.h:214
lldb_private::OptionElementVector
std::vector< OptionArgElement > OptionElementVector
Definition: Options.h:42
lldb_private::CommandObjectProxy::GetRepeatCommand
const char * GetRepeatCommand(Args &current_command_args, uint32_t index) override
Get the command that appropriate for a "repeat" of the current command.
Definition: CommandObjectMultiword.cpp:457
lldb_private::CommandObjectProxy::GetProxyCommandObject
virtual CommandObject * GetProxyCommandObject()=0
lldb_private::CommandObjectMultiword::GenerateHelpText
void GenerateHelpText(Stream &output_stream) override
Definition: CommandObjectMultiword.cpp:224
lldb_private::CommandObjectProxy::WantsCompletion
bool WantsCompletion() override
Definition: CommandObjectMultiword.cpp:437
lldb_private::CommandObject
Definition: CommandObject.h:67
lldb_private::CommandObjectProxy
Definition: CommandObjectMultiword.h:81
lldb_private::CommandObjectMultiword::GetSubcommandSPExact
lldb::CommandObjectSP GetSubcommandSPExact(llvm::StringRef sub_cmd) override
Definition: CommandObjectMultiword.cpp:30
lldb_private::CommandReturnObject
Definition: CommandReturnObject.h:25
uint32_t
CommandObject.h
lldb_private::CommandObjectMultiword::GetRepeatCommand
const char * GetRepeatCommand(Args &current_command_args, uint32_t index) override
Get the command that appropriate for a "repeat" of the current command.
Definition: CommandObjectMultiword.cpp:293
lldb_private::CommandObjectMultiword::GetSubcommandObject
CommandObject * GetSubcommandObject(llvm::StringRef sub_cmd, StringList *matches=nullptr) override
Definition: CommandObjectMultiword.cpp:75
lldb_private::CommandObjectProxy::IsRemovable
bool IsRemovable() const override
Definition: CommandObjectMultiword.cpp:365
lldb_private::CommandObjectMultiword::~CommandObjectMultiword
~CommandObjectMultiword() override
lldb_private::CommandObjectMultiword::AproposAllSubCommands
void AproposAllSubCommands(llvm::StringRef prefix, llvm::StringRef search_word, StringList &commands_found, StringList &commands_help) override
Definition: CommandObjectMultiword.cpp:305
lldb_private::CommandObjectMultiword::IsRemovable
bool IsRemovable() const override
Definition: CommandObjectMultiword.h:68
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::CommandObjectProxy::GetSubcommandObject
CommandObject * GetSubcommandObject(llvm::StringRef sub_cmd, StringList *matches=nullptr) override
Definition: CommandObjectMultiword.cpp:404
lldb_private::CommandObjectMultiword::RemoveUserSubcommand
llvm::Error RemoveUserSubcommand(llvm::StringRef cmd_name, bool multiword_okay)
Definition: CommandObjectMultiword.cpp:132
Error
llvm::Error Error
Definition: UdtRecordCompleter.cpp:29
lldb_private::CommandObjectMultiword::CommandObjectSyntax
friend class CommandObjectSyntax
Definition: CommandObjectMultiword.h:22
lldb_private::CommandObjectProxy::GetAsMultiwordCommand
CommandObjectMultiword * GetAsMultiwordCommand() override
Definition: CommandObjectMultiword.cpp:380
lldb_private::CommandObjectProxy::HandleCompletion
void HandleCompletion(CompletionRequest &request) override
This default version handles calling option argument completions and then calls HandleArgumentComplet...
Definition: CommandObjectMultiword.cpp:444
lldb_private::CommandObjectProxy::GenerateHelpText
void GenerateHelpText(Stream &result) override
Definition: CommandObjectMultiword.cpp:387
lldb_private::CompletionRequest
Definition: CompletionRequest.h:100
lldb_private::CommandObjectMultiword::Execute
bool Execute(const char *args_string, CommandReturnObject &result) override
Definition: CommandObjectMultiword.cpp:161