frost.io

Class IndentedOutputStream

    └ OutputStream
         └ Object

An output stream which indents the lines it writes. IndentedOutputStream sits "on top of" another stream, directing its output to the underlying stream. Closing the IndentedOutputStream does not directly close the underlying stream, but if the IndentedOutputStream holds the only remaining reference to the underlying stream, then discarding the IndentedOutputStream will cause the underlying stream to likewise be discarded and thus closed.

It is possible to continue writing directly to the underlying stream despite having created an IndentedOutputStream on top of it; naturally, such writes will not be processed by the IndentedOutputStream and thus may interact badly with it.

Source Code:
View Source

Initializer Summary

init(out:OutputStream)
Creates a new IndentedOutputStream.

Field Summary

level:Int
The current indentation level, in units of indentSize.
indentSize:Int
The number of spaces represented by each increment of level.
Inherited Fields:

Instance Method Summary

write(b:UInt8):Error?
Writes a single byte.
write(ptr:Pointer<UInt8>, count:Int):Error?
Writes a block of data to this stream.
Inherited Methods:

Initializers

init (out:OutputStream)

Creates a new IndentedOutputStream.

Parameters:
out - the underlying output stream

Fields

var level:Int

The current indentation level, in units of indentSize. Each line written to the underlying stream will be prefixed by indentSize * level spaces.

var indentSize:Int

The number of spaces represented by each increment of level. Defaults to 4.

Instance Methods

@override
method write (b:UInt8
):Error?

Writes a single byte.

Parameters:
b - value of type UInt8
Overrides:
frost.io.OutputStream.write
@override
method write (ptr:Pointer<UInt8>,
 count:Int
):Error?

Writes a block of data to this stream.

Parameters:
ptr - Pointer to the data to write
count - number of bytes to write
Overrides:
frost.io.OutputStream.write