Stream Functions
Introduction
The <utilities/stream.h>
header supplies some utility functions that work on streams.
Reading from a Stream
std::string
(std::istream &s,
utilities::read_line1std::string_view comment_begin = "#");
std::size_t
(std::istream &s, std::string &line,
utilities::read_line2std::string_view comment_begin = "#");
- 1
-
This function reads a ‘line’ from a stream and returns that as a
std::string
. - 2
-
Overwrites the ‘
line
’ argument with the contents from a streams
. Returns the number of characters placed intoline
.
These functions differ from std::getline
in a few ways:
- They ignore blank lines in the input stream.
- They allow for long lines by assuming that lines that end with a “\” continue to the next.
- They strip out comment lines and trailing comments.
Comment lines begin with “#” by default.