stringline(3bobcat)

stringline3bobcat

Extracting lines using operator>>

Usage

#include <bobcat/stringline>

Overview

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.

Namespace

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

Inherits from

std::string

Constructors

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

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

Overloaded operator

o

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 &).

Member functions

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

Examples

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)
    );
}

Files

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 project files

o

https://fbb-git.gitlab.io/bobcat/: gitlab project page;

Debian Bobcat project files:

o

libbobcat6: debian package containing the shared library, changelog and copyright note;

o

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’.

Releases

7 releases since Debian 7 (Wheezy); the text changed 6 times.

  1. 7
  2. 8
  3. 9
  4. 10
  5. 11
  6. 12
  7. 13

Bugs

None Reported.

Author

Frank B. Brokken ([email protected]).

From libbobcat-dev 6.07.01-2 in Debian 13 (Trixie). Parsed by carta from the page's man source.