CommandHistory.h revision bcbf2b55790e851c791a983d46bfaa2a38667247
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// C Includes
14// C++ Includes
15#include <string>
16#include <vector>
17
18// Other libraries and framework includes
19// Project includes
20
21#include "lldb/lldb-private.h"
22#include "lldb/Core/Stream.h"
23#include "lldb/Host/Mutex.h"
24
25namespace lldb_private {
26
27class CommandHistory
28{
29public:
30    CommandHistory ();
31
32    ~CommandHistory ();
33
34    size_t
35    GetSize () const;
36
37    bool
38    IsEmpty () const;
39
40    const char*
41    FindString (const char* input_str) const;
42
43    const char*
44    GetStringAtIndex (size_t idx) const;
45
46    const char*
47    operator [] (size_t idx) const;
48
49    const char*
50    GetRecentmostString () const;
51
52    void
53    AppendString (const std::string& str,
54                  bool reject_if_dupe = true);
55
56    void
57    Clear ();
58
59    void
60    Dump (Stream& stream,
61          size_t start_idx = 0,
62          size_t stop_idx = SIZE_MAX) const;
63
64    static const char g_repeat_char = '!';
65
66private:
67    DISALLOW_COPY_AND_ASSIGN(CommandHistory);
68
69    typedef std::vector<std::string> History;
70    mutable Mutex m_mutex;
71    History m_history;
72};
73
74} // namespace lldb_private
75
76#endif  // liblldb_CommandHistory_h_
77