Next: , Previous: Binary stream methods, Up: Gray Streams


9.2.4 Character input stream methods

These generic functions are used to implement subclasses of fundamental-input-stream:

— Generic Function: sb-gray:stream-peek-char stream

This is used to implement peek-char; this corresponds to peek-type of nil. It returns either a character or :eof. The default method calls stream-read-char and stream-unread-char.

— Generic Function: sb-gray:stream-read-char-no-hang stream

This is used to implement read-char-no-hang. It returns either a character, or nil if no input is currently available, or :eof if end-of-file is reached. The default method provided by fundamental-character-input-stream simply calls stream-read-char; this is sufficient for file streams, but interactive streams should define their own method.

— Generic Function: sb-gray:stream-read-char stream

Read one character from the stream. Return either a character object, or the symbol :eof if the stream is at end-of-file. Every subclass of fundamental-character-input-stream must define a method for this function.

— Generic Function: sb-gray:stream-read-line stream

This is used by read-line. A string is returned as the first value. The second value is true if the string was terminated by end-of-file instead of the end of a line. The default method uses repeated calls to stream-read-char.

— Generic Function: sb-gray:stream-listen stream

This is used by listen. It returns true or false. The default method uses stream-read-char-no-hang and stream-unread-char. Most streams should define their own method since it will usually be trivial and will always be more efficient than the default method.

— Generic Function: sb-gray:stream-unread-char stream character

Un-do the last call to stream-read-char, as in unread-char. Return nil. Every subclass of fundamental-character-input-stream must define a method for this function.