CLI  2.9
command_line_history.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2006-2018, Alexis Royer, http://alexis.royer.free.fr/CLI
3 
4  All rights reserved.
5 
6  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
7 
8  * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
9  * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation
10  and/or other materials provided with the distribution.
11  * Neither the name of the CLI library project nor the names of its contributors may be used to endorse or promote products derived from this software
12  without specific prior written permission.
13 
14  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
15  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
16  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
17  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
18  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
22  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
23  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 
27 
31 
32 #ifndef _CLI_CMD_LINE_HISTORY_H_
33 #define _CLI_CMD_LINE_HISTORY_H_
34 
35 #include "cli/namespace.h"
36 #include "cli/object.h"
37 #include "cli/tk.h"
38 
39 #include "command_line_edition.h"
40 
41 
43 
44  // Forward declarations.
45  class CmdLineEdition;
46 
47 
49  class CmdLineHistory : public Object
50  {
51  public:
53  explicit CmdLineHistory(
54  const unsigned int UI_StackSize
55  );
56 
58  virtual ~CmdLineHistory(void);
59 
60  private:
64  CmdLineHistory& operator=(const CmdLineHistory&);
65 
66  public:
69  const bool Push(
70  const CmdLineEdition& CLI_Line
71  );
72 
75  const bool Clear(void);
76 
77  public:
80  const CmdLineEdition& GetLine(
81  const unsigned int UI_BackwardIndex
82  ) const;
84 
87  const unsigned int GetCount(void) const;
88 
89  public:
92  const bool SaveCurrentLine(
93  const CmdLineEdition& CLI_CurrentLine
94  );
95 
99  const bool Navigate(
100  CmdLineEdition& CLI_CmdLine,
101  const OutputDevice& CLI_Stream,
102  const int I_Navigation
103  );
106 
109  const unsigned int GetNavigationIndex(void) const;
110 
116  const bool B_NavigationMemory
117  );
118 
119  private:
121  const unsigned int m_uiStackSize;
123  tk::Queue<CmdLineEdition> m_qHistory;
125  unsigned int m_uiNavigationIndex;
127  bool m_bNavigation;
128  };
129 
131 
132 #endif // _CLI_CMD_LINE_HISTORY_H_
Generic object.
Definition: object.h:42
Main namespace of the CLI library.
virtual ~CmdLineHistory(void)
Destructor.
const unsigned int GetCount(void) const
History line count retrieval.
const bool Clear(void)
Cleares all history from the stack.
const unsigned int GetNavigationIndex(void) const
History index retrieval.
const CmdLineEdition & GetLine(const unsigned int UI_BackwardIndex) const
History line retrieval.
#define CLI_NS_END(__ns)
End a namespace definition.
Definition: namespace.h:45
CmdLineHistory(const unsigned int UI_StackSize)
Default constructor.
Namespace management.
const bool Push(const CmdLineEdition &CLI_Line)
Pushes a command line in the history stack.
CmdLineEdition class definition.
Command line history objet.
Generic output device.
Definition: io_device.h:256
const bool SaveCurrentLine(const CmdLineEdition &CLI_CurrentLine)
Saves the current line.
#define CLI_NS_BEGIN(__ns)
Begin a namespace definition.
Definition: namespace.h:38
CLI toolkit definition.
Object class definition.
void EnableNavigationMemory(const bool B_NavigationMemory)
Navigation memory enabling.
Command line edition objet.
const bool Navigate(CmdLineEdition &CLI_CmdLine, const OutputDevice &CLI_Stream, const int I_Navigation)
History line navigation.