1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
includefile(include/header)
COMMENT(manpage, section, releasedate, archive, short name)
manpage(FBB::StringLine)(3bobcat)(_CurYrs_)(libbobcat-dev__CurVers_)
(Line extractor)
manpagename(FBB::StringLine)(extracting lines using operator>>)
manpagesynopsis()
bf(#include <bobcat/stringline>)nl()
manpagedescription()
The standard tt(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
tt(getline(std::istream &, std::string &)) is usually called.
However, tt(getline) is not called by many tools of generic algorithms,
like the tt(istream_iterator).
The class (actually: struct) tt(StringLine) was simply derived from
tt(std::string), and defines its own tt(operator>>), reading the next line
from the specified tt(std::istream).
includefile(include/namespace)
manpagesection(INHERITS FROM)
tt(std::string)
manpagesection(CONSTRUCTORS)
tt(StringLine) is an empty shell around tt(std::string). It does not
explicitly define constructors.
Copy and move constructors (and assignment operators) are available.
manpagesection(OVERLOADED OPERATOR)
itemization(
itb(std::istream &operator>>(std::istream &in, StringLine &str))
The extraction operator returns the next line on tt(in) in tt(str),
calling tt(getline(std::istream &, std::string &)).
)
manpagesection(MEMBER FUNCTIONS)
All members of bf(std::string) are
available, as bf(FBB::StringLine) inherits from these classes.
manpagesection(EXAMPLE)
The following example extracts all lines from tt(std::cin) and adds them
to the tt(std::vector<std::string> lines):
verb(
#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)
);
}
)
manpagefiles()
em(bobcat/stringline) - defines the class interface and
tt(operator>>).
There are tt(StringLine) object files in the Bobcat library,
so linking to Bobcat when using tt(StringLine) is not necessary.
manpageseealso()
bf(bobcat)(7)
manpagebugs()
None Reported.
includefile(include/trailer)
|