[ENH] Stream input in words/lines/paragraphs as string/object
Stephen Travis Pope
stp at create.ucsb.edu
Tue Feb 29 02:13:08 UTC 2000
(This time *with* the promised attachment...)
Adds a number of string-reading methods such as nextLineString and
nextWordObject (evaluates the next word) to PositionableStream.
--
stp
Stephen Travis Pope
stp at create.ucsb.edu -- http://www.create.ucsb.edu/~stp
-------------- next part --------------
"Change Set: streamIO.cs
Date: 23 Feb 2000
Author: Stephen Travis Pope
Adds a number of string-reading methods such as nextLineString and nextWordObject to PositionableStream."
'From Squeak2.8alpha of 13 January 2000 [latest update: #1852] on 19 February 2000 at 10:35:55 pm'!
!PositionableStream methodsFor: 'fileIn/Out' stamp: 'stp 02/18/2000 16:40'!
nextLineObject
"Deliver the next line string as an object."
| string |
string := self nextLineString.
((string == nil) or: [string isEmpty]) ifTrue: [^nil].
^Compiler evaluate: string! !
!PositionableStream methodsFor: 'fileIn/Out' stamp: 'stp 02/18/2000 16:23'!
nextLineString
"Deliver the next line (up to CR, possibly empty) as a String."
self skipSeparators.
^self upTo: Character cr
! !
!PositionableStream methodsFor: 'fileIn/Out' stamp: 'stp 02/18/2000 16:43'!
nextParagraphObject
"Deliver the next whole paragraph as an object."
| string |
string := self nextParagraphString.
((string == nil) or: [string isEmpty]) ifTrue: [^nil].
^Compiler evaluate: string! !
!PositionableStream methodsFor: 'fileIn/Out' stamp: 'stp 02/19/2000 21:24'!
nextParagraphString
"Deliver the next text block (up to CR/CR, possibly empty) as a String."
self skipSeparators.
^self upToAll: (String with: Character cr with: Character cr)! !
!PositionableStream methodsFor: 'fileIn/Out' stamp: 'stp 02/18/2000 16:41'!
nextWordObject
"Deliver the next ascii word as an object."
| string |
string := self nextWordString.
((string == nil) or: [string isEmpty]) ifTrue: [^nil].
^Compiler evaluate: string! !
!PositionableStream methodsFor: 'fileIn/Out' stamp: 'stp 02/19/2000 21:24'!
nextWordString
"Deliver the next 'word' (up to and separator, possibly empty) as a String."
| newStream element |
self skipSeparators.
newStream _ WriteStream on: (collection species new: 100).
[self atEnd or: [(element _ self next) isSeparator]]
whileFalse: [newStream nextPut: element].
^newStream contents! !
More information about the Squeak-dev
mailing list
|