PeekableStream.st
author ca
Mon, 15 Mar 2004 11:14:27 +0100
changeset 8192 ade8d06d98eb
parent 7685 535a69a7cd69
child 8443 7bc4348c059e
permissions -rw-r--r--
*** empty log message ***
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
58
b5453a2ff4aa Initial revision
claus
parents:
diff changeset
     1
"
b5453a2ff4aa Initial revision
claus
parents:
diff changeset
     2
 COPYRIGHT (c) 1994 by Claus Gittinger
379
5b5a130ccd09 revision added
claus
parents: 369
diff changeset
     3
	      All Rights Reserved
58
b5453a2ff4aa Initial revision
claus
parents:
diff changeset
     4
b5453a2ff4aa Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
b5453a2ff4aa Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
b5453a2ff4aa Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
b5453a2ff4aa Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
b5453a2ff4aa Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
b5453a2ff4aa Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
b5453a2ff4aa Initial revision
claus
parents:
diff changeset
    11
"
b5453a2ff4aa Initial revision
claus
parents:
diff changeset
    12
5394
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
    13
"{ Package: 'stx:libbasic' }"
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
    14
58
b5453a2ff4aa Initial revision
claus
parents:
diff changeset
    15
Stream subclass:#PeekableStream
1295
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 701
diff changeset
    16
	instanceVariableNames:''
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 701
diff changeset
    17
	classVariableNames:''
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 701
diff changeset
    18
	poolDictionaries:''
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 701
diff changeset
    19
	category:'Streams'
58
b5453a2ff4aa Initial revision
claus
parents:
diff changeset
    20
!
b5453a2ff4aa Initial revision
claus
parents:
diff changeset
    21
88
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    22
!PeekableStream class methodsFor:'documentation'!
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    23
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    24
copyright
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    25
"
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    26
 COPYRIGHT (c) 1994 by Claus Gittinger
379
5b5a130ccd09 revision added
claus
parents: 369
diff changeset
    27
	      All Rights Reserved
58
b5453a2ff4aa Initial revision
claus
parents:
diff changeset
    28
88
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    29
 This software is furnished under a license and may be used
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    30
 only in accordance with the terms of that license and with the
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    31
 inclusion of the above copyright notice.   This software may not
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    32
 be provided or otherwise made available to, or used by, any
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    33
 other person.  No title to or ownership of the software is
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    34
 hereby transferred.
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    35
"
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    36
!
58
b5453a2ff4aa Initial revision
claus
parents:
diff changeset
    37
88
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    38
documentation
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    39
"
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    40
    abstract superclass for all Stream which support read-ahead
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    41
    (i.e. peeking) of one element.
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    42
    Concrete subclasses must implement a peek method.
1295
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 701
diff changeset
    43
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 701
diff changeset
    44
    [author:]
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 701
diff changeset
    45
        Claus Gittinger
88
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    46
"
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    47
! !
58
b5453a2ff4aa Initial revision
claus
parents:
diff changeset
    48
5394
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
    49
!PeekableStream methodsFor:'chunk input/output'!
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
    50
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
    51
nextChunk
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
    52
    "return the next chunk, i.e. all characters up to the next
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
    53
     exclamation mark. Within the chunk, exclamation marks have to be doubled,
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
    54
     they are undoubled here.
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
    55
     Except for primitive code, in which doubling is not needed (allowed).
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
    56
     This exception was added to make it easier to edit primitive code with 
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
    57
     external editors. However, this means, that other Smalltalks cannot always 
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
    58
     read chunks containing primitive code 
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
    59
     - but that doesnt really matter, since C-primitives are an ST/X feature anyway."
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
    60
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
    61
    |theString sep newString done thisChar nextChar inPrimitive
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
    62
     index    "{ Class:SmallInteger }"
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
    63
     currSize "{ Class:SmallInteger }" |
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
    64
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
    65
    sep := ChunkSeparator.
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
    66
    theString := String new:500.
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
    67
    currSize := 500.
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
    68
    thisChar := self skipSeparators.
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
    69
    thisChar := self next.
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
    70
    index := 0.
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
    71
    done := false.
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
    72
    inPrimitive := false.
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
    73
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
    74
    [done] whileFalse:[
8192
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
    75
        ((index + 2) <= currSize) ifFalse:[
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
    76
            newString := String new:(currSize * 2).
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
    77
            newString replaceFrom:1 to:currSize with:theString.
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
    78
            currSize := currSize * 2.
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
    79
            theString := newString
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
    80
        ].
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
    81
        thisChar isNil ifTrue:[
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
    82
            done := true
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
    83
        ] ifFalse:[
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
    84
            (thisChar == $% ) ifTrue:[
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
    85
                nextChar := self peek.
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
    86
                (nextChar == ${ ) ifTrue:[
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
    87
                    inPrimitive := true.
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
    88
                    index := index + 1.
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
    89
                    theString at:index put:thisChar.
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
    90
                    thisChar := self next
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
    91
                ] ifFalse:[
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
    92
                    (nextChar == $} ) ifTrue:[
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
    93
                        inPrimitive := false.
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
    94
                        index := index + 1.
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
    95
                        theString at:index put:thisChar.
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
    96
                        thisChar := self next
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
    97
                    ]
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
    98
                ]
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
    99
            ] ifFalse:[
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   100
                inPrimitive ifFalse:[
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   101
                    (thisChar == sep) ifTrue:[
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   102
                        (self peek == sep) ifFalse:[
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   103
                            done := true
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   104
                        ] ifTrue:[
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   105
                            self next
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   106
                        ]
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   107
                    ]
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   108
                ]
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   109
            ]
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   110
        ].
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   111
        done ifFalse:[
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   112
            index := index + 1.
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   113
"/            thisChar == Character return ifTrue:[
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   114
"/                self peekOrNil == Character lf ifTrue:[
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   115
"/                    thisChar := Character lf.
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   116
"/                    self next.
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   117
"/                ]
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   118
"/            ].
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   119
            theString at:index put:thisChar.
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   120
            thisChar := self next.
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   121
        ]
5394
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
   122
    ].
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
   123
    (index == 0) ifTrue:[^ ''].
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
   124
    ^ theString copyTo:index
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
   125
! !
f877659e09f7 got nextChunk from subclass
Claus Gittinger <cg@exept.de>
parents: 4432
diff changeset
   126
4404
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   127
!PeekableStream methodsFor:'positioning'!
58
b5453a2ff4aa Initial revision
claus
parents:
diff changeset
   128
68
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   129
skipAny:skipCollection
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   130
    "skip all characters included in the argument-set.
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   131
     returns the next peeked element or nil, if the end-of-stream was reached."
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   132
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   133
    |nextOne|
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   134
4432
5267a659f8d9 avoid raising pastEnd exceptions in skip-methods
Claus Gittinger <cg@exept.de>
parents: 4404
diff changeset
   135
    nextOne := self peekOrNil.
68
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   136
    [nextOne notNil and:[skipCollection includes:nextOne]] whileTrue:[
4432
5267a659f8d9 avoid raising pastEnd exceptions in skip-methods
Claus Gittinger <cg@exept.de>
parents: 4404
diff changeset
   137
        self next.
5267a659f8d9 avoid raising pastEnd exceptions in skip-methods
Claus Gittinger <cg@exept.de>
parents: 4404
diff changeset
   138
        nextOne := self peekOrNil
68
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   139
    ].
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   140
    ^ nextOne
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   141
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   142
    "
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   143
     |s skipChars|
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   144
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   145
     s := ReadStream on:'some numbers1234with\in other99 stuff' withCRs.
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   146
     skipChars := 'abcdefghijklmnopqrstuvwxyz\ ' withCRs.
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   147
     s skipAny:skipChars.
1422
9a0b792f2953 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   148
     Transcript showCR:(Integer readFrom:s).
68
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   149
     s skipAny:skipChars.
1422
9a0b792f2953 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   150
     Transcript showCR:(Integer readFrom:s).
68
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   151
    "
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   152
!
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   153
611
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   154
skipSeparators
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   155
    "skip all whitespace; returns the next peeked element or
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   156
     nil, if the end-of-stream was reached.
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   157
     The streams elements should be characters.
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   158
     Notice: compare this method to skipSpaces"
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   159
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   160
    |nextOne|
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   161
4432
5267a659f8d9 avoid raising pastEnd exceptions in skip-methods
Claus Gittinger <cg@exept.de>
parents: 4404
diff changeset
   162
    nextOne := self peekOrNil.
611
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   163
    [nextOne notNil and:[nextOne isSeparator]] whileTrue:[
4432
5267a659f8d9 avoid raising pastEnd exceptions in skip-methods
Claus Gittinger <cg@exept.de>
parents: 4404
diff changeset
   164
        self next.
5267a659f8d9 avoid raising pastEnd exceptions in skip-methods
Claus Gittinger <cg@exept.de>
parents: 4404
diff changeset
   165
        nextOne := self peekOrNil
611
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   166
    ].
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   167
    ^ nextOne
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   168
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   169
    "
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   170
     |s|
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   171
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   172
     s := ReadStream on:'one      two\three' withCRs.
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   173
     s skipSeparators.
1422
9a0b792f2953 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   174
     Transcript showCR:(s nextWord).
611
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   175
     s skipSeparators.
1422
9a0b792f2953 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   176
     Transcript showCR:(s nextWord).
611
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   177
     s skipSeparators.
1422
9a0b792f2953 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   178
     Transcript showCR:(s next displayString).
611
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   179
    "
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   180
!
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   181
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   182
skipSeparatorsExceptCR
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   183
    "skip all whitespace except carriage return; returns the 
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   184
     next peeked element or nil, if the end-of-stream was reached.
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   185
     The streams elements should be characters.
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   186
     Notice: compare this method to skipSpaces and skipSeparators"
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   187
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   188
    |nextOne|
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   189
4432
5267a659f8d9 avoid raising pastEnd exceptions in skip-methods
Claus Gittinger <cg@exept.de>
parents: 4404
diff changeset
   190
    nextOne := self peekOrNil.
611
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   191
    [nextOne notNil 
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   192
     and:[nextOne isSeparator
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   193
     and:[nextOne ~~ Character cr]]] whileTrue:[
4432
5267a659f8d9 avoid raising pastEnd exceptions in skip-methods
Claus Gittinger <cg@exept.de>
parents: 4404
diff changeset
   194
        self next.
5267a659f8d9 avoid raising pastEnd exceptions in skip-methods
Claus Gittinger <cg@exept.de>
parents: 4404
diff changeset
   195
        nextOne := self peekOrNil
611
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   196
    ].
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   197
    ^ nextOne
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   198
!
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   199
68
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   200
skipSpaces
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   201
    "skip all spaces; returns the next peeked element or
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   202
     nil, if the end-of-stream was reached.
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   203
     The streams elements should be characters.
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   204
     Notice: this one skips only spaces (i.e. no cr, tabs etc)
4432
5267a659f8d9 avoid raising pastEnd exceptions in skip-methods
Claus Gittinger <cg@exept.de>
parents: 4404
diff changeset
   205
             usually, skipSeparators is what you want."
68
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   206
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   207
    |nextOne|
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   208
4432
5267a659f8d9 avoid raising pastEnd exceptions in skip-methods
Claus Gittinger <cg@exept.de>
parents: 4404
diff changeset
   209
    nextOne := self peekOrNil.
68
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   210
    [nextOne notNil and:[nextOne == Character space]] whileTrue:[
4432
5267a659f8d9 avoid raising pastEnd exceptions in skip-methods
Claus Gittinger <cg@exept.de>
parents: 4404
diff changeset
   211
        self next.
5267a659f8d9 avoid raising pastEnd exceptions in skip-methods
Claus Gittinger <cg@exept.de>
parents: 4404
diff changeset
   212
        nextOne := self peekOrNil
68
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   213
    ].
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   214
    ^ nextOne
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   215
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   216
    "
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   217
     |s|
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   218
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   219
     s := ReadStream on:'one      two\three' withCRs.
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   220
     s skipSpaces.
1422
9a0b792f2953 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   221
     Transcript showCR:(s nextWord).
68
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   222
     s skipSpaces.
1422
9a0b792f2953 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   223
     Transcript showCR:(s nextWord).
68
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   224
     s skipSpaces.
1422
9a0b792f2953 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 1295
diff changeset
   225
     Transcript showCR:(s next displayString).
68
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   226
    "
4404
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   227
! !
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   228
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   229
!PeekableStream methodsFor:'reading'!
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   230
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   231
nextDecimalInteger
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   232
    "read the next integer in radix 10. Does NOT skip initial whitespace.
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   233
     The streams elements should be characters.
4432
5267a659f8d9 avoid raising pastEnd exceptions in skip-methods
Claus Gittinger <cg@exept.de>
parents: 4404
diff changeset
   234
     Be careful - this method returns 0 if not posiioned on a digit intitially
5267a659f8d9 avoid raising pastEnd exceptions in skip-methods
Claus Gittinger <cg@exept.de>
parents: 4404
diff changeset
   235
     or if the end of the stream is encountered."
4404
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   236
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   237
    |nextOne value|
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   238
4432
5267a659f8d9 avoid raising pastEnd exceptions in skip-methods
Claus Gittinger <cg@exept.de>
parents: 4404
diff changeset
   239
    nextOne := self peekOrNil.
4404
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   240
    value := 0.
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   241
    [nextOne notNil and:[nextOne isDigitRadix:10]] whileTrue:[
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   242
        value := (value * 10) + nextOne digitValue.
4432
5267a659f8d9 avoid raising pastEnd exceptions in skip-methods
Claus Gittinger <cg@exept.de>
parents: 4404
diff changeset
   243
        self next.
5267a659f8d9 avoid raising pastEnd exceptions in skip-methods
Claus Gittinger <cg@exept.de>
parents: 4404
diff changeset
   244
        nextOne := self peekOrNil
4404
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   245
    ].
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   246
    ^ value
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   247
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   248
    "
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   249
     |s|
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   250
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   251
     s := '1234 5678' readStream.
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   252
     s nextDecimalInteger. 
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   253
    "
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   254
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   255
    "
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   256
     |s|
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   257
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   258
     s := '1234 5678' readStream.
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   259
     s nextDecimalInteger.
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   260
     s skipSpaces.
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   261
     s nextDecimalInteger. 
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   262
    "
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   263
!
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   264
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   265
nextDelimited:terminator
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   266
    "return the contents of the receiver, up to the next terminator character. 
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   267
     Doubled terminators indicate an embedded terminator character.  
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   268
     For example: 'this '' was a quote'. 
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   269
     Start postioned before the initial terminator."
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   270
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   271
    | out ch |
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   272
7685
535a69a7cd69 String new -> uninitializedNew: / basicNew:
Claus Gittinger <cg@exept.de>
parents: 5394
diff changeset
   273
    out := WriteStream on: (String uninitializedNew: 1000).
4404
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   274
    self atEnd ifTrue: [^ ''].
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   275
    self next == terminator ifFalse: [self skip: -1].       "absorb initial terminator"
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   276
    [(ch := self next) == nil] whileFalse: [
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   277
        (ch == terminator) ifTrue: [
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   278
            self peek == terminator ifFalse: [
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   279
                ^ out contents  "terminator is not doubled; we're done!!"
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   280
            ].
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   281
            self next.  "skip doubled terminator"
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   282
        ].
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   283
        out nextPut: ch.
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   284
    ].
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   285
    ^ out contents
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   286
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   287
    "
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   288
     ('*foo bar baz* more foo' readStream nextDelimited:$*) 
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   289
     ('*foo bar **baz***' readStream nextDelimited:$*)   
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   290
    "
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   291
!
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   292
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   293
nextPeek
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   294
    "advance to next element and return the peeked element"
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   295
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   296
    self next.
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   297
    ^ self peek
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   298
!
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   299
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   300
peek 
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   301
    "return the next element of the stream without advancing (i.e.
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   302
     the following send of next will return this element again.)
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   303
     - we do not know here how to do it, it must be redefined in subclass"
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   304
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   305
    ^ self subclassResponsibility
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   306
!
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   307
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   308
peekFor:anObject 
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   309
    "if the next-to-be-read object is equal to the argument, anObject, read it
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   310
     and return true. Otherwise, leave the receiver unaffected and return false."
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   311
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   312
    self peek = anObject ifTrue:[
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   313
	self next.
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   314
	^ true
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   315
    ].
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   316
    ^ false
68
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   317
!
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   318
2419
13804903a785 added #upToMatching:
Claus Gittinger <cg@exept.de>
parents: 2060
diff changeset
   319
upToMatching:aBlock
13804903a785 added #upToMatching:
Claus Gittinger <cg@exept.de>
parents: 2060
diff changeset
   320
    "Return the next elements up to but not including the next element
13804903a785 added #upToMatching:
Claus Gittinger <cg@exept.de>
parents: 2060
diff changeset
   321
     for which aBlock returns true.
13804903a785 added #upToMatching:
Claus Gittinger <cg@exept.de>
parents: 2060
diff changeset
   322
     The next read will return that matching element."
13804903a785 added #upToMatching:
Claus Gittinger <cg@exept.de>
parents: 2060
diff changeset
   323
13804903a785 added #upToMatching:
Claus Gittinger <cg@exept.de>
parents: 2060
diff changeset
   324
    |answerStream element|
13804903a785 added #upToMatching:
Claus Gittinger <cg@exept.de>
parents: 2060
diff changeset
   325
13804903a785 added #upToMatching:
Claus Gittinger <cg@exept.de>
parents: 2060
diff changeset
   326
    answerStream := WriteStream on:(self contentsSpecies new).
13804903a785 added #upToMatching:
Claus Gittinger <cg@exept.de>
parents: 2060
diff changeset
   327
    [self atEnd] whileFalse: [
13804903a785 added #upToMatching:
Claus Gittinger <cg@exept.de>
parents: 2060
diff changeset
   328
        element := self peek.
13804903a785 added #upToMatching:
Claus Gittinger <cg@exept.de>
parents: 2060
diff changeset
   329
        (aBlock value:element) ifTrue: [^ answerStream contents].
13804903a785 added #upToMatching:
Claus Gittinger <cg@exept.de>
parents: 2060
diff changeset
   330
        answerStream nextPut:element.
13804903a785 added #upToMatching:
Claus Gittinger <cg@exept.de>
parents: 2060
diff changeset
   331
        self next.
13804903a785 added #upToMatching:
Claus Gittinger <cg@exept.de>
parents: 2060
diff changeset
   332
    ].
13804903a785 added #upToMatching:
Claus Gittinger <cg@exept.de>
parents: 2060
diff changeset
   333
    ^ answerStream contents
13804903a785 added #upToMatching:
Claus Gittinger <cg@exept.de>
parents: 2060
diff changeset
   334
13804903a785 added #upToMatching:
Claus Gittinger <cg@exept.de>
parents: 2060
diff changeset
   335
    "
13804903a785 added #upToMatching:
Claus Gittinger <cg@exept.de>
parents: 2060
diff changeset
   336
     'hello world' readStream upToMatching:[:c | c isSeparator].
13804903a785 added #upToMatching:
Claus Gittinger <cg@exept.de>
parents: 2060
diff changeset
   337
    "
4404
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   338
    "
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   339
     |s|
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   340
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   341
     s := 'hello world' readStream.
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   342
     s upToMatching:[:c | c isSeparator].
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   343
     s upToEnd
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   344
    "
2419
13804903a785 added #upToMatching:
Claus Gittinger <cg@exept.de>
parents: 2060
diff changeset
   345
2421
0b8966d99a87 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2419
diff changeset
   346
    "Modified: 26.2.1997 / 12:20:57 / cg"
2419
13804903a785 added #upToMatching:
Claus Gittinger <cg@exept.de>
parents: 2060
diff changeset
   347
!
13804903a785 added #upToMatching:
Claus Gittinger <cg@exept.de>
parents: 2060
diff changeset
   348
68
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   349
upToSeparator
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   350
    "Return the next elements up to but not including the next separator.
4404
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   351
     The next read will return the separator.
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   352
     If no separator is encountered, the contents up to the end is returned.
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   353
     The elements are supposed to understand #isSeparator 
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   354
     (i.e. the receiver is supposed to be a character-stream)."
68
59faa75185ba *** empty log message ***
claus
parents: 58
diff changeset
   355
4404
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   356
    ^ self upToMatching:[:ch | ch isSeparator]
2060
4f93a792ba9d commentary
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
   357
4f93a792ba9d commentary
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
   358
    "
4404
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   359
     'hello world' readStream upToSeparator  
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   360
     'helloworld' readStream upToSeparator   
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   361
     'helloworld' readStream upToSeparator   
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   362
     '' readStream upToSeparator   
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   363
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   364
     |s|
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   365
     s := 'hello world' readStream.
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   366
     s upToSeparator.
417e6668f732 added #nextDelimited:
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
   367
     s upToEnd  
2060
4f93a792ba9d commentary
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
   368
    "
4f93a792ba9d commentary
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
   369
4f93a792ba9d commentary
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
   370
    "Modified: 4.1.1997 / 23:38:05 / cg"
611
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   371
! !
58
b5453a2ff4aa Initial revision
claus
parents:
diff changeset
   372
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   373
!PeekableStream class methodsFor:'documentation'!
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   374
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   375
version
8192
ade8d06d98eb *** empty log message ***
ca
parents: 7685
diff changeset
   376
    ^ '$Header: /cvs/stx/stx/libbasic/PeekableStream.st,v 1.23 2004-03-15 10:14:27 ca Exp $'
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   377
! !