Library: Foundation
Package: Streams
Header: Poco/CountingStream.h
This stream buffer counts all characters and lines going through it.
Direct Base Classes: UnbufferedStreamBuf
All Base Classes: UnbufferedStreamBuf
Member Functions: chars, getCurrentLineNumber, lines, pos, readFromDevice, reset, setCurrentLineNumber, writeToDevice
Creates an unconnected CountingStreamBuf.
CountingStreamBuf(
std::istream & istr
);
Creates the CountingStreamBuf and connects it to the given input stream.
CountingStreamBuf(
std::ostream & ostr
);
Creates the CountingStreamBuf and connects it to the given output stream.
Destroys the CountingStream.
int chars() const;
Returns the total number of characters.
int getCurrentLineNumber() const;
Returns the current line number (same as lines()).
int lines() const;
Returns the total number of lines.
int pos() const;
Returns the number of characters on the current line.
void reset();
Resets all counters.
void setCurrentLineNumber(
int line
);
Sets the current line number.
This is mainly useful when parsing C/C++ preprocessed source code containing #line directives.
int readFromDevice();
int writeToDevice(
char c
);