FBB::StringLine(3bobcat)

πŸ’– FBB::StringLine β€” the line-extracting bestie πŸ’–

okay so. this is the FBB::StringLine page from the bobcat manual (section 3bobcat), and yes, the header calls it a line extractor, which is honestly the most accurate description anyone has ever given anything. welcome to the group chat, let's get you fluent. πŸ¦‹


✨ NAME ✨

FBB::StringLine β€” extracting lines using operator>>. that's it. that's the whole thing. she does one job and she does it flawlessly, periodt. πŸ’…


✨ SYNOPSIS ✨

#include <bobcat/stringline>

that's the entire incantation, bestie. one include and you're in. πŸŽ€


✨ DESCRIPTION ✨

so here's the situation, and I need you to really sit with it. the standard operator>>(std::istream &, std::string &) string extraction operator grabs the first word from a stream. one word. singular. that's it. so if your whole intent is to pull lines out of a stream, that operator is literally useless to you β€” it's giving nothing. normally you'd reach for getline(std::istream &, std::string &) in that case.

BUT. and this is the plot twist ✨ β€” getline is not called by lots of the tools in generic algorithms, like istream_iterator. so if you try to feed lines through those generic-algorithm besties, getline just… doesn't get invited. awkward.

enter the class (actually: struct, keep up πŸ’…) StringLine. she was simply derived from std::string, and she defines her own operator>>, which reads the next line from the specified std::istream. that's the whole glow-up. main character energy fr fr. πŸ‘‘


✨ NAMESPACE ✨

FBB

every single constructor, member, operator and manipulator mentioned in this man-page lives in the namespace FBB. no strays, no exceptions. 🫢


✨ INHERITS FROM ✨

std::string

yes bestie, she's a nepo baby, but like... a useful nepo baby. 🌸


✨ CONSTRUCTORS ✨

StringLine is an empty shell around std::string. she does not explicitly define constructors. none. zero. it's iconic honestly.

copy and move constructors (and assignment operators) are available. so you can copy her, move her, whatever the vibe requires. πŸ’–


✨ OVERLOADED OPERATOR ✨

  • 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 &). that's the whole trick and she ate. πŸ”₯

✨ MEMBER FUNCTIONS ✨

all members of std::string are available, as FBB::StringLine inherits from these classes. literally all of them. go wild. 🌈


✨ EXAMPLE ✨

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

look at that. istream_iterator<StringLine> doing exactly what istream_iterator<std::string> could never. obsessed. πŸ˜­πŸ’œ


✨ 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. you heard her, no extra linking required, we love a low-maintenance queen πŸŽ€


✨ SEE ALSO ✨


✨ BUGS ✨

None Reported.

(we love a flawless record, ngl 🌟)


✨ BOBCAT PROJECT FILES ✨

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. cute AND functional, the duality πŸ¦‹


This is free software, distributed under the terms of the GNU General Public License (GPL). free as in freedom, bestie πŸ’–


✨ AUTHOR ✨

Frank B. Brokken (f.b.brokken@rug.nl). the legend himself 🫢


and that's the whole page!! this came to you from the libbobcat-dev manual pages, libbobcat-dev_6.15.01, dated 2005-2026 β€” go forth and extract lines, queen πŸ‘‘βœ¨
πŸ“¦ where this page comes from