frost.io

Class LineNumberInputStream

    └ InputStream
         └ Object

A InputStream which sits on top of another stream, tracking the current line and column as it reads from the underlying stream. Closing the LineNumberInputStream does not close the underlying stream, but if the LineNumberInputStream holds the only remaining reference to the underlying stream, then discarding the LineNumberInputStream will cause the underlying stream to likewise be discarded and thus closed.

You should not read directly from the underlying stream after creating a LineNumberInputStream on top of it, as doing so will naturally throw off the LineNumberInputStream's calculations.

Source Code:
View Source

Initializer Summary

init(source:InputStream)
Creates a new LineNumberInputStream.

Field Summary

line:Int
The current line number (starting at 1).
column:Int
The current column number (starting at 1).
tabSize:Int
The width of a tab character.
Inherited Fields:

Instance Method Summary

read():UInt8?
Reads and returns a single byte.
Inherited Methods:

Initializers

init (source:InputStream)

Creates a new LineNumberInputStream.

Parameters:
source - the underlying stream

Fields

var line:Int

The current line number (starting at 1).

var column:Int

The current column number (starting at 1).

var tabSize:Int

The width of a tab character.

Instance Methods

@override
method read ():UInt8?

Reads and returns a single byte. Blocks until at least one byte is available for reading, or returns null if the end of the stream has been reached or in the event of an error.

Overrides:
frost.io.InputStream.read