]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Interpreter/CommandHistory.h
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / include / lldb / Interpreter / CommandHistory.h
1 //===-- CommandHistory.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_CommandHistory_h_
11 #define liblldb_CommandHistory_h_
12
13 #include <mutex>
14 #include <string>
15 #include <vector>
16
17 #include "lldb/Utility/Stream.h"
18 #include "lldb/lldb-private.h"
19
20 namespace lldb_private {
21
22 class CommandHistory {
23 public:
24   CommandHistory();
25
26   ~CommandHistory();
27
28   size_t GetSize() const;
29
30   bool IsEmpty() const;
31
32   llvm::Optional<llvm::StringRef> FindString(llvm::StringRef input_str) const;
33
34   llvm::StringRef GetStringAtIndex(size_t idx) const;
35
36   llvm::StringRef operator[](size_t idx) const;
37
38   llvm::StringRef GetRecentmostString() const;
39
40   void AppendString(llvm::StringRef str, bool reject_if_dupe = true);
41
42   void Clear();
43
44   void Dump(Stream &stream, size_t start_idx = 0,
45             size_t stop_idx = SIZE_MAX) const;
46
47   static const char g_repeat_char = '!';
48
49 private:
50   DISALLOW_COPY_AND_ASSIGN(CommandHistory);
51
52   typedef std::vector<std::string> History;
53   mutable std::recursive_mutex m_mutex;
54   History m_history;
55 };
56
57 } // namespace lldb_private
58
59 #endif // liblldb_CommandHistory_h_