swift::SReadline Class Reference

The readline library wrapper. Attention: It is not thread safe! Supports: editing, history, custom completers. More...

#include <SReadline.h>

Collaboration diagram for swift::SReadline:

Collaboration graph
[legend]
List of all members.

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 Does not clear the given container.
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. 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.
void SetKeymap (SKeymap &NewKeymap)
 Sets the given keymap.

Detailed Description

The readline library wrapper. Attention: It is not thread safe! Supports: editing, history, custom completers.

Definition at line 381 of file SReadline.h.


Constructor & Destructor Documentation

swift::SReadline::SReadline const size_t  Limit = DefaultHistoryLimit  )  [inline]
 

Constructs the object, sets the completion function.

Parameters:
Limit History size

Definition at line 387 of file SReadline.h.

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 401 of file SReadline.h.

References LoadHistory().

Here is the call graph for this function:


Member Function Documentation

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 471 of file SReadline.h.

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 456 of file SReadline.h.

References GetLine().

Here is the call graph for this function:

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 440 of file SReadline.h.

References GetLine().

Here is the call graph for this function:

std::string swift::SReadline::GetLine const std::string &  Prompt  )  [inline]
 

Gets a single line from a user.

Parameters:
Prompt A printed prompt
Returns:
A string which was actually inputed

Definition at line 426 of file SReadline.h.

Referenced by GetLine().

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 579 of file SReadline.h.

bool swift::SReadline::LoadHistory std::istream &  IS  )  [inline]
 

Loads a history from a file stream.

Parameters:
IS Input file stream
Returns:
true if success

Definition at line 554 of file SReadline.h.

Referenced by SReadline().

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 599 of file SReadline.h.

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 533 of file SReadline.h.

bool swift::SReadline::SaveHistory std::ostream &  OS  )  [inline]
 

Saves the history to the given file stream.

Parameters:
OS output file stream
Returns:
true if success

Definition at line 519 of file SReadline.h.

Referenced by ~SReadline().

void swift::SReadline::SetKeymap SKeymap NewKeymap  )  [inline]
 

Sets the given keymap.

Parameters:
NewKeymap The keymap that should be used from now

Definition at line 615 of file SReadline.h.

References swift::SKeymap::keymap.


The documentation for this class was generated from the following file:
Generated on Mon May 8 21:58:24 2006 for SReadline - C++ Wrapper Around readline Library by  doxygen 1.4.5