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 #include <list> 14 15 #include "lldb/Interpreter/CommandObject.h" 16 #include "lldb/Utility/CompletionRequest.h" 17 #include "lldb/Utility/RegularExpression.h" 18 19 namespace lldb_private { 20 21 //------------------------------------------------------------------------- 22 // CommandObjectRegexCommand 23 //------------------------------------------------------------------------- 24 25 class CommandObjectRegexCommand : public CommandObjectRaw { 26 public: 27 CommandObjectRegexCommand(CommandInterpreter &interpreter, llvm::StringRef name, 28 llvm::StringRef help, llvm::StringRef syntax, 29 uint32_t max_matches, uint32_t completion_type_mask, 30 bool is_removable); 31 32 ~CommandObjectRegexCommand() override; 33 IsRemovable()34 bool IsRemovable() const override { return m_is_removable; } 35 36 bool AddRegexCommand(const char *re_cstr, const char *command_cstr); 37 HasRegexEntries()38 bool HasRegexEntries() const { return !m_entries.empty(); } 39 40 int HandleCompletion(CompletionRequest &request) override; 41 42 protected: 43 bool DoExecute(llvm::StringRef command, CommandReturnObject &result) override; 44 45 struct Entry { 46 RegularExpression regex; 47 std::string command; 48 }; 49 50 typedef std::list<Entry> EntryCollection; 51 const uint32_t m_max_matches; 52 const uint32_t m_completion_type_mask; 53 EntryCollection m_entries; 54 bool m_is_removable; 55 56 private: 57 DISALLOW_COPY_AND_ASSIGN(CommandObjectRegexCommand); 58 }; 59 60 } // namespace lldb_private 61 62 #endif // liblldb_CommandObjectRegexCommand_h_ 63