Home | History | Annotate | Download | only in Interpreter
      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/Core/RegularExpression.h"
     20 #include "lldb/Interpreter/CommandObject.h"
     21 
     22 namespace lldb_private {
     23 
     24 //-------------------------------------------------------------------------
     25 // CommandObjectRegexCommand
     26 //-------------------------------------------------------------------------
     27 
     28 class CommandObjectRegexCommand : public CommandObjectRaw
     29 {
     30 public:
     31 
     32     CommandObjectRegexCommand (CommandInterpreter &interpreter,
     33                                const char *name,
     34                                const char *help,
     35                                const char *syntax,
     36                                uint32_t max_matches,
     37                                uint32_t completion_type_mask = 0);
     38 
     39     virtual
     40     ~CommandObjectRegexCommand ();
     41 
     42     bool
     43     AddRegexCommand (const char *re_cstr, const char *command_cstr);
     44 
     45     bool
     46     HasRegexEntries () const
     47     {
     48         return !m_entries.empty();
     49     }
     50 
     51     virtual int
     52     HandleCompletion (Args &input,
     53                       int &cursor_index,
     54                       int &cursor_char_position,
     55                       int match_start_point,
     56                       int max_return_elements,
     57                       bool &word_complete,
     58                       StringList &matches);
     59 
     60 protected:
     61     virtual bool
     62     DoExecute (const char *command, CommandReturnObject &result);
     63 
     64     struct Entry
     65     {
     66         RegularExpression regex;
     67         std::string command;
     68     };
     69 
     70     typedef std::list<Entry> EntryCollection;
     71     const uint32_t m_max_matches;
     72     const uint32_t m_completion_type_mask;
     73     EntryCollection m_entries;
     74 
     75 private:
     76     DISALLOW_COPY_AND_ASSIGN (CommandObjectRegexCommand);
     77 };
     78 
     79 } // namespace lldb_private
     80 
     81 #endif  // liblldb_CommandObjectRegexCommand_h_
     82