]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Interpreter/CommandObjectRegexCommand.h
MFV r329760: 7638 Refactor spa_load_impl into several functions
[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/RegularExpression.h"
21
22 namespace lldb_private {
23
24 //-------------------------------------------------------------------------
25 // CommandObjectRegexCommand
26 //-------------------------------------------------------------------------
27
28 class CommandObjectRegexCommand : public CommandObjectRaw {
29 public:
30   CommandObjectRegexCommand(CommandInterpreter &interpreter, llvm::StringRef name,
31     llvm::StringRef help, llvm::StringRef syntax,
32                             uint32_t max_matches, uint32_t completion_type_mask,
33                             bool is_removable);
34
35   ~CommandObjectRegexCommand() override;
36
37   bool IsRemovable() const override { return m_is_removable; }
38
39   bool AddRegexCommand(const char *re_cstr, const char *command_cstr);
40
41   bool HasRegexEntries() const { return !m_entries.empty(); }
42
43   int HandleCompletion(Args &input, int &cursor_index,
44                        int &cursor_char_position, int match_start_point,
45                        int max_return_elements, bool &word_complete,
46                        StringList &matches) override;
47
48 protected:
49   bool DoExecute(const char *command, CommandReturnObject &result) override;
50
51   struct Entry {
52     RegularExpression regex;
53     std::string command;
54   };
55
56   typedef std::list<Entry> EntryCollection;
57   const uint32_t m_max_matches;
58   const uint32_t m_completion_type_mask;
59   EntryCollection m_entries;
60   bool m_is_removable;
61
62 private:
63   DISALLOW_COPY_AND_ASSIGN(CommandObjectRegexCommand);
64 };
65
66 } // namespace lldb_private
67
68 #endif // liblldb_CommandObjectRegexCommand_h_