13#include "llvm/Support/Errc.h"
14#include "llvm/Support/Error.h"
22 llvm::StringRef syntax, uint32_t completion_type_mask,
bool is_removable)
24 m_completion_type_mask(completion_type_mask),
25 m_is_removable(is_removable) {}
31 llvm::StringRef input,
34 llvm::raw_string_ostream output(buffer);
36 llvm::SmallVector<llvm::StringRef, 4> parts;
37 input.split(parts,
'%');
40 for (llvm::StringRef part : drop_begin(parts)) {
42 if (part.consumeInteger(10, idx))
44 else if (idx < replacements.size())
45 output << replacements[idx];
47 return llvm::make_error<llvm::StringError>(
48 llvm::formatv(
"%{0} is out of range: not enough arguments specified",
50 llvm::errc::invalid_argument);
59 EntryCollection::const_iterator pos, end =
m_entries.end();
60 for (pos =
m_entries.begin(); pos != end; ++pos) {
61 llvm::SmallVector<llvm::StringRef, 4> matches;
62 if (pos->regex.Execute(command, &matches)) {
63 llvm::Expected<std::string> new_command =
66 result.
SetError(new_command.takeError());
75 bool force_repeat_command =
true;
77 force_repeat_command);
86 <<
"' failed to match any "
87 "regular expression in the '"
92 llvm::StringRef command_cstr) {
97 m_entries.back().command = command_cstr.str();
static bool InvokeCommonCompletionCallbacks(CommandInterpreter &interpreter, uint32_t completion_mask, lldb_private::CompletionRequest &request, SearchFilter *searcher)
bool HandleCommand(const char *command_line, LazyBool add_to_history, const ExecutionContext &override_context, CommandReturnObject &result)
bool GetExpandRegexAliases() const
CommandObjectRegexCommand(CommandInterpreter &interpreter, llvm::StringRef name, llvm::StringRef help, llvm::StringRef syntax, uint32_t completion_type_mask, bool is_removable)
EntryCollection m_entries
~CommandObjectRegexCommand() override
static llvm::Expected< std::string > SubstituteVariables(llvm::StringRef input, const llvm::SmallVectorImpl< llvm::StringRef > &replacements)
Substitute variables of the format %\d+ in the input string.
void HandleCompletion(CompletionRequest &request) override
This default version handles calling option argument completions and then calls HandleArgumentComplet...
const uint32_t m_completion_type_mask
void DoExecute(llvm::StringRef command, CommandReturnObject &result) override
bool AddRegexCommand(llvm::StringRef re_cstr, llvm::StringRef command_cstr)
CommandInterpreter & GetCommandInterpreter()
CommandInterpreter & m_interpreter
virtual llvm::StringRef GetSyntax()
void void AppendError(llvm::StringRef in_string)
Stream & GetErrorStream()
void SetStatus(lldb::ReturnStatus status)
void SetError(const Status &error, const char *fallback_error_cstr=nullptr)
Stream & GetOutputStream()
"lldb/Utility/ArgCompletionRequest.h"
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
A class that represents a running process on the host machine.