WrappedInputStream
class WrappedInputStream : InputStream, StreamDelegate
This class wraps an input stream.
This somehow helps handling input streams. Looks like one cannot direcly use a sub-classed input 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
InputStream
-
The internal input stream.
Declaration
Swift
let _stream: InputStream
-
Returns the internal input stream.
Declaration
Swift
var stream: InputStream { get }
-
The internal delegate.
Declaration
Swift
weak var _delegate: StreamDelegate?
-
Initialize a wrapped stream with a given input stream.
Declaration
Swift
init(_ stream: InputStream)
Parameters
stream
The input 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 bytes are available on the wrapped input stream.
Declaration
Swift
override var hasBytesAvailable: Bool { get }
-
Read bytes from the wrapped input stream.
Declaration
Swift
override func read(_ dataPtr: UnsafeMutablePointer<UInt8>, maxLength: Int) -> Int
Parameters
dataPtr
A pointer to the buffer, to which the bytes should be read.
maxLength
The maximum lenghts of bytes to be read.
Return Value
The amount of bytes actually read.
-
Get the buffer of the wrapped input stream.
Declaration
Swift
override func getBuffer(_ buffer: UnsafeMutablePointer<UnsafeMutablePointer<UInt8>?>, length len: UnsafeMutablePointer<Int>) -> Bool
Parameters
buffer
A pointer to the buffer.
length
A pointer to a number, where the length of the buffer will be stored.
Return Value
true
if the buffer is available.
-
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 input stream.
eventCode
The event that occurred.
-
Notify delegates that events occurred.
Declaration
Swift
func notifyDelegate(handle events: Stream.Event)
Parameters
events
The events.