LLDB  mainline
CommandHistory.h
Go to the documentation of this file.
1 //===-- CommandHistory.h ----------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLDB_INTERPRETER_COMMANDHISTORY_H
10 #define LLDB_INTERPRETER_COMMANDHISTORY_H
11 
12 #include <mutex>
13 #include <string>
14 #include <vector>
15 
16 #include "lldb/Utility/Stream.h"
17 #include "lldb/lldb-private.h"
18 
19 namespace lldb_private {
20 
22 public:
23  CommandHistory() = default;
24 
25  ~CommandHistory() = default;
26 
27  size_t GetSize() const;
28 
29  bool IsEmpty() const;
30 
31  llvm::Optional<llvm::StringRef> FindString(llvm::StringRef input_str) const;
32 
33  llvm::StringRef GetStringAtIndex(size_t idx) const;
34 
35  llvm::StringRef operator[](size_t idx) const;
36 
37  llvm::StringRef GetRecentmostString() const;
38 
39  void AppendString(llvm::StringRef str, bool reject_if_dupe = true);
40 
41  void Clear();
42 
43  void Dump(Stream &stream, size_t start_idx = 0,
44  size_t stop_idx = SIZE_MAX) const;
45 
46  static const char g_repeat_char = '!';
47 
48 private:
49  CommandHistory(const CommandHistory &) = delete;
50  const CommandHistory &operator=(const CommandHistory &) = delete;
51 
52  typedef std::vector<std::string> History;
53  mutable std::recursive_mutex m_mutex;
55 };
56 
57 } // namespace lldb_private
58 
59 #endif // LLDB_INTERPRETER_COMMANDHISTORY_H
lldb_private::CommandHistory::m_mutex
std::recursive_mutex m_mutex
Definition: CommandHistory.h:53
lldb_private::CommandHistory::GetSize
size_t GetSize() const
Definition: CommandHistory.cpp:16
lldb_private::CommandHistory::GetRecentmostString
llvm::StringRef GetRecentmostString() const
Definition: CommandHistory.cpp:71
lldb_private::CommandHistory::IsEmpty
bool IsEmpty() const
Definition: CommandHistory.cpp:21
lldb_private::CommandHistory::m_history
History m_history
Definition: CommandHistory.h:54
lldb_private::CommandHistory::Dump
void Dump(Stream &stream, size_t start_idx=0, size_t stop_idx=SIZE_MAX) const
Definition: CommandHistory.cpp:94
lldb_private::Stream
Definition: Stream.h:28
lldb_private::CommandHistory
Definition: CommandHistory.h:21
lldb_private::CommandHistory::operator[]
llvm::StringRef operator[](size_t idx) const
Definition: CommandHistory.cpp:67
lldb_private::CommandHistory::History
std::vector< std::string > History
Definition: CommandHistory.h:52
lldb_private::CommandHistory::g_repeat_char
static const char g_repeat_char
Definition: CommandHistory.h:46
lldb-private.h
lldb_private::CommandHistory::~CommandHistory
~CommandHistory()=default
lldb_private::CommandHistory::operator=
const CommandHistory & operator=(const CommandHistory &)=delete
lldb_private::CommandHistory::GetStringAtIndex
llvm::StringRef GetStringAtIndex(size_t idx) const
Definition: CommandHistory.cpp:60
lldb_private::CommandHistory::CommandHistory
CommandHistory()=default
lldb_private::CommandHistory::Clear
void Clear()
Definition: CommandHistory.cpp:89
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
Stream.h
lldb_private::CommandHistory::FindString
llvm::Optional< llvm::StringRef > FindString(llvm::StringRef input_str) const
Definition: CommandHistory.cpp:27
lldb_private::CommandHistory::AppendString
void AppendString(llvm::StringRef str, bool reject_if_dupe=true)
Definition: CommandHistory.cpp:78