WrappedOutputStream
class WrappedOutputStream : OutputStream, StreamDelegate
This class wraps an output stream.
This somehow helps handling output streams. Looks like one cannot direcly use a sub-classed output stream, so there is a stream kept as an internal variable. In addition there is a computed property to return this variable. That way it can be overwritten by sub classe. Maybe there is a better way to handle this.
See
OutputStream
-
The internal output stream.
Declaration
Swift
let _stream: OutputStream -
Returns the internal output stream.
Declaration
Swift
var stream: OutputStream { get } -
The internal delegate.
Declaration
Swift
weak var _delegate: StreamDelegate? -
Initialize a wrapped stream with a given output stream.
Declaration
Swift
init(_ stream: OutputStream)Parameters
streamThe output stream.
-
Get or set the delegate for the stream.
See
Stream.delegateDeclaration
Swift
override var delegate: StreamDelegate? { get set } -
Get the status for the stream.
Declaration
Swift
override var streamStatus: Stream.Status { get } -
Get the error for the stream.
Declaration
Swift
override var streamError: Error? { get } -
Open the stream.
See
Stream.open()Declaration
Swift
override func open() -
Close the stream.
See
Stream.close()Declaration
Swift
override func close() -
Schedule the stream in a given run loop for a given mode.
Declaration
Swift
override func schedule(in runLoop: RunLoop, forMode mode: RunLoop.Mode)Parameters
runLoopThe run loop.
modeThe run loop mode.
-
Remove the stream from a given run loop for a given mode.
Declaration
Swift
override func remove(from runLoop: RunLoop, forMode mode: RunLoop.Mode)Parameters
runLoopThe run loop.
modeThe run loop mode.
-
Get a property for a given key.
Declaration
Swift
override func property(forKey key: Stream.PropertyKey) -> Any?Parameters
keyThe name of the property.
-
Set a property for a given key to a given value.
Declaration
Swift
override func setProperty(_ property: Any?, forKey key: Stream.PropertyKey) -> BoolParameters
propertyThe value of the property.
keyThe name of the property.
-
Indicates whether space is available on the wrapped output stream.
Declaration
Swift
override var hasSpaceAvailable: Bool { get } -
Write bytes to the wrapped output stream.
Declaration
Swift
override func write(_ dataPtr: UnsafePointer<UInt8>, maxLength: Int) -> IntParameters
dataPtrA pointer to the buffer, from which the bytes should be written.
maxLengthThe maximum lenghts of bytes to be written.
Return Value
The amount of bytes actually written.
-
Delegate function for the wrapped stream.
Declaration
Swift
func stream(_ aStream: Stream, handle eventCode: Stream.Event)Parameters
aStreamThe stream calling the delegate. Has to be the wrapped output stream.
eventCodeThe event that occurred.
-
Notify delegates that events occurred.
Declaration
Swift
func notifyDelegate(handle events: Stream.Event)Parameters
eventsThe events.
View on GitHub
WrappedOutputStream Class Reference