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#include <optional>
15
16namespace lldb_private {
17
18// CommandObjectMultiword
19
21 // These two want to iterate over the subcommand dictionary.
22 friend class CommandInterpreter;
23 friend class CommandObjectSyntax;
24
25public:
26 CommandObjectMultiword(CommandInterpreter &interpreter, const char *name,
27 const char *help = nullptr,
28 const char *syntax = nullptr, uint32_t flags = 0);
29
31
32 bool IsMultiwordObject() override { return true; }
33
34 CommandObjectMultiword *GetAsMultiwordCommand() override { return this; }
35
36 bool LoadSubCommand(llvm::StringRef cmd_name,
37 const lldb::CommandObjectSP &command_obj) override;
38
39 llvm::Error LoadUserSubcommand(llvm::StringRef cmd_name,
40 const lldb::CommandObjectSP &command_obj,
41 bool can_replace) override;
42
43 llvm::Error RemoveUserSubcommand(llvm::StringRef cmd_name, bool multiword_okay);
44
45 void GenerateHelpText(Stream &output_stream) override;
46
47 lldb::CommandObjectSP GetSubcommandSP(llvm::StringRef sub_cmd,
48 StringList *matches = nullptr) override;
49
50 lldb::CommandObjectSP GetSubcommandSPExact(llvm::StringRef sub_cmd) override;
51
52 CommandObject *GetSubcommandObject(llvm::StringRef sub_cmd,
53 StringList *matches = nullptr) override;
54
55 bool WantsRawCommandString() override { return false; }
56
57 void HandleCompletion(CompletionRequest &request) override;
58
59 std::optional<std::string> GetRepeatCommand(Args &current_command_args,
60 uint32_t index) override;
61
62 void Execute(const char *args_string, CommandReturnObject &result) override;
63
64 bool IsRemovable() const override { return m_can_be_removed; }
65
66 void SetRemovable(bool removable) { m_can_be_removed = removable; }
67
68protected:
70 return m_subcommand_dict;
71 }
72
73 std::string GetSubcommandsHintText();
74
77};
78
80public:
81 CommandObjectProxy(CommandInterpreter &interpreter, const char *name,
82 const char *help = nullptr, const char *syntax = nullptr,
83 uint32_t flags = 0);
84
86
87 // Subclasses must provide a command object that will be transparently used
88 // for this object.
90
91 llvm::StringRef GetSyntax() override;
92
93 llvm::StringRef GetHelp() override;
94
95 llvm::StringRef GetHelpLong() override;
96
97 bool IsRemovable() const override;
98
99 bool IsMultiwordObject() override;
100
102
103 void GenerateHelpText(Stream &result) override;
104
105 lldb::CommandObjectSP GetSubcommandSP(llvm::StringRef sub_cmd,
106 StringList *matches = nullptr) override;
107
108 CommandObject *GetSubcommandObject(llvm::StringRef sub_cmd,
109 StringList *matches = nullptr) override;
110
111 bool LoadSubCommand(llvm::StringRef cmd_name,
112 const lldb::CommandObjectSP &command_obj) override;
113
114 bool WantsRawCommandString() override;
115
116 bool WantsCompletion() override;
117
118 Options *GetOptions() override;
119
120 void HandleCompletion(CompletionRequest &request) override;
121
122 void
124 OptionElementVector &opt_element_vector) override;
125
126 std::optional<std::string> GetRepeatCommand(Args &current_command_args,
127 uint32_t index) override;
128
129 /// \return
130 /// An error message to be displayed when the command is executed (i.e.
131 /// Execute is called) and \a GetProxyCommandObject returned null.
132 virtual llvm::StringRef GetUnsupportedError();
133
134 void Execute(const char *args_string, CommandReturnObject &result) override;
135
136protected:
137 // These two want to iterate over the subcommand dictionary.
138 friend class CommandInterpreter;
140};
141
142} // namespace lldb_private
143
144#endif // LLDB_INTERPRETER_COMMANDOBJECTMULTIWORD_H
A command line argument class.
Definition: Args.h:33
void Execute(const char *args_string, CommandReturnObject &result) override
llvm::Error LoadUserSubcommand(llvm::StringRef cmd_name, const lldb::CommandObjectSP &command_obj, bool can_replace) override
void GenerateHelpText(Stream &output_stream) override
CommandObject::CommandMap m_subcommand_dict
CommandObject::CommandMap & GetSubcommandDictionary()
void HandleCompletion(CompletionRequest &request) override
This default version handles calling option argument completions and then calls HandleArgumentComplet...
std::optional< std::string > GetRepeatCommand(Args &current_command_args, uint32_t index) override
Get the command that appropriate for a "repeat" of the current command.
bool LoadSubCommand(llvm::StringRef cmd_name, const lldb::CommandObjectSP &command_obj) override
CommandObject * GetSubcommandObject(llvm::StringRef sub_cmd, StringList *matches=nullptr) override
llvm::Error RemoveUserSubcommand(llvm::StringRef cmd_name, bool multiword_okay)
lldb::CommandObjectSP GetSubcommandSPExact(llvm::StringRef sub_cmd) override
CommandObjectMultiword * GetAsMultiwordCommand() override
lldb::CommandObjectSP GetSubcommandSP(llvm::StringRef sub_cmd, StringList *matches=nullptr) override
void GenerateHelpText(Stream &result) override
virtual CommandObject * GetProxyCommandObject()=0
llvm::StringRef GetHelpLong() override
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The default version handles argument definitions that have only one argument type,...
lldb::CommandObjectSP GetSubcommandSP(llvm::StringRef sub_cmd, StringList *matches=nullptr) override
bool LoadSubCommand(llvm::StringRef cmd_name, const lldb::CommandObjectSP &command_obj) override
CommandObjectMultiword * GetAsMultiwordCommand() override
CommandObject * GetSubcommandObject(llvm::StringRef sub_cmd, StringList *matches=nullptr) override
void Execute(const char *args_string, CommandReturnObject &result) override
virtual llvm::StringRef GetUnsupportedError()
void HandleCompletion(CompletionRequest &request) override
This default version handles calling option argument completions and then calls HandleArgumentComplet...
std::optional< std::string > GetRepeatCommand(Args &current_command_args, uint32_t index) override
Get the command that appropriate for a "repeat" of the current command.
std::map< std::string, lldb::CommandObjectSP, std::less<> > CommandMap
"lldb/Utility/ArgCompletionRequest.h"
A command line option parsing protocol class.
Definition: Options.h:58
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
A class that represents a running process on the host machine.
std::vector< OptionArgElement > OptionElementVector
Definition: Options.h:43
std::shared_ptr< lldb_private::CommandObject > CommandObjectSP
Definition: lldb-forward.h:333