FBB::ReadLineStream

libbobcat1-dev_3.01.00-x.tar.gz

2005-2012


FBB::ReadLineStream(3bobcat)

FBB::ReadLineStream(3bobcat)

libbobcat1-dev_3.01.00-x.tar.gz Editing input lines

2005-2012

NAME

FBB::ReadLineStream - std::istream offering line-editing and history

SYNOPSIS

#include <bobcat/readlinestream>
Linking option: -lreadline -lbobcat

DESCRIPTION

A FBB::ReadLineStream object is a std::istream objects, allowing line-editing and history manipulation.

The ReadLineStream class uses Gnu's readline library to allow editing of input lines. The ReadLineStream object can be used to construct a std::istream allowing in-line editing of lines read from the terminal. All lines may be preceded by a configurable prompt.

Since Gnu's readline library operates on global data there can only be one ReadLineStream (and underlying ReadLineBuf) object. ReadLineStream is a singleton class: in any program there can only be one ReadLineStream object.

ReadLineStream offers editing capabilities while the user is entering lines. Like Gnu's readline(3) function, the line editing commands are by default similar to those of emacs(1), but can easily be reconfigured, e.g. to offer vi(1)-like characteristics.

History manipulation is provided as an option. The collected history may be accessed for reading using an FBB::ReadLineHistory object.

Specific information about the facilities offered by the Gnu software used by ReadLineStream is provided in the GNU Readline Library documentation (http://cnswww.cns.cwru.edu/php/chet/readline/rltop.html).

Gnu's readline function reads its information from the standard input file. Programs using ReadLineStream should normally not extract information from std::cin. However, as the standard input file has a file descriptor (0), redirection should be possible (e.g., using FBB::Redirector).

When the command line is kept, history expansion is offered as an option. History expansion introduces words from the history list into the input stream, making it easy to repeat commands, to insert elements of a previous input line into the current input line, or to fix errors in previous command lines.

History expansion is usually performed immediately after a complete line is read.

The line selected from the history is called the event, and the portions of that line that are processed are called words. Various modifiers are available to manipulate selected words. This is comparable to the way a program like bash(1) breaks up its input line into `words'.

History expansion is introduced by the use of the history expansion character, by default equal to the !-character. Only backslash (\) and single quotes can change the history expansion character into a normal character.

The remainder of this section is copied almost verbatim from the history(3) man-page. The reader is referred to that man-page or to the Gnu History Library documentation for further details.

The following event designators are supported:

Word Designators

Word designators are used to select desired words from the event. A : separates the event specification from the word designator. It may be omitted if the word designator begins with a ^, $, *, -, or %. Words are numbered from the beginning of the line, with the first word being denoted by 0 (zero). Words are inserted into the current line separated by single spaces.

EXAMPLE


#include <bobcat/syslogstream>

using namespace std;
using namespace FBB;

int main(int argc, char **argv)
{
    SyslogStream sls(argv[0]);

    sls << SyslogStream::debug << "Hello world" << endl;
    sls << SyslogStream::strerrno << endl;
    
    return 0;
}
    

FILES

bobcat/syslogstream - defines the class interface

SEE ALSO

bobcat(7), openlog(3), syslog(3), syslogstream(3bobcat)

BUGS

The constructor's option parameter is an int. Because of this, int values rather than enumeration values are passed to the constructor. It is the responsibility of the programmer to pass defined option values only.

DISTRIBUTION FILES

BOBCAT

Bobcat is an acronym of `Brokken's Own Base Classes And Templates'.

COPYRIGHT

This is free software, distributed under the terms of the GNU General Public License (GPL).

AUTHOR

Frank B. Brokken (f.b.brokken@rug.nl).

./usr/share/doc/libbobcat3-dev/man/binarysearch.3.html0000644000000000000000000001512512022707551021432 0ustar rootroot FBB::binary_search


FBB::binary_search

libbobcat1-dev_3.01.00-x.tar.gz

2005-2012


FBB::binary_search(3bobcat)

FBB::binary_search(3bobcat)

libbobcat1-dev_3.01.00-x.tar.gz Binary search function

2005-2012

NAME

FBB::binary_search - Extensions to the STL binary_search function template

SYNOPSIS

#include <bobcat/binarysearch>

DESCRIPTION

The FBB::binary_search function templates extend the STL binary_search function template returning an iterator to the element found, instead of a bool value informing the caller whether or not the searched for element is present in a provided iterator range.

The bool value returned by the STL binary_search function template is often not the kind of information the caller of the function is interested in. Rather, the caller will often want to use binary_search in the way find_if is used: returning an iterator to the found element or returning the end-iterator if the element was not found. Whereas find_if does not require the elements in the iterator range to be sorted, and thus will use a linear search binary_search may use the sorted nature of the elements to its advantage, using a binary search algorithm requiring 2 log N iterations to locate the searched for element rather than (on average) N/2 iterations. The FBB::binary_search algorithm uses this binary searching process while at the same time allowing its use like find_if.

Since the FBB::binary_search function templates use the same number and types of parameters as the stl::binary_search function templates the explicit use of the FBB namespace will often be required in situations where both function templates are made available to the compiler.

NAMESPACE

FBB
All constructors, members, operators and manipulators, mentioned in this man-page, are defined in the namespace FBB.

INHERITS FROM

-

OVERLOADED FUNCTIONS

In the following description several template type parameters are used. They are:

EXAMPLES

#include <iostream>
#include <string>
#include "../binarysearch"

using namespace std;
using namespace FBB;

string words[] = 
{
    "eight",                // alphabetically sorted number-names
    "five",
    "four",
    "nine",
    "one",
    "seven",
    "six",
    "ten",
    "three",
    "two"
};

class Comparator
{
    public:
        bool operator()(string const &left, string const &right) const;
};

inline bool Comparator::operator()(string const &left, 
                                   string const &right) const
{
    return left < right;
}


bool compFun(string const &left, string const &right)
{
    return left < right;
}


int main()
{
    string *ret = binary_search(words, words + 10, "five");
    if (ret != words + 10)
        cout << "five is at offset " << (ret - words) << endl;

    ret = binary_search(words, words + 10, "grandpa");
    if (ret == words + 10)
        cout << "grandpa is not the name of a number\n";

    ret = binary_search(words, words + 10, "five", Comparator());
    if (ret != words + 10)
        cout << "five is at offset " << (ret - words) << endl;

    ret = binary_search(words, words + 10, "grandpa", compFun); 
                                                   // or use: Comparator()
    if (ret == words + 10)
        cout << "grandpa is not the name of a number\n";

    return 0;
}

FILES

bobcat/binarysearch - defines the template functions

SEE ALSO

bobcat(7)

BUGS

None reported.

DISTRIBUTION FILES

BOBCAT

Bobcat is an acronym of `Brokken's Own Base Classes And Templates'.

COPYRIGHT

This is free software, distributed under the terms of the GNU General Public License (GPL).

AUTHOR

Frank B. Brokken (f.b.brokken@rug.nl).