The readline library wrapper. More...
#include <stdair/ui/cmdline/SReadline.hpp>
Public Member Functions | |
| SReadline (const size_t Limit=DefaultHistoryLimit) | |
| Constructs the object, sets the completion function. | |
| SReadline (const std::string &historyFileName, const size_t Limit=DefaultHistoryLimit) | |
| Constructs the object, sets the completion function, loads history. | |
| ~SReadline () | |
| Saves the session history (if the file name was provided) and destroys the object. | |
| std::string | GetLine (const std::string &Prompt) |
| Gets a single line from a user. | |
| template<typename Container > | |
| std::string | GetLine (const std::string &Prompt, Container &ReadTokens) |
| Gets a single line from a user. | |
| template<typename Container > | |
| std::string | GetLine (const std::string &Prompt, Container &ReadTokens, bool &BreakOut) |
| Gets a single line from a user. | |
| std::string | GetLine (const std::string &Prompt, bool &BreakOut) |
| Gets a single line from a user. | |
| template<typename ContainerType > | |
| void | GetHistory (ContainerType &Container) |
| Fills the given container with the current history list. | |
| bool | SaveHistory (std::ostream &OS) |
| Saves the history to the given file stream. | |
| bool | SaveHistory (const std::string &FileName) |
| Saves the history to the given file. | |
| void | ClearHistory () |
| Clears the history. Does not affect the file where the previous session history is saved. | |
| bool | LoadHistory (std::istream &IS) |
| Loads a history from a file stream. | |
| bool | LoadHistory (const std::string &FileName) |
| Loads a history from the given file. | |
| template<typename ContainerType > | |
| void | RegisterCompletions (const ContainerType &Container) |
| Allows to register custom completers. | |
| void | SetKeymap (SKeymap &NewKeymap) |
| Sets the given keymap. | |
The readline library wrapper.
Attention: It is not thread safe! Supports: editing, history, custom completers
Definition at line 424 of file SReadline.hpp.
| swift::SReadline::SReadline | ( | const size_t | Limit = DefaultHistoryLimit | ) | [inline] |
Constructs the object, sets the completion function.
| Limit | History size |
Definition at line 431 of file SReadline.hpp.
| swift::SReadline::SReadline | ( | const std::string & | historyFileName, |
| const size_t | Limit = DefaultHistoryLimit |
||
| ) | [inline] |
Constructs the object, sets the completion function, loads history.
| historyFileName | File name to load history from |
| Limit | History size |
Definition at line 446 of file SReadline.hpp.
References LoadHistory().
| swift::SReadline::~SReadline | ( | ) | [inline] |
Saves the session history (if the file name was provided) and destroys the object.
Definition at line 462 of file SReadline.hpp.
References SaveHistory().
| std::string swift::SReadline::GetLine | ( | const std::string & | Prompt | ) | [inline] |
Gets a single line from a user.
| Prompt | A printed prompt |
Definition at line 473 of file SReadline.hpp.
Referenced by GetLine().
| std::string swift::SReadline::GetLine | ( | const std::string & | Prompt, |
| Container & | ReadTokens | ||
| ) | [inline] |
Gets a single line from a user.
| Prompt | A printed prompt |
| ReadTokens | A user inputed string splitted into tokens. The container is cleared first |
Definition at line 487 of file SReadline.hpp.
References GetLine().
| std::string swift::SReadline::GetLine | ( | const std::string & | Prompt, |
| Container & | ReadTokens, | ||
| bool & | BreakOut | ||
| ) | [inline] |
Gets a single line from a user.
| Prompt | A printed prompt |
| BreakOut | it is set to true if the EOF found |
| ReadTokens | A user inputed string splitted into tokens. The container is cleared first |
Definition at line 502 of file SReadline.hpp.
References GetLine().
| std::string swift::SReadline::GetLine | ( | const std::string & | Prompt, |
| bool & | BreakOut | ||
| ) | [inline] |
Gets a single line from a user.
| Prompt | A printed prompt |
| BreakOut | it is set to true if the EOF found |
Definition at line 517 of file SReadline.hpp.
| void swift::SReadline::GetHistory | ( | ContainerType & | Container | ) | [inline] |
Fills the given container with the current history list.
Does not clear the given container
Definition at line 552 of file SReadline.hpp.
| bool swift::SReadline::SaveHistory | ( | std::ostream & | OS | ) | [inline] |
Saves the history to the given file stream.
| OS | output file stream |
Definition at line 564 of file SReadline.hpp.
Referenced by SaveHistory(), and ~SReadline().
| bool swift::SReadline::SaveHistory | ( | const std::string & | FileName | ) | [inline] |
Saves the history to the given file.
| FileName | File name to save the history to |
Definition at line 581 of file SReadline.hpp.
References SaveHistory().
| void swift::SReadline::ClearHistory | ( | ) | [inline] |
Clears the history. Does not affect the file where the previous session history is saved.
Definition at line 594 of file SReadline.hpp.
Referenced by LoadHistory().
| bool swift::SReadline::LoadHistory | ( | std::istream & | IS | ) | [inline] |
Loads a history from a file stream.
| IS | Input file stream |
Definition at line 604 of file SReadline.hpp.
References ClearHistory().
Referenced by LoadHistory(), and SReadline().
| bool swift::SReadline::LoadHistory | ( | const std::string & | FileName | ) | [inline] |
Loads a history from the given file.
| FileName | File name to be load from |
Definition at line 629 of file SReadline.hpp.
References LoadHistory().
| void swift::SReadline::RegisterCompletions | ( | const ContainerType & | Container | ) | [inline] |
Allows to register custom completers.
Supports a special keyword: file. It means to use the standard file name completer.
For example the given container elements could be as follows:
Each container element must describe a single possible command line. The container element must have a conversion to std::string operator.
| Container | A container which has all the user possible commands. |
Definition at line 658 of file SReadline.hpp.
| void swift::SReadline::SetKeymap | ( | SKeymap & | NewKeymap | ) | [inline] |
Sets the given keymap.
| NewKeymap | The keymap that should be used from now. |
Definition at line 675 of file SReadline.hpp.