1 //===-- CommandHistory.h ----------------------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef liblldb_CommandHistory_h_
10 #define liblldb_CommandHistory_h_
16 #include "lldb/Utility/Stream.h"
17 #include "lldb/lldb-private.h"
19 namespace lldb_private {
21 class CommandHistory {
27 size_t GetSize() const;
31 llvm::Optional<llvm::StringRef> FindString(llvm::StringRef input_str) const;
33 llvm::StringRef GetStringAtIndex(size_t idx) const;
35 llvm::StringRef operator[](size_t idx) const;
37 llvm::StringRef GetRecentmostString() const;
39 void AppendString(llvm::StringRef str, bool reject_if_dupe = true);
43 void Dump(Stream &stream, size_t start_idx = 0,
44 size_t stop_idx = SIZE_MAX) const;
46 static const char g_repeat_char = '!';
49 DISALLOW_COPY_AND_ASSIGN(CommandHistory);
51 typedef std::vector<std::string> History;
52 mutable std::recursive_mutex m_mutex;
56 } // namespace lldb_private
58 #endif // liblldb_CommandHistory_h_