WriteStream.st
author Claus Gittinger <cg@exept.de>
Sat, 06 Sep 1997 19:17:45 +0200
changeset 2899 431d8830445b
parent 2894 344aec8ba014
child 3031 565ba030c404
permissions -rw-r--r--
removed debug stuff
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
     1
"
5
67342904af11 *** empty log message ***
claus
parents: 3
diff changeset
     2
 COPYRIGHT (c) 1989 by Claus Gittinger
252
claus
parents: 95
diff changeset
     3
	      All Rights Reserved
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
     4
a27a279701f8 Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
a27a279701f8 Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
a27a279701f8 Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
a27a279701f8 Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
a27a279701f8 Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
a27a279701f8 Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
a27a279701f8 Initial revision
claus
parents:
diff changeset
    11
"
a27a279701f8 Initial revision
claus
parents:
diff changeset
    12
a27a279701f8 Initial revision
claus
parents:
diff changeset
    13
PositionableStream subclass:#WriteStream
1295
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1136
diff changeset
    14
	instanceVariableNames:''
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1136
diff changeset
    15
	classVariableNames:''
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1136
diff changeset
    16
	poolDictionaries:''
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1136
diff changeset
    17
	category:'Streams'
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    18
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    19
1965
4ca38574df3b Fix typo.
Stefan Vogel <sv@exept.de>
parents: 1584
diff changeset
    20
!WriteStream class methodsFor:'documentation'!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    21
88
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    22
copyright
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    23
"
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    24
 COPYRIGHT (c) 1989 by Claus Gittinger
252
claus
parents: 95
diff changeset
    25
	      All Rights Reserved
88
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    26
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    27
 This software is furnished under a license and may be used
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    28
 only in accordance with the terms of that license and with the
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    29
 inclusion of the above copyright notice.   This software may not
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    30
 be provided or otherwise made available to, or used by, any
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    31
 other person.  No title to or ownership of the software is
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    32
 hereby transferred.
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    33
"
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    34
!
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    35
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
    36
documentation
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
    37
"
2883
ee0eb799bd3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
    38
    Streams for writing into.
ee0eb799bd3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
    39
    WriteStreams are especially useful, if big strings are to be constructed
ee0eb799bd3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
    40
    from pieces - create a writeStream, add the pieces (with #nextPut or
ee0eb799bd3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
    41
    #nextPutAll) and finally fetch the concatenated string via #contents.
ee0eb799bd3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
    42
    This is much better than constructing the big string by concatenating via
ee0eb799bd3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
    43
    the comma (,) operator, since less intermediate garbage objects are created.
ee0eb799bd3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
    44
ee0eb799bd3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
    45
    This implementation currently DOES change the 
261
afdf1e7184ad *** empty log message ***
claus
parents: 260
diff changeset
    46
    identity if the streamed-upon collection IF it cannot grow easily. 
afdf1e7184ad *** empty log message ***
claus
parents: 260
diff changeset
    47
    Collections which cannot grow easily are for example: Array, ByteArray and String.
88
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    48
    Thus it is slightly incompatible to ST-80 since 'aStream contents' does 
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    49
    not always return the original collection. This may change.
1295
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1136
diff changeset
    50
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1136
diff changeset
    51
    [author:]
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1136
diff changeset
    52
        Claus Gittinger
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
    53
"
2883
ee0eb799bd3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
    54
!
ee0eb799bd3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
    55
ee0eb799bd3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
    56
examples
ee0eb799bd3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
    57
"
ee0eb799bd3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
    58
                                                                [exBegin]
ee0eb799bd3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
    59
     |s|
ee0eb799bd3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
    60
ee0eb799bd3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
    61
     s := WriteStream on:''.
ee0eb799bd3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
    62
     s nextPutAll:'hello';
ee0eb799bd3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
    63
       space;
ee0eb799bd3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
    64
       nextPutAll:'world'.
ee0eb799bd3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
    65
ee0eb799bd3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
    66
     s contents inspect
ee0eb799bd3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
    67
                                                                [exEnd]
ee0eb799bd3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
    68
ee0eb799bd3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
    69
                                                                [exBegin]
ee0eb799bd3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
    70
     |s|
ee0eb799bd3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
    71
ee0eb799bd3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
    72
     s := WriteStream on:''.
ee0eb799bd3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
    73
     s nextPutAll:'hello';
ee0eb799bd3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
    74
       space;
ee0eb799bd3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
    75
       nextPutAll:'world'.
ee0eb799bd3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
    76
ee0eb799bd3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
    77
     Transcript nextPutLine:(s contents)
ee0eb799bd3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
    78
                                                                [exEnd]
ee0eb799bd3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
    79
ee0eb799bd3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
    80
                                                                [exBegin]
ee0eb799bd3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
    81
     |s|
ee0eb799bd3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
    82
ee0eb799bd3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
    83
     s := '' writeStream.
ee0eb799bd3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
    84
     s nextPutAll:'hello';
ee0eb799bd3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
    85
       space;
ee0eb799bd3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
    86
       nextPutAll:'world'.
ee0eb799bd3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
    87
ee0eb799bd3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
    88
     Transcript nextPutLine:(s contents)
ee0eb799bd3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
    89
                                                                [exEnd]
ee0eb799bd3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
    90
"
ee0eb799bd3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
    91
345
claus
parents: 329
diff changeset
    92
! !
claus
parents: 329
diff changeset
    93
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    94
!WriteStream methodsFor:'accessing'!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    95
a27a279701f8 Initial revision
claus
parents:
diff changeset
    96
contents
345
claus
parents: 329
diff changeset
    97
    "return the current contents (a collection) of the stream.
claus
parents: 329
diff changeset
    98
     Currently, this returns the actual collection if possible
claus
parents: 329
diff changeset
    99
     (and reset is implemented to create a new one) in contrast to
claus
parents: 329
diff changeset
   100
     ST80, where contents returns a copy and reset only sets the writePointer.
claus
parents: 329
diff changeset
   101
     The ST/X behavior creates less temporary garbage in the normal case
2410
eea60bba0412 Fix typos.
Stefan Vogel <sv@exept.de>
parents: 1965
diff changeset
   102
     (where things are written for the contents only) but may be incompatible
345
claus
parents: 329
diff changeset
   103
     with some applications. Time will show, if this is to be changed."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   104
260
cefb485445a7 *** empty log message ***
claus
parents: 252
diff changeset
   105
    |lastIndex|
cefb485445a7 *** empty log message ***
claus
parents: 252
diff changeset
   106
cefb485445a7 *** empty log message ***
claus
parents: 252
diff changeset
   107
    lastIndex := position - 1.
cefb485445a7 *** empty log message ***
claus
parents: 252
diff changeset
   108
    collection size == lastIndex ifFalse:[
2410
eea60bba0412 Fix typos.
Stefan Vogel <sv@exept.de>
parents: 1965
diff changeset
   109
        collection isFixedSize ifTrue:[
eea60bba0412 Fix typos.
Stefan Vogel <sv@exept.de>
parents: 1965
diff changeset
   110
            "
eea60bba0412 Fix typos.
Stefan Vogel <sv@exept.de>
parents: 1965
diff changeset
   111
             grow is expensive - return a copy.
eea60bba0412 Fix typos.
Stefan Vogel <sv@exept.de>
parents: 1965
diff changeset
   112
             (is this what users of writeStream expect ?
eea60bba0412 Fix typos.
Stefan Vogel <sv@exept.de>
parents: 1965
diff changeset
   113
            "
eea60bba0412 Fix typos.
Stefan Vogel <sv@exept.de>
parents: 1965
diff changeset
   114
            collection := collection copyFrom:1 to:lastIndex
eea60bba0412 Fix typos.
Stefan Vogel <sv@exept.de>
parents: 1965
diff changeset
   115
        ] ifFalse:[
eea60bba0412 Fix typos.
Stefan Vogel <sv@exept.de>
parents: 1965
diff changeset
   116
            collection grow:lastIndex
eea60bba0412 Fix typos.
Stefan Vogel <sv@exept.de>
parents: 1965
diff changeset
   117
        ]
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   118
    ].
a27a279701f8 Initial revision
claus
parents:
diff changeset
   119
    ^ collection
2410
eea60bba0412 Fix typos.
Stefan Vogel <sv@exept.de>
parents: 1965
diff changeset
   120
eea60bba0412 Fix typos.
Stefan Vogel <sv@exept.de>
parents: 1965
diff changeset
   121
    "Modified: 19.2.1997 / 08:57:28 / stefan"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   122
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   123
329
claus
parents: 293
diff changeset
   124
reset
345
claus
parents: 329
diff changeset
   125
    "reset the stream; write anew.
2410
eea60bba0412 Fix typos.
Stefan Vogel <sv@exept.de>
parents: 1965
diff changeset
   126
     See the comment in WriteStream>>contents"
329
claus
parents: 293
diff changeset
   127
claus
parents: 293
diff changeset
   128
    collection := collection species new:(collection size).
claus
parents: 293
diff changeset
   129
    super reset
2410
eea60bba0412 Fix typos.
Stefan Vogel <sv@exept.de>
parents: 1965
diff changeset
   130
eea60bba0412 Fix typos.
Stefan Vogel <sv@exept.de>
parents: 1965
diff changeset
   131
    "Modified: 19.2.1997 / 08:57:00 / stefan"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   132
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
   133
611
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   134
!WriteStream methodsFor:'positioning'!
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   135
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   136
position:index
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   137
    "redefined to allow positioning past the readLimit"
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   138
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   139
    ((index > (collection size + 1)) or:[index < 0]) ifTrue: [^ self positionError].
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   140
    position := index
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   141
! !
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   142
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   143
!WriteStream methodsFor:'private'!
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   144
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   145
growCollection
2863
aec08a0c2c2e no need for unsigned compare against 0
Claus Gittinger <cg@exept.de>
parents: 2410
diff changeset
   146
    "grow the streamed collection to at least 10 elements"
aec08a0c2c2e no need for unsigned compare against 0
Claus Gittinger <cg@exept.de>
parents: 2410
diff changeset
   147
611
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   148
    self growCollection:10
2863
aec08a0c2c2e no need for unsigned compare against 0
Claus Gittinger <cg@exept.de>
parents: 2410
diff changeset
   149
aec08a0c2c2e no need for unsigned compare against 0
Claus Gittinger <cg@exept.de>
parents: 2410
diff changeset
   150
    "Modified: 19.8.1997 / 17:53:28 / cg"
611
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   151
!
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   152
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   153
growCollection:minNewSize
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   154
    "grow the streamed collection to at least minNewSize"
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   155
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   156
    |oldSize newSize newColl|
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   157
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   158
    oldSize := collection size.
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   159
    (oldSize == 0) ifTrue:[
2863
aec08a0c2c2e no need for unsigned compare against 0
Claus Gittinger <cg@exept.de>
parents: 2410
diff changeset
   160
        newSize := minNewSize
611
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   161
    ] ifFalse:[
2863
aec08a0c2c2e no need for unsigned compare against 0
Claus Gittinger <cg@exept.de>
parents: 2410
diff changeset
   162
        newSize := oldSize * 2.
aec08a0c2c2e no need for unsigned compare against 0
Claus Gittinger <cg@exept.de>
parents: 2410
diff changeset
   163
        (newSize < minNewSize) ifTrue:[newSize := minNewSize].
611
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   164
    ].
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   165
    collection isFixedSize ifTrue:[
2863
aec08a0c2c2e no need for unsigned compare against 0
Claus Gittinger <cg@exept.de>
parents: 2410
diff changeset
   166
        newColl := collection species new:newSize.
aec08a0c2c2e no need for unsigned compare against 0
Claus Gittinger <cg@exept.de>
parents: 2410
diff changeset
   167
        newColl replaceFrom:1 to:oldSize with:collection startingAt:1.
aec08a0c2c2e no need for unsigned compare against 0
Claus Gittinger <cg@exept.de>
parents: 2410
diff changeset
   168
        collection := newColl
611
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   169
    ] ifFalse:[
2863
aec08a0c2c2e no need for unsigned compare against 0
Claus Gittinger <cg@exept.de>
parents: 2410
diff changeset
   170
        collection grow:newSize
611
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   171
    ].
2863
aec08a0c2c2e no need for unsigned compare against 0
Claus Gittinger <cg@exept.de>
parents: 2410
diff changeset
   172
aec08a0c2c2e no need for unsigned compare against 0
Claus Gittinger <cg@exept.de>
parents: 2410
diff changeset
   173
    "Modified: 19.8.1997 / 17:53:11 / cg"
611
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   174
! !
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   175
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   176
!WriteStream methodsFor:'private accessing'!
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   177
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   178
on:aCollection from:start to:last
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   179
    "create and return a new stream for writing onto aCollection, where
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   180
     writing is limited to the elements in the range start to last."
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
    super on:aCollection from:start to:last.
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   183
    writeLimit := last.
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   184
! !
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   185
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   186
!WriteStream methodsFor:'queries'!
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
isWritable
1405
f4ab59f3888a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1398
diff changeset
   189
    "return true, if writing is supported by the recevier.
f4ab59f3888a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1398
diff changeset
   190
     Always return true here"
f4ab59f3888a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1398
diff changeset
   191
611
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   192
    ^ true
1405
f4ab59f3888a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1398
diff changeset
   193
f4ab59f3888a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1398
diff changeset
   194
    "Modified: 16.5.1996 / 14:44:49 / cg"
611
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   195
! !
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   196
63
1f0cdefb013f *** empty log message ***
claus
parents: 10
diff changeset
   197
!WriteStream methodsFor:'reading'!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   198
a27a279701f8 Initial revision
claus
parents:
diff changeset
   199
next
10
claus
parents: 5
diff changeset
   200
    "catch read access to write stream - report an error"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   201
10
claus
parents: 5
diff changeset
   202
    self shouldNotImplement
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   203
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   204
a27a279701f8 Initial revision
claus
parents:
diff changeset
   205
peek
10
claus
parents: 5
diff changeset
   206
    "catch read access to write stream - report an error"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   207
10
claus
parents: 5
diff changeset
   208
    self shouldNotImplement
63
1f0cdefb013f *** empty log message ***
claus
parents: 10
diff changeset
   209
! !
1f0cdefb013f *** empty log message ***
claus
parents: 10
diff changeset
   210
611
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   211
!WriteStream methodsFor:'writing'!
369
claus
parents: 359
diff changeset
   212
611
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   213
next:count put:anObject
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   214
    "append anObject count times to the receiver.
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   215
     Redefined to avoid count grows of the underlying collection -
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   216
     instead a single grow on the final size is performed."
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   217
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   218
    |final|
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   219
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   220
    (collection isNil or:[writeLimit notNil]) ifTrue:[
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   221
	^ super next:count put:anObject
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   222
    ].
369
claus
parents: 359
diff changeset
   223
611
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   224
    final := position + count - 1.
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   225
    (final > collection size) ifTrue:[
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   226
	self growCollection:final
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   227
    ].
369
claus
parents: 359
diff changeset
   228
611
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   229
    position to:final do:[:index |
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   230
	collection at:index put:anObject.
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   231
    ].
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   232
    position := position + count.
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   233
    (position > readLimit) ifTrue:[readLimit := position - 1].
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   234
    ^ anObject
80bb0f1a7bab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   235
!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   236
a27a279701f8 Initial revision
claus
parents:
diff changeset
   237
nextPut:anObject
1584
cad4f2c515c7 nextPut: slightly modified
Claus Gittinger <cg@exept.de>
parents: 1541
diff changeset
   238
    "append the argument, anObject to the stream.
2863
aec08a0c2c2e no need for unsigned compare against 0
Claus Gittinger <cg@exept.de>
parents: 2410
diff changeset
   239
     Specially tuned for appending to String, ByteArray and Array streams."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   240
63
1f0cdefb013f *** empty log message ***
claus
parents: 10
diff changeset
   241
%{  /* NOCONTEXT */
1f0cdefb013f *** empty log message ***
claus
parents: 10
diff changeset
   242
1f0cdefb013f *** empty log message ***
claus
parents: 10
diff changeset
   243
    REGISTER int pos;
1f0cdefb013f *** empty log message ***
claus
parents: 10
diff changeset
   244
    unsigned ch;
1f0cdefb013f *** empty log message ***
claus
parents: 10
diff changeset
   245
    OBJ coll;
2883
ee0eb799bd3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
   246
    OBJ p, wL, rL;
1584
cad4f2c515c7 nextPut: slightly modified
Claus Gittinger <cg@exept.de>
parents: 1541
diff changeset
   247
    int __readLimit = -1;
63
1f0cdefb013f *** empty log message ***
claus
parents: 10
diff changeset
   248
1136
898af060dfde underline cleanup
Claus Gittinger <cg@exept.de>
parents: 838
diff changeset
   249
    coll = __INST(collection);
898af060dfde underline cleanup
Claus Gittinger <cg@exept.de>
parents: 838
diff changeset
   250
    p = __INST(position);
63
1f0cdefb013f *** empty log message ***
claus
parents: 10
diff changeset
   251
2894
344aec8ba014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2883
diff changeset
   252
#ifndef NO_PRIM_STREAM
293
31df3850e98c *** empty log message ***
claus
parents: 261
diff changeset
   253
    if (__isNonNilObject(coll) && __isSmallInteger(p)) {
1584
cad4f2c515c7 nextPut: slightly modified
Claus Gittinger <cg@exept.de>
parents: 1541
diff changeset
   254
        pos = __intVal(p);
2883
ee0eb799bd3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
   255
        wL = __INST(writeLimit);
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
   256
2883
ee0eb799bd3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
   257
        if ((wL == nil)
ee0eb799bd3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
   258
         || (__isSmallInteger(wL) && (pos <= __intVal(wL)))) {
1584
cad4f2c515c7 nextPut: slightly modified
Claus Gittinger <cg@exept.de>
parents: 1541
diff changeset
   259
            OBJ cls;
63
1f0cdefb013f *** empty log message ***
claus
parents: 10
diff changeset
   260
1584
cad4f2c515c7 nextPut: slightly modified
Claus Gittinger <cg@exept.de>
parents: 1541
diff changeset
   261
            cls = __qClass(coll);
252
claus
parents: 95
diff changeset
   262
1584
cad4f2c515c7 nextPut: slightly modified
Claus Gittinger <cg@exept.de>
parents: 1541
diff changeset
   263
            rL = __INST(readLimit);
cad4f2c515c7 nextPut: slightly modified
Claus Gittinger <cg@exept.de>
parents: 1541
diff changeset
   264
            if (__isSmallInteger(rL)) {
cad4f2c515c7 nextPut: slightly modified
Claus Gittinger <cg@exept.de>
parents: 1541
diff changeset
   265
                __readLimit = __intVal(rL);
cad4f2c515c7 nextPut: slightly modified
Claus Gittinger <cg@exept.de>
parents: 1541
diff changeset
   266
            }
293
31df3850e98c *** empty log message ***
claus
parents: 261
diff changeset
   267
1584
cad4f2c515c7 nextPut: slightly modified
Claus Gittinger <cg@exept.de>
parents: 1541
diff changeset
   268
            if (cls == @global(String)) {
cad4f2c515c7 nextPut: slightly modified
Claus Gittinger <cg@exept.de>
parents: 1541
diff changeset
   269
                if (__isCharacter(anObject) 
2883
ee0eb799bd3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
   270
                 && ((ch = __intVal(__characterVal(anObject))) <= 255) /* ch is unsigned */
1584
cad4f2c515c7 nextPut: slightly modified
Claus Gittinger <cg@exept.de>
parents: 1541
diff changeset
   271
                 && (pos <= __stringSize(coll))) {
2883
ee0eb799bd3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
   272
                    __StringInstPtr(coll)->s_element[pos-1] = ch;
ee0eb799bd3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
   273
                    __INST(position) = __MKSMALLINT(pos + 1);
ee0eb799bd3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
   274
                    if ((__readLimit >= 0) && (pos >= __readLimit)) {
ee0eb799bd3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
   275
                        __INST(readLimit) = __MKSMALLINT(pos);
1584
cad4f2c515c7 nextPut: slightly modified
Claus Gittinger <cg@exept.de>
parents: 1541
diff changeset
   276
                    }
2883
ee0eb799bd3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
   277
                    RETURN ( anObject );
1584
cad4f2c515c7 nextPut: slightly modified
Claus Gittinger <cg@exept.de>
parents: 1541
diff changeset
   278
                }
cad4f2c515c7 nextPut: slightly modified
Claus Gittinger <cg@exept.de>
parents: 1541
diff changeset
   279
            } else if (cls == @global(ByteArray)) {
cad4f2c515c7 nextPut: slightly modified
Claus Gittinger <cg@exept.de>
parents: 1541
diff changeset
   280
                if (__isSmallInteger(anObject) 
2864
328b52ecd339 no need for unsigned compare against 0
Claus Gittinger <cg@exept.de>
parents: 2863
diff changeset
   281
                 && ((ch = __intVal(anObject)) <= 255) /* ch is unsigned */
2883
ee0eb799bd3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
   282
                 && (pos <= __byteArraySize(coll))) {
1584
cad4f2c515c7 nextPut: slightly modified
Claus Gittinger <cg@exept.de>
parents: 1541
diff changeset
   283
                    __ByteArrayInstPtr(coll)->ba_element[pos-1] = ch;
cad4f2c515c7 nextPut: slightly modified
Claus Gittinger <cg@exept.de>
parents: 1541
diff changeset
   284
                    __INST(position) = __MKSMALLINT(pos + 1);
cad4f2c515c7 nextPut: slightly modified
Claus Gittinger <cg@exept.de>
parents: 1541
diff changeset
   285
                    if ((__readLimit >= 0) && (pos >= __readLimit)) {
cad4f2c515c7 nextPut: slightly modified
Claus Gittinger <cg@exept.de>
parents: 1541
diff changeset
   286
                        __INST(readLimit) = __MKSMALLINT(pos);
cad4f2c515c7 nextPut: slightly modified
Claus Gittinger <cg@exept.de>
parents: 1541
diff changeset
   287
                    }
cad4f2c515c7 nextPut: slightly modified
Claus Gittinger <cg@exept.de>
parents: 1541
diff changeset
   288
                    RETURN ( anObject );
cad4f2c515c7 nextPut: slightly modified
Claus Gittinger <cg@exept.de>
parents: 1541
diff changeset
   289
                }
cad4f2c515c7 nextPut: slightly modified
Claus Gittinger <cg@exept.de>
parents: 1541
diff changeset
   290
            } else if (cls == @global(Array)) {
2883
ee0eb799bd3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2864
diff changeset
   291
                if (pos <= __arraySize(coll)) {
1584
cad4f2c515c7 nextPut: slightly modified
Claus Gittinger <cg@exept.de>
parents: 1541
diff changeset
   292
                     __ArrayInstPtr(coll)->a_element[pos-1] = anObject;
cad4f2c515c7 nextPut: slightly modified
Claus Gittinger <cg@exept.de>
parents: 1541
diff changeset
   293
                    __STORE(coll, anObject);
cad4f2c515c7 nextPut: slightly modified
Claus Gittinger <cg@exept.de>
parents: 1541
diff changeset
   294
                    __INST(position) = __MKSMALLINT(pos + 1);
cad4f2c515c7 nextPut: slightly modified
Claus Gittinger <cg@exept.de>
parents: 1541
diff changeset
   295
                    if ((__readLimit >= 0) && (pos >= __readLimit)) {
cad4f2c515c7 nextPut: slightly modified
Claus Gittinger <cg@exept.de>
parents: 1541
diff changeset
   296
                        __INST(readLimit) = __MKSMALLINT(pos);
cad4f2c515c7 nextPut: slightly modified
Claus Gittinger <cg@exept.de>
parents: 1541
diff changeset
   297
                    }
cad4f2c515c7 nextPut: slightly modified
Claus Gittinger <cg@exept.de>
parents: 1541
diff changeset
   298
                    RETURN ( anObject );
cad4f2c515c7 nextPut: slightly modified
Claus Gittinger <cg@exept.de>
parents: 1541
diff changeset
   299
                }
cad4f2c515c7 nextPut: slightly modified
Claus Gittinger <cg@exept.de>
parents: 1541
diff changeset
   300
            }
cad4f2c515c7 nextPut: slightly modified
Claus Gittinger <cg@exept.de>
parents: 1541
diff changeset
   301
        }
63
1f0cdefb013f *** empty log message ***
claus
parents: 10
diff changeset
   302
    }
2894
344aec8ba014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2883
diff changeset
   303
#endif
260
cefb485445a7 *** empty log message ***
claus
parents: 252
diff changeset
   304
%}.
293
31df3850e98c *** empty log message ***
claus
parents: 261
diff changeset
   305
    (writeLimit isNil
31df3850e98c *** empty log message ***
claus
parents: 261
diff changeset
   306
    or:[position <= writeLimit]) ifTrue:[
1584
cad4f2c515c7 nextPut: slightly modified
Claus Gittinger <cg@exept.de>
parents: 1541
diff changeset
   307
        (position > collection size) ifTrue:[self growCollection].
cad4f2c515c7 nextPut: slightly modified
Claus Gittinger <cg@exept.de>
parents: 1541
diff changeset
   308
        collection at:position put:anObject.
cad4f2c515c7 nextPut: slightly modified
Claus Gittinger <cg@exept.de>
parents: 1541
diff changeset
   309
        (position > readLimit) ifTrue:[readLimit := position].
cad4f2c515c7 nextPut: slightly modified
Claus Gittinger <cg@exept.de>
parents: 1541
diff changeset
   310
        position := position + 1.
838
67a53cceaab1 no global refs
Claus Gittinger <cg@exept.de>
parents: 701
diff changeset
   311
    ] ifFalse:[
1965
4ca38574df3b Fix typo.
Stefan Vogel <sv@exept.de>
parents: 1584
diff changeset
   312
        WriteErrorSignal raiseErrorString:'write beyond writeLimit'
293
31df3850e98c *** empty log message ***
claus
parents: 261
diff changeset
   313
    ].
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   314
    ^anObject
a27a279701f8 Initial revision
claus
parents:
diff changeset
   315
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   316
a27a279701f8 Initial revision
claus
parents:
diff changeset
   317
nextPutAll:aCollection
63
1f0cdefb013f *** empty log message ***
claus
parents: 10
diff changeset
   318
    "append all elements of the argument, aCollection to the stream.
1f0cdefb013f *** empty log message ***
claus
parents: 10
diff changeset
   319
     Redefined to avoid count grows of the underlying collection -
1f0cdefb013f *** empty log message ***
claus
parents: 10
diff changeset
   320
     instead a single grow on the final size is performed."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   321
a27a279701f8 Initial revision
claus
parents:
diff changeset
   322
    |nMore final|
a27a279701f8 Initial revision
claus
parents:
diff changeset
   323
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
   324
    collection isNil ifTrue:[
260
cefb485445a7 *** empty log message ***
claus
parents: 252
diff changeset
   325
	^ super nextPutAll:aCollection
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
   326
    ].
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
   327
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   328
    nMore := aCollection size.
a27a279701f8 Initial revision
claus
parents:
diff changeset
   329
    final := position + nMore - 1.
293
31df3850e98c *** empty log message ***
claus
parents: 261
diff changeset
   330
    (writeLimit notNil
31df3850e98c *** empty log message ***
claus
parents: 261
diff changeset
   331
    and:[final > writeLimit]) ifTrue:[
31df3850e98c *** empty log message ***
claus
parents: 261
diff changeset
   332
	final := writeLimit.
31df3850e98c *** empty log message ***
claus
parents: 261
diff changeset
   333
	nMore := final - position + 1
31df3850e98c *** empty log message ***
claus
parents: 261
diff changeset
   334
    ].
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   335
    (final > collection size) ifTrue:[
252
claus
parents: 95
diff changeset
   336
	self growCollection:final
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   337
    ].
a27a279701f8 Initial revision
claus
parents:
diff changeset
   338
    collection replaceFrom:position
252
claus
parents: 95
diff changeset
   339
			to:final
claus
parents: 95
diff changeset
   340
		      with:aCollection 
claus
parents: 95
diff changeset
   341
		startingAt:1.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   342
a27a279701f8 Initial revision
claus
parents:
diff changeset
   343
    position := position + nMore.
a27a279701f8 Initial revision
claus
parents:
diff changeset
   344
    (position > readLimit) ifTrue:[readLimit := position - 1].
a27a279701f8 Initial revision
claus
parents:
diff changeset
   345
    ^ aCollection
1539
b1ac096a81e3 added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents: 1405
diff changeset
   346
!
b1ac096a81e3 added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents: 1405
diff changeset
   347
b1ac096a81e3 added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents: 1405
diff changeset
   348
nextPutAll:aCollection startingAt:pos1 to:pos2
b1ac096a81e3 added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents: 1405
diff changeset
   349
    "append some elements of the argument, aCollection to the stream.
b1ac096a81e3 added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents: 1405
diff changeset
   350
     Redefined to avoid count grows of the underlying collection -
b1ac096a81e3 added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents: 1405
diff changeset
   351
     instead a single grow on the final size is performed."
b1ac096a81e3 added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents: 1405
diff changeset
   352
b1ac096a81e3 added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents: 1405
diff changeset
   353
    |nMore final|
b1ac096a81e3 added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents: 1405
diff changeset
   354
b1ac096a81e3 added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents: 1405
diff changeset
   355
    collection isNil ifTrue:[
1541
6ed5feddc4ed checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1539
diff changeset
   356
        ^ super nextPutAll:aCollection startingAt:pos1 to:pos2
1539
b1ac096a81e3 added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents: 1405
diff changeset
   357
    ].
b1ac096a81e3 added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents: 1405
diff changeset
   358
b1ac096a81e3 added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents: 1405
diff changeset
   359
    nMore := pos2 - pos1 + 1.
b1ac096a81e3 added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents: 1405
diff changeset
   360
    final := position + nMore - 1.
b1ac096a81e3 added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents: 1405
diff changeset
   361
    (writeLimit notNil
b1ac096a81e3 added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents: 1405
diff changeset
   362
    and:[final > writeLimit]) ifTrue:[
b1ac096a81e3 added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents: 1405
diff changeset
   363
        final := writeLimit.
b1ac096a81e3 added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents: 1405
diff changeset
   364
        nMore := final - position + 1
b1ac096a81e3 added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents: 1405
diff changeset
   365
    ].
b1ac096a81e3 added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents: 1405
diff changeset
   366
    (final > collection size) ifTrue:[
b1ac096a81e3 added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents: 1405
diff changeset
   367
        self growCollection:final
b1ac096a81e3 added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents: 1405
diff changeset
   368
    ].
b1ac096a81e3 added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents: 1405
diff changeset
   369
b1ac096a81e3 added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents: 1405
diff changeset
   370
    collection replaceFrom:position
b1ac096a81e3 added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents: 1405
diff changeset
   371
                        to:final
b1ac096a81e3 added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents: 1405
diff changeset
   372
                      with:aCollection 
b1ac096a81e3 added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents: 1405
diff changeset
   373
                startingAt:pos1.
b1ac096a81e3 added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents: 1405
diff changeset
   374
b1ac096a81e3 added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents: 1405
diff changeset
   375
    position := position + nMore.
b1ac096a81e3 added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents: 1405
diff changeset
   376
    (position > readLimit) ifTrue:[readLimit := position - 1].
b1ac096a81e3 added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents: 1405
diff changeset
   377
    ^ aCollection
b1ac096a81e3 added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents: 1405
diff changeset
   378
b1ac096a81e3 added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents: 1405
diff changeset
   379
    "
b1ac096a81e3 added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents: 1405
diff changeset
   380
     |s|
b1ac096a81e3 added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents: 1405
diff changeset
   381
b1ac096a81e3 added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents: 1405
diff changeset
   382
     s := '' writeStream.
b1ac096a81e3 added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents: 1405
diff changeset
   383
     s nextPutAll:'hello '.
b1ac096a81e3 added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents: 1405
diff changeset
   384
     s nextPutAll:'1234world012345' startingAt:5 to:9.
b1ac096a81e3 added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents: 1405
diff changeset
   385
     s contents
b1ac096a81e3 added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents: 1405
diff changeset
   386
    "
b1ac096a81e3 added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents: 1405
diff changeset
   387
1541
6ed5feddc4ed checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1539
diff changeset
   388
    "Modified: 12.7.1996 / 10:31:36 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   389
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
   390
1965
4ca38574df3b Fix typo.
Stefan Vogel <sv@exept.de>
parents: 1584
diff changeset
   391
!WriteStream class methodsFor:'documentation'!
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   392
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   393
version
2899
431d8830445b removed debug stuff
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
   394
    ^ '$Header: /cvs/stx/stx/libbasic/WriteStream.st,v 1.38 1997-09-06 17:17:45 cg Exp $'
701
a309e3ef7faf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   395
! !