The readline library wrapper.
More...
#include <stdair/ui/cmdline/SReadline.hpp>
|
| SReadline (const size_t Limit=DefaultHistoryLimit) |
| Constructs the object, sets the completion function. More...
|
|
| SReadline (const std::string &historyFileName, const size_t Limit=DefaultHistoryLimit) |
| Constructs the object, sets the completion function, loads history. More...
|
|
| ~SReadline () |
| Saves the session history (if the file name was provided) and destroys the object. More...
|
|
std::string | GetLine (const std::string &Prompt) |
| Gets a single line from a user. More...
|
|
template<typename Container > |
std::string | GetLine (const std::string &Prompt, Container &ReadTokens) |
| Gets a single line from a user. More...
|
|
template<typename Container > |
std::string | GetLine (const std::string &Prompt, Container &ReadTokens, bool &BreakOut) |
| Gets a single line from a user. More...
|
|
std::string | GetLine (const std::string &Prompt, bool &BreakOut) |
| Gets a single line from a user. More...
|
|
template<typename ContainerType > |
void | GetHistory (ContainerType &Container) |
| Fills the given container with the current history list. More...
|
|
bool | SaveHistory (std::ostream &OS) |
| Saves the history to the given file stream. More...
|
|
bool | SaveHistory (const std::string &FileName) |
| Saves the history to the given file. More...
|
|
void | ClearHistory () |
| Clears the history. Does not affect the file where the previous session history is saved. More...
|
|
bool | LoadHistory (std::istream &IS) |
| Loads a history from a file stream. More...
|
|
bool | LoadHistory (const std::string &FileName) |
| Loads a history from the given file. More...
|
|
template<typename ContainerType > |
void | RegisterCompletions (const ContainerType &Container) |
| Allows to register custom completers. More...
|
|
void | SetKeymap (SKeymap &NewKeymap) |
| Sets the given keymap. More...
|
|
The readline library wrapper.
Attention: It is not thread safe! Supports: editing, history, custom completers
Definition at line 424 of file SReadline.hpp.
◆ SReadline() [1/2]
swift::SReadline::SReadline |
( |
const size_t |
Limit = DefaultHistoryLimit | ) |
|
|
inline |
Constructs the object, sets the completion function.
- Parameters
-
Definition at line 431 of file SReadline.hpp.
◆ SReadline() [2/2]
swift::SReadline::SReadline |
( |
const std::string & |
historyFileName, |
|
|
const size_t |
Limit = DefaultHistoryLimit |
|
) |
| |
|
inline |
Constructs the object, sets the completion function, loads history.
- Parameters
-
historyFileName | File name to load history from |
Limit | History size |
Definition at line 446 of file SReadline.hpp.
◆ ~SReadline()
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.
◆ GetLine() [1/4]
std::string swift::SReadline::GetLine |
( |
const std::string & |
Prompt | ) |
|
|
inline |
Gets a single line from a user.
- Parameters
-
- Returns
- A string which was actually inputed
Definition at line 473 of file SReadline.hpp.
◆ GetLine() [2/4]
template<typename Container >
std::string swift::SReadline::GetLine |
( |
const std::string & |
Prompt, |
|
|
Container & |
ReadTokens |
|
) |
| |
|
inline |
Gets a single line from a user.
- Parameters
-
Prompt | A printed prompt |
ReadTokens | A user inputed string splitted into tokens. The container is cleared first |
- Returns
- A string which was actually inputed
Definition at line 487 of file SReadline.hpp.
◆ GetLine() [3/4]
template<typename Container >
std::string swift::SReadline::GetLine |
( |
const std::string & |
Prompt, |
|
|
Container & |
ReadTokens, |
|
|
bool & |
BreakOut |
|
) |
| |
|
inline |
Gets a single line from a user.
- Parameters
-
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 |
- Returns
- A string which was actually inputed
Definition at line 502 of file SReadline.hpp.
◆ GetLine() [4/4]
std::string swift::SReadline::GetLine |
( |
const std::string & |
Prompt, |
|
|
bool & |
BreakOut |
|
) |
| |
|
inline |
Gets a single line from a user.
- Parameters
-
Prompt | A printed prompt |
BreakOut | it is set to true if the EOF found |
- Returns
- A string which was actually inputed
Definition at line 517 of file SReadline.hpp.
◆ GetHistory()
template<typename ContainerType >
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.
◆ SaveHistory() [1/2]
bool swift::SReadline::SaveHistory |
( |
std::ostream & |
OS | ) |
|
|
inline |
Saves the history to the given file stream.
- Parameters
-
- Returns
- true if success
Definition at line 564 of file SReadline.hpp.
◆ SaveHistory() [2/2]
bool swift::SReadline::SaveHistory |
( |
const std::string & |
FileName | ) |
|
|
inline |
Saves the history to the given file.
- Parameters
-
FileName | File name to save the history to |
- Returns
- true if success
Definition at line 581 of file SReadline.hpp.
◆ ClearHistory()
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.
◆ LoadHistory() [1/2]
bool swift::SReadline::LoadHistory |
( |
std::istream & |
IS | ) |
|
|
inline |
Loads a history from a file stream.
- Parameters
-
- Returns
- true if success
Definition at line 604 of file SReadline.hpp.
◆ LoadHistory() [2/2]
bool swift::SReadline::LoadHistory |
( |
const std::string & |
FileName | ) |
|
|
inline |
Loads a history from the given file.
- Parameters
-
FileName | File name to be load from |
- Returns
- true if success
Definition at line 629 of file SReadline.hpp.
◆ RegisterCompletions()
template<typename ContainerType >
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:
-
command1 opt1
-
command1 opt2 file
-
command2
-
command2 opt1
Each container element must describe a single possible command line. The container element must have a conversion to std::string operator.
- Parameters
-
Container | A container which has all the user possible commands. |
Definition at line 658 of file SReadline.hpp.
◆ SetKeymap()
void swift::SReadline::SetKeymap |
( |
SKeymap & |
NewKeymap | ) |
|
|
inline |
Sets the given keymap.
- Parameters
-
NewKeymap | The keymap that should be used from now. |
Definition at line 675 of file SReadline.hpp.
The documentation for this class was generated from the following file: