1254721Semaste//===-- CommandObjectRegexCommand.h -----------------------------*- C++ -*-===//
2254721Semaste//
3353358Sdim// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4353358Sdim// See https://llvm.org/LICENSE.txt for license information.
5353358Sdim// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6254721Semaste//
7254721Semaste//===----------------------------------------------------------------------===//
8254721Semaste
9254721Semaste#ifndef liblldb_CommandObjectRegexCommand_h_
10254721Semaste#define liblldb_CommandObjectRegexCommand_h_
11254721Semaste
12254721Semaste#include <list>
13254721Semaste
14254721Semaste#include "lldb/Interpreter/CommandObject.h"
15341825Sdim#include "lldb/Utility/CompletionRequest.h"
16321369Sdim#include "lldb/Utility/RegularExpression.h"
17254721Semaste
18254721Semastenamespace lldb_private {
19254721Semaste
20254721Semaste// CommandObjectRegexCommand
21254721Semaste
22314564Sdimclass CommandObjectRegexCommand : public CommandObjectRaw {
23254721Semastepublic:
24314564Sdim  CommandObjectRegexCommand(CommandInterpreter &interpreter, llvm::StringRef name,
25314564Sdim    llvm::StringRef help, llvm::StringRef syntax,
26314564Sdim                            uint32_t max_matches, uint32_t completion_type_mask,
27314564Sdim                            bool is_removable);
28254721Semaste
29314564Sdim  ~CommandObjectRegexCommand() override;
30280031Sdim
31314564Sdim  bool IsRemovable() const override { return m_is_removable; }
32254721Semaste
33314564Sdim  bool AddRegexCommand(const char *re_cstr, const char *command_cstr);
34254721Semaste
35314564Sdim  bool HasRegexEntries() const { return !m_entries.empty(); }
36314564Sdim
37360784Sdim  void HandleCompletion(CompletionRequest &request) override;
38314564Sdim
39254721Semasteprotected:
40341825Sdim  bool DoExecute(llvm::StringRef command, CommandReturnObject &result) override;
41254721Semaste
42314564Sdim  struct Entry {
43314564Sdim    RegularExpression regex;
44314564Sdim    std::string command;
45314564Sdim  };
46254721Semaste
47314564Sdim  typedef std::list<Entry> EntryCollection;
48314564Sdim  const uint32_t m_max_matches;
49314564Sdim  const uint32_t m_completion_type_mask;
50314564Sdim  EntryCollection m_entries;
51314564Sdim  bool m_is_removable;
52254721Semaste
53254721Semasteprivate:
54314564Sdim  DISALLOW_COPY_AND_ASSIGN(CommandObjectRegexCommand);
55254721Semaste};
56254721Semaste
57254721Semaste} // namespace lldb_private
58254721Semaste
59296417Sdim#endif // liblldb_CommandObjectRegexCommand_h_
60