/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/source/Commands/CommandObjectRegexCommand.h
Line | Count | Source |
1 | | //===-- CommandObjectRegexCommand.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_COMMANDOBJECTREGEXCOMMAND_H |
10 | | #define LLDB_INTERPRETER_COMMANDOBJECTREGEXCOMMAND_H |
11 | | |
12 | | #include <list> |
13 | | |
14 | | #include "lldb/Interpreter/CommandObject.h" |
15 | | #include "lldb/Utility/CompletionRequest.h" |
16 | | #include "lldb/Utility/RegularExpression.h" |
17 | | |
18 | | namespace lldb_private { |
19 | | |
20 | | // CommandObjectRegexCommand |
21 | | |
22 | | class CommandObjectRegexCommand : public CommandObjectRaw { |
23 | | public: |
24 | | CommandObjectRegexCommand(CommandInterpreter &interpreter, |
25 | | llvm::StringRef name, llvm::StringRef help, |
26 | | llvm::StringRef syntax, |
27 | | uint32_t completion_type_mask, bool is_removable); |
28 | | |
29 | | ~CommandObjectRegexCommand() override; |
30 | | |
31 | 16 | bool IsRemovable() const override { return m_is_removable; } |
32 | | |
33 | | bool AddRegexCommand(llvm::StringRef re_cstr, llvm::StringRef command_cstr); |
34 | | |
35 | 5 | bool HasRegexEntries() const { return !m_entries.empty(); } |
36 | | |
37 | | void HandleCompletion(CompletionRequest &request) override; |
38 | | |
39 | | protected: |
40 | | void DoExecute(llvm::StringRef command, CommandReturnObject &result) override; |
41 | | |
42 | | /// Substitute variables of the format %\d+ in the input string. |
43 | | static llvm::Expected<std::string> SubstituteVariables( |
44 | | llvm::StringRef input, |
45 | | const llvm::SmallVectorImpl<llvm::StringRef> &replacements); |
46 | | |
47 | | struct Entry { |
48 | | RegularExpression regex; |
49 | | std::string command; |
50 | | }; |
51 | | |
52 | | typedef std::list<Entry> EntryCollection; |
53 | | const uint32_t m_completion_type_mask; |
54 | | EntryCollection m_entries; |
55 | | bool m_is_removable; |
56 | | |
57 | | private: |
58 | | CommandObjectRegexCommand(const CommandObjectRegexCommand &) = delete; |
59 | | const CommandObjectRegexCommand & |
60 | | operator=(const CommandObjectRegexCommand &) = delete; |
61 | | }; |
62 | | |
63 | | } // namespace lldb_private |
64 | | |
65 | | #endif // LLDB_INTERPRETER_COMMANDOBJECTREGEXCOMMAND_H |