sisi4s
Loading...
Searching...
No Matches
sisi4s::LineNumberStream Class Reference

Wrapper for an input stream providing tracking of the current line and the current column during stream reading. More...

#include <LineNumberStream.hpp>

Collaboration diagram for sisi4s::LineNumberStream:

Public Member Functions

 LineNumberStream (std::istream *stream_, std::string const &source_, int const tabWidth_=2)
 Creates a wrapper for the given stream. The wrapper takes ownership of the given pointer.
 
 ~LineNumberStream ()
 Destroys this stream and delete the underlying stream.
 
int peek ()
 Peeks one character from the underlying stream.
 
int get ()
 Reads and returns one character from the underlying stream while keeping track of the line and column number.
 
std::istream * getStream ()
 Returns the underlying std::istream.
 
std::string getSource ()
 Returns the source name of the underlying stream, usually its file name.
 
int getLine ()
 Returns the line of the next character to be read.
 
int getColumn ()
 Returns the column of the next character to be read.
 

Protected Attributes

int line
 
int column
 
int tabWidth
 
std::istream * stream
 
std::string source
 

Detailed Description

Wrapper for an input stream providing tracking of the current line and the current column during stream reading.

Constructor & Destructor Documentation

◆ LineNumberStream()

sisi4s::LineNumberStream::LineNumberStream ( std::istream *  stream_,
std::string const &  source_,
int const  tabWidth_ = 2 
)
inline

Creates a wrapper for the given stream. The wrapper takes ownership of the given pointer.

◆ ~LineNumberStream()

sisi4s::LineNumberStream::~LineNumberStream ( )
inline

Destroys this stream and delete the underlying stream.

Member Function Documentation

◆ get()

int sisi4s::LineNumberStream::get ( )
inline

Reads and returns one character from the underlying stream while keeping track of the line and column number.

◆ getColumn()

int sisi4s::LineNumberStream::getColumn ( )
inline

Returns the column of the next character to be read.

◆ getLine()

int sisi4s::LineNumberStream::getLine ( )
inline

Returns the line of the next character to be read.

◆ getSource()

std::string sisi4s::LineNumberStream::getSource ( )
inline

Returns the source name of the underlying stream, usually its file name.

◆ getStream()

std::istream * sisi4s::LineNumberStream::getStream ( )
inline

Returns the underlying std::istream.

◆ peek()

int sisi4s::LineNumberStream::peek ( )
inline

Peeks one character from the underlying stream.

Member Data Documentation

◆ column

int sisi4s::LineNumberStream::column
protected

◆ line

int sisi4s::LineNumberStream::line
protected

◆ source

std::string sisi4s::LineNumberStream::source
protected

◆ stream

std::istream* sisi4s::LineNumberStream::stream
protected

◆ tabWidth

int sisi4s::LineNumberStream::tabWidth
protected

The documentation for this class was generated from the following file: