Readline-- Documentation

2.0.8

logo.png

This package implements a full GNU Readline interface in C++. The API is quite simple and makes heavy use of templated container, standard classes and so on. The idea is that a C++ developer should fell resonabily comfortable with the library API.

Overview

The C library API function have been split into various class templates that deal with one specific topic. Each template takes on parameter, the thread locking type.
rlmm::basic_readline
This is the main class. Users can manipulate the basic readline behaviour through this class.
rlmm::basic_history
All history related operations go through this class. The class has been implmented such that it is possible (and easy) to have multiple histories (think of Emacs) in the same application.
rlmm::basic_key_map
Binding keys and key-sequences go through this class. Mutliple key-maps can exist in a single application.
rlmm::basic_function_map
Manipluation of named functions.
rlmm::basic_completion
An Abstract Base Class (ABC) for user defined completions. The class defines an interface the users can derive from to implement a completion scheme. The user need at the minimum to implement a member function to get the list of possible completions (rlmm::basic_completion::possibilities) and a member function that will serve these completions (rlmm::basic_completion::complete). If the application uses containers of some sort, these member functions can be very effectively implemented, by simply giving references into the containers.
rlmm::basic_callback
An ABC for using Readline in a call-back fashion. The user should derive her call-back class from this class, and implement the handler member function to handle lines of input.
rlmm::basic_signal_handler
Utility class

In addition, there's a number of utility classes and class templates

rlmm::basic_buffer
Interface to readlines internal buffer
rlmm::undo
guard type class to implement undoing in a certain region.
rlmm::command
Interface functor class for commands. Users can derive from this class to define new functions

Stream interface.

Use the library as a regular std::istream. This makes the code very transparent, and easy to plug into other kinds of applications that accepts an std::istream as the input method. See also the streamer example

Thread safety

Thread safety is implemented in the class templates via a template parameter. This parameter should be a class that defines the member functions lock() and unlock(). The semantics of these member functions, is that the lock() member function should lock a specific syncronisation objet, like a mutex or CriticalSection. Similarly the unlock() member function should release the lock of the underlying sycronisation oject.

An example for POSIX threads could be

    #include <pthread.h>

    class posix_lock 
    {
    private:
      pthread_mutex_t _mutex;
    public:
      posix_lock() { pthread_mutex_init(&_mutex, NULL); }
      ~posix_lock() { pthread_mutex_destroy(&_mutex); }
      void lock() { pthread_mutex_lock(&_mutex); }
      void unlock() { pthread_mutex_unlock(&_mutex); }
    };

Note, that the class lilbrary provides the class rlmm::single_thread that does no locking what so ever.

Singletons and `One at a time' classes

A number of class templates in the library are singletons. That is, only one such object can exists at a given time. The object is accessed via <class> instance(), which returns a reference to the object. Singletons in the library is implemented via the utility class rlmm::singleton.

Singletons in the library are

For a number of the class templates in the library, only one object can be active at given time. These are termed `one at a time' classes in the library. A given object is made active by the member function activate(), which deactivates the current active object, and activates the object which the member function was called upon. The member function deactivate() deactivates the object is it called upon, if and only if it is the current actie object. It then restores the default object as current active object. `one at a time' classes are implemented via rlmm::one_at_a_time.

`One at a time' class templates in the library are:

Top of page
Last update Fri Aug 26 15:19:46 2005
Christian Holm
Created by DoxyGen 1.4.4