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  bool WantsRawCommandString() override { return false; }
55 
56  void HandleCompletion(CompletionRequest &request) override;
57 
58  llvm::Optional<std::string> GetRepeatCommand(Args &current_command_args,
59  uint32_t index) override;
60 
61  bool Execute(const char *args_string, CommandReturnObject &result) override;
62 
63  bool IsRemovable() const override { return m_can_be_removed; }
64 
65  void SetRemovable(bool removable) { m_can_be_removed = removable; }
66 
67 protected:
69  return m_subcommand_dict;
70  }
71 
74 };
75 
77 public:
78  CommandObjectProxy(CommandInterpreter &interpreter, const char *name,
79  const char *help = nullptr, const char *syntax = nullptr,
80  uint32_t flags = 0);
81 
82  ~CommandObjectProxy() override;
83 
84  // Subclasses must provide a command object that will be transparently used
85  // for this object.
86  virtual CommandObject *GetProxyCommandObject() = 0;
87 
88  llvm::StringRef GetSyntax() override;
89 
90  llvm::StringRef GetHelp() override;
91 
92  llvm::StringRef GetHelpLong() override;
93 
94  bool IsRemovable() const override;
95 
96  bool IsMultiwordObject() override;
97 
99 
100  void GenerateHelpText(Stream &result) override;
101 
102  lldb::CommandObjectSP GetSubcommandSP(llvm::StringRef sub_cmd,
103  StringList *matches = nullptr) override;
104 
105  CommandObject *GetSubcommandObject(llvm::StringRef sub_cmd,
106  StringList *matches = nullptr) override;
107 
108  bool LoadSubCommand(llvm::StringRef cmd_name,
109  const lldb::CommandObjectSP &command_obj) override;
110 
111  bool WantsRawCommandString() override;
112 
113  bool WantsCompletion() override;
114 
115  Options *GetOptions() override;
116 
117  void HandleCompletion(CompletionRequest &request) override;
118 
119  void
121  OptionElementVector &opt_element_vector) override;
122 
123  llvm::Optional<std::string> GetRepeatCommand(Args &current_command_args,
124  uint32_t index) override;
125 
126  /// \return
127  /// An error message to be displayed when the command is executed (i.e.
128  /// Execute is called) and \a GetProxyCommandObject returned null.
129  virtual llvm::StringRef GetUnsupportedError();
130 
131  bool Execute(const char *args_string, CommandReturnObject &result) override;
132 
133 protected:
134  // These two want to iterate over the subcommand dictionary.
135  friend class CommandInterpreter;
136  friend class CommandObjectSyntax;
137 };
138 
139 } // namespace lldb_private
140 
141 #endif // LLDB_INTERPRETER_COMMANDOBJECTMULTIWORD_H
lldb_private::CommandObjectProxy::IsMultiwordObject
bool IsMultiwordObject() override
Definition: CommandObjectMultiword.cpp:349
lldb_private::CommandObjectMultiword::GetSubcommandDictionary
CommandObject::CommandMap & GetSubcommandDictionary()
Definition: CommandObjectMultiword.h:68
lldb_private::CommandObjectMultiword::m_subcommand_dict
CommandObject::CommandMap m_subcommand_dict
Definition: CommandObjectMultiword.h:72
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:416
lldb_private::CommandObjectProxy::GetOptions
Options * GetOptions() override
Definition: CommandObjectMultiword.cpp:313
lldb_private::CommandObjectMultiword::GetAsMultiwordCommand
CommandObjectMultiword * GetAsMultiwordCommand() override
Definition: CommandObjectMultiword.h:33
lldb_private::CommandObjectProxy::WantsRawCommandString
bool WantsRawCommandString() override
Definition: CommandObjectMultiword.cpp:396
lldb_private::CommandObjectProxy::GetHelpLong
llvm::StringRef GetHelpLong() override
Definition: CommandObjectMultiword.cpp:334
lldb_private::CommandObjectProxy::CommandObjectSyntax
friend class CommandObjectSyntax
Definition: CommandObjectMultiword.h:136
lldb_private::CommandObjectMultiword::WantsRawCommandString
bool WantsRawCommandString() override
Definition: CommandObjectMultiword.h:54
lldb_private::CommandObjectProxy::~CommandObjectProxy
~CommandObjectProxy() override
lldb_private::CommandObjectProxy::GetHelp
llvm::StringRef GetHelp() override
Definition: CommandObjectMultiword.cpp:320
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:306
CompletionRequest.h
lldb_private::CommandObjectMultiword::GetRepeatCommand
llvm::Optional< std::string > GetRepeatCommand(Args &current_command_args, uint32_t index) override
Get the command that appropriate for a "repeat" of the current command.
Definition: CommandObjectMultiword.cpp:294
lldb_private::CommandObjectMultiword::SetRemovable
void SetRemovable(bool removable)
Definition: CommandObjectMultiword.h:65
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:327
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::GetUnsupportedError
virtual llvm::StringRef GetUnsupportedError()
Definition: CommandObjectMultiword.cpp:432
lldb_private::CommandObjectProxy::Execute
bool Execute(const char *args_string, CommandReturnObject &result) override
Definition: CommandObjectMultiword.cpp:436
lldb_private::CommandObjectMultiword::IsMultiwordObject
bool IsMultiwordObject() override
Definition: CommandObjectMultiword.h:31
lldb_private::CommandObjectProxy::GetRepeatCommand
llvm::Optional< std::string > GetRepeatCommand(Args &current_command_args, uint32_t index) override
Get the command that appropriate for a "repeat" of the current command.
Definition: CommandObjectMultiword.cpp:424
lldb_private::CommandObjectProxy::LoadSubCommand
bool LoadSubCommand(llvm::StringRef cmd_name, const lldb::CommandObjectSP &command_obj) override
Definition: CommandObjectMultiword.cpp:388
lldb_private::CommandObjectProxy::GetSubcommandSP
lldb::CommandObjectSP GetSubcommandSP(llvm::StringRef sub_cmd, StringList *matches=nullptr) override
Definition: CommandObjectMultiword.cpp:372
lldb_private::StringList
Definition: StringList.h:26
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:109
lldb_private::CommandObjectMultiword::m_can_be_removed
bool m_can_be_removed
Definition: CommandObjectMultiword.h:73
lldb_private::CommandInterpreter
Definition: CommandInterpreter.h:214
lldb_private::OptionElementVector
std::vector< OptionArgElement > OptionElementVector
Definition: Options.h:42
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:403
lldb_private::CommandObject
Definition: CommandObject.h:68
lldb_private::CommandObjectProxy
Definition: CommandObjectMultiword.h:76
lldb_private::CommandObjectMultiword::GetSubcommandSPExact
lldb::CommandObjectSP GetSubcommandSPExact(llvm::StringRef sub_cmd) override
Definition: CommandObjectMultiword.cpp:30
lldb_private::CommandReturnObject
Definition: CommandReturnObject.h:26
uint32_t
CommandObject.h
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:341
lldb_private::CommandObjectMultiword::~CommandObjectMultiword
~CommandObjectMultiword() override
lldb_private::CommandObjectMultiword::IsRemovable
bool IsRemovable() const override
Definition: CommandObjectMultiword.h:63
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:380
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:34
lldb_private::CommandObjectMultiword::CommandObjectSyntax
friend class CommandObjectSyntax
Definition: CommandObjectMultiword.h:22
lldb_private::CommandObjectProxy::GetAsMultiwordCommand
CommandObjectMultiword * GetAsMultiwordCommand() override
Definition: CommandObjectMultiword.cpp:356
lldb_private::CommandObjectProxy::HandleCompletion
void HandleCompletion(CompletionRequest &request) override
This default version handles calling option argument completions and then calls HandleArgumentComplet...
Definition: CommandObjectMultiword.cpp:410
lldb_private::CommandObjectProxy::GenerateHelpText
void GenerateHelpText(Stream &result) override
Definition: CommandObjectMultiword.cpp:363
lldb_private::CompletionRequest
Definition: CompletionRequest.h:100
lldb_private::CommandObjectMultiword::Execute
bool Execute(const char *args_string, CommandReturnObject &result) override
Definition: CommandObjectMultiword.cpp:161