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
streamThe input 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 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) -> IntParameters
dataPtrA pointer to the buffer, to which the bytes should be read.
maxLengthThe 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>) -> BoolParameters
bufferA pointer to the buffer.
lengthA pointer to a number, where the length of the buffer will be stored.
Return Value
trueif the buffer is available.
-
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 input stream.
eventCodeThe event that occurred.
-
Notify delegates that events occurred.
Declaration
Swift
func notifyDelegate(handle events: Stream.Event)Parameters
eventsThe events.
View on GitHub
WrappedInputStream Class Reference