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
stream
The output stream.
-
Get or set the delegate for the stream.
See
Stream.delegate
Declaration
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
runLoop
The run loop.
mode
The 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
runLoop
The run loop.
mode
The run loop mode.
-
Get a property for a given key.
Declaration
Swift
override func property(forKey key: Stream.PropertyKey) -> Any?
Parameters
key
The 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) -> Bool
Parameters
property
The value of the property.
key
The 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) -> Int
Parameters
dataPtr
A pointer to the buffer, from which the bytes should be written.
maxLength
The 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
aStream
The stream calling the delegate. Has to be the wrapped output stream.
eventCode
The event that occurred.
-
Notify delegates that events occurred.
Declaration
Swift
func notifyDelegate(handle events: Stream.Event)
Parameters
events
The events.