FBB::OFoldStream(3bobcat)
π FBB::OFoldStream β the fold-long-lines queen π
okay bestie, welcome to the bobcat manual page for FBB::OFoldStream(3bobcat) β she folds long lines and she does it beautifully. Let's get into it β¨
πΈ NAME πΈ
FBB::OFoldStream β Folds long lines. that's it, that's the job, and she eats every time π
β¨ SYNOPSIS β¨
#include <bobcat/ofoldstream>
Linking option: -lbobcat
π¦ DESCRIPTION π¦
FBB::OFoldStream folds long lines written to it. She writes the (folded) lines to a second ostream β one that's either already used by the OFoldStream object, or opened by it. no cap π«Ά
OFoldStream objects never fold lines in the middle of a series of non-blank characters. She will always break a line at white space characters. the resulting lines always show up 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 between the margins, then the word will exceed the right hand margin. she said "not my problem" π
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. a fuller description of the folding process lives over in the ofoldbuf(3bobcat) man page β go read her too, she's iconic π
π NAMESPACE π
FBB
all constructors, members, operators and manipulators mentioned in this man-page are defined in the namespace FBB. periodt.
π 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 tab characters can be configured as well (using the default of 8 positions for each tab-character). this enum has two values:
BLANKS: the default, indicating that the left margin is specified and written as a number of blanks;TABS: indicating that the left margin is specified and written as a number of tab-characters.
The enumeration TrailingBlanks is used to configure the OFoldStream object with respect to any trailing blanks that may appear on the final line. it's the same enumeration type as used with OFoldBuf (cf. ofoldbuf(3bobcat)), and it has two values:
IGNORE_TRAILING_BLANKS: this indicates that trailing blanks appearing at the final line, if it is not terminated by a newline, should not be written to the destinationstd::ostream. this is the default used byOFoldStreamobjects.KEEP_TRAILING_BLANKS: this indicates that trailing blanks at the final line, if it is not terminated by a newline, should be written to the destinationstd::ostream.
π CONSTRUCTORS π
OFoldStream()β this constructor initializes anOFoldStreamobject but does not associate it with a destination stream. it uses the values0,80,BLANKS, andIGNORE_TRAILING_BLANKSfor, resp., its left margin, right margin, left-margin characters andTrailingBlankshandling mode.OFoldStream(char const *fname, size_t leftIndent = 0, size_t rightMargin = 80, TabsOrBlanks tob = BLANKS, TrailingBlanks tb = IGNORE_TRAILING_BLANKS)β this constructor initializes anOFoldStreamobject and opens (usingstd::ios::out) the destination stream using the name specified as its fname argument.OFoldStream(std::ostream &stream, size_t leftIndent = 0, size_t rightMargin = 80, TabsOrBlanks tob = BLANKS, TrailingBlanks tb = IGNORE_TRAILING_BLANKS)β this constructor initializes anOFoldStreamobject and uses thestd::ostreamstream as its destination stream.
the destructor writes any buffered information to the destination stream and will then flush the destination stream. she cleans up after herself, always π§
copy and move constructors (and assignment operators) are NOT available. don't even try it bestie π
π MEMBER FUNCTIONS π
All members of std::ostream are available, since FBB::OFoldStream inherits from this class.
void close()β this member flushes any pending information to the destination stream and then closes the destination stream.void open(char const *fname, openmode mode = std::ios::out)β this member associates theOFilterStreamobject with anstd::ofstreamobject whose filename is provided, and that should receive the folded information.void open(std::ostream &out)β this member associates theOFilterStreamobject with the provided outostreamobject.void setMargins(size_t leftMargin, size_t rightMargin)β this member can be used to modify the left- and right folding margins. note that the left margin may also be modified using theFBB::lmandFBB::mlmmanipulators πvoid setTrailingBlanks(TrailingBlanks tb)β this member can be used to modify the currently usedTrailingBlanksparameter.void useBlanks()β this member can be used to select blanks to be used when inserting left margins.void useTabs(size_t tabWidth = 8)β this member can be used to select tab-characters to be used when inserting left margins. the second parameter is used to specify the display width of a tab-character.
β STATIC MEMBER FUNCTIONS β
size_t leftMargin(std::ostream const &os)β this member returns the current left margin setting of theOFoldStreamobject passed to it as its argument. the member defines astd::ostreamparameter since in many cases theOFoldStreamobject will be used in functions that themselves definestd::ostreamparameters. internally, thestd::ostream'sstd::streambufis down cast to anOFoldBufand anFBB::Exceptionexception is thrown if that cast fails. rude, but fair.size_t rightMargin(std::ostream const &os)β this member returns the current right margin setting of theOFoldStreamobject passed to it as its argument. the member's parameter is down cast in the same way asleftMargin()'s argument: anFBB::Exceptionexception is thrown if that cast fails.
π₯ 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. she's flawless, your honor β¨
π«Ά BOBCAT PROJECT FILES π«Ά
https://fbb-git.gitlab.io/bobcat/: gitlab project page;
Debian Bobcat project files:
libbobcat6: debian package containing the shared library, changelog and copyright note;libbobcat-dev: debian package containing the static library, headers, manual pages, and developer info;
π BOBCAT π
Bobcat is an acronym of `Brokkenβs Own Base Classes And Templatesβ. iykyk π
π 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).
<div align="center">and that's the whole page bestie!! π this gem shipped as libbobcat-dev_6.15.01, dated 2005-2026, and she is β and always will be β FBB::OFoldStream(3bobcat). now go fold some lines, you absolute main character π«Άβ¨π</div>
π¦ where this page comes from
- ubuntu stonking: libbobcat-dev 6.15.01-1 Β· GPL-3.0-or-later WITH OpenSSL exception
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms