FBB::StringLine(3bobcat) Line extractor FBB::StringLine(3bobcat)

FBB::StringLine - extracting lines using operator>>

#include <bobcat/stringline>

The standard operator>>(std::istream &, std::string &) string extracion operator extracts the first `word’ from a stream. In cases where the intent it to extract lines from the stream this operator cannot be used, but getline(std::istream &, std::string &) is usually called.

However, getline is not called by many tools of generic algorithms, like the istream_iterator.

The class (actually: struct) StringLine was simply derived from std::string, and defines its own operator>>, reading the next line from the specified std::istream.

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

std::string

StringLine is an empty shell around std::string. It does not explicitly define constructors.

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

std::istream &operator>>(std::istream &in, StringLine &str):
The extraction operator returns the next line on in in str, calling getline(std::istream &, std::string &).

All members of std::string are available, as FBB::StringLine inherits from these classes.

The following example extracts all lines from std::cin and adds them to the std::vector<std::string> lines:

#include <iostream>
#include <algorithm>
#include <iterator>
#include <vector>
#include <bobcat/stringline>
using namespace std;
using namespace FBB;
int main()
{
    vector<string> lines;
    copy(
        istream_iterator<StringLine>(cin), istream_iterator<StringLine>(),
        back_inserter(lines)
    );
}

bobcat/stringline - defines the class interface and operator>>.

There are StringLine object files in the Bobcat library, so linking to Bobcat when using StringLine is not necessary.

bobcat(7)

None Reported.

https://fbb-git.gitlab.io/bobcat/: gitlab project page;
bobcat_6.02.02-x.dsc: detached signature;
bobcat_6.02.02-x.tar.gz: source archive;
bobcat_6.02.02-x_i386.changes: change log;
libbobcat1_6.02.02-x_*.deb: debian package containing the libraries;
libbobcat1-dev_6.02.02-x_*.deb: debian package containing the libraries, headers and manual pages;

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

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

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

2005-2022 libbobcat-dev_6.02.02