FBB::OFoldStream(3bobcat)

Fold long lines
(libbobcat-dev_6.04.00)

2005-2023

NAME

FBB::OFoldStream - Folds long lines

SYNOPSIS

#include <bobcat/ofoldstream>
Linking option: -lbobcat

DESCRIPTION

FBB::OFoldStream folds long lines written to it. The OFoldStream writes the (folded) lines to a second ostream which is either used by or opened by the OFoldStream object.

OFoldStream objects never fold lines in the middle of series of non-blank characters but will always break a line at white space characters. The resulting lines will always appear to the right of a configurable left margin and to the left of a configurable right margin. There is a somewhat pathological exception to this: if a word is too long to fit in between the margins then the word will exceed the right hand margin.

The indentation used for the left margins is configurable to either blanks (the default) or tabs. When tabs are used the width of a tab character is configurable, using a default of 8 positions in the destination stream.

OFoldStream is implemented as a wrapper class around std::ostream and FBB::OFoldBuf and a more complete description of the folding process can be found in the ofoldbuf(3bobcat) man page.

NAMESPACE

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

INHERITS FROM

std::ostream,
(and privately from FBB::OFoldBuf)

ENUMERATION

The enumeration TabsOrBlanks is used to select tabs or blanks when writing the indentation. The default is blanks. When tabs are selected the display width of tabs characters can be configured as well (using the default of 8 positions for each tab-character). The enumeration has two values:

The enumeration TrailingBlanks is used to configure the OFoldStream object with respect to any trailing blanks that may appear on the final line. It is the same enumeration type as used with OFoldBuf (cf. ofoldbuf(3bobcat)) having two values:

CONSTRUCTORS

The destructor writes any buffered information to the destination stream and will then flush the destination stream.

Copy and move constructors (and assignment operators) are not available.

MEMBER FUNCTIONS

All members of std::ostream are available, as FBB::OFoldStream inherits from this class.

STATIC MEMBER FUNCTIONS

EXAMPLE

#include <iostream>
#include <string>
#include <bobcat/ofoldstream>

using namespace std;
using namespace FBB;

void margins(ostream &out)
{
    cout << OFoldStream::leftMargin(out) << ", " <<
            OFoldStream::rightMargin(out) << endl;
}

int main()
{
    OFoldStream out(cout, 4, 40);

    out << lm(4);

    string line;
    while (getline(cin, line))
        out << line << '\n';

    margins(out);
}

FILES

bobcat/ofoldstream - defines the class interface

SEE ALSO

bobcat(7), lm(3bobcat), mlm(3bobcat), ofoldbuf(3bobcat)

BUGS

None Reported.

BOBCAT PROJECT 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).