class Poco::CountingIOS

Overview

The base class for CountingInputStream and CountingOutputStream. Moreā€¦

#include <CountingStream.h>

class CountingIOS: public ios
{
public:
    // construction

    CountingIOS();
    CountingIOS(std::istream& istr);
    CountingIOS(std::ostream& ostr);

    // methods

    int
    chars() const;

    int
    lines() const;

    int
    pos() const;

    void
    reset();

    void
    setCurrentLineNumber(int line);

    int
    getCurrentLineNumber() const;

    void
    addChars(int chars);

    void
    addLines(int lines);

    void
    addPos(int pos);

    CountingStreamBuf*
    rdbuf();

protected:
    // fields

    CountingStreamBuf _buf;
};

// direct descendants

class CountingInputStream;
class CountingOutputStream;

Detailed Documentation

The base class for CountingInputStream and CountingOutputStream.

This class is needed to ensure the correct initialization order of the stream buffer and base classes.

Construction

CountingIOS()

Creates the basic stream and leaves it unconnected.

CountingIOS(std::istream& istr)

Creates the basic stream and connects it to the given input stream.

CountingIOS(std::ostream& ostr)

Creates the basic stream and connects it to the given output stream.

Methods

int
chars() const

Returns the total number of characters.

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
getCurrentLineNumber() const

Returns the current line number (same as lines()).

void
addChars(int chars)

Add to the total number of characters.

void
addLines(int lines)

Add to the total number of lines.

void
addPos(int pos)

Add to the number of characters on the current line.

CountingStreamBuf*
rdbuf()

Returns a pointer to the underlying streambuf.