]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Interpreter/CommandObjectRegexCommand.h
Merge clang 7.0.1 and several follow-up changes
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / include / lldb / Interpreter / CommandObjectRegexCommand.h
1 //===-- CommandObjectRegexCommand.h -----------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef liblldb_CommandObjectRegexCommand_h_
11 #define liblldb_CommandObjectRegexCommand_h_
12
13 // C Includes
14 // C++ Includes
15 #include <list>
16
17 // Other libraries and framework includes
18 // Project includes
19 #include "lldb/Interpreter/CommandObject.h"
20 #include "lldb/Utility/CompletionRequest.h"
21 #include "lldb/Utility/RegularExpression.h"
22
23 namespace lldb_private {
24
25 //-------------------------------------------------------------------------
26 // CommandObjectRegexCommand
27 //-------------------------------------------------------------------------
28
29 class CommandObjectRegexCommand : public CommandObjectRaw {
30 public:
31   CommandObjectRegexCommand(CommandInterpreter &interpreter, llvm::StringRef name,
32     llvm::StringRef help, llvm::StringRef syntax,
33                             uint32_t max_matches, uint32_t completion_type_mask,
34                             bool is_removable);
35
36   ~CommandObjectRegexCommand() override;
37
38   bool IsRemovable() const override { return m_is_removable; }
39
40   bool AddRegexCommand(const char *re_cstr, const char *command_cstr);
41
42   bool HasRegexEntries() const { return !m_entries.empty(); }
43
44   int HandleCompletion(CompletionRequest &request) override;
45
46 protected:
47   bool DoExecute(llvm::StringRef command, CommandReturnObject &result) override;
48
49   struct Entry {
50     RegularExpression regex;
51     std::string command;
52   };
53
54   typedef std::list<Entry> EntryCollection;
55   const uint32_t m_max_matches;
56   const uint32_t m_completion_type_mask;
57   EntryCollection m_entries;
58   bool m_is_removable;
59
60 private:
61   DISALLOW_COPY_AND_ASSIGN(CommandObjectRegexCommand);
62 };
63
64 } // namespace lldb_private
65
66 #endif // liblldb_CommandObjectRegexCommand_h_