author | Martin Kobetic |
Sun, 17 Nov 2013 00:02:08 -0500 | |
changeset 131 | 871b930fcf3d |
parent 109 | 9587e2df7029 |
permissions | -rw-r--r-- |
4 | 1 |
"{ Package: 'stx:goodies/xtreams/substreams' }" |
2 |
||
3 |
"{ NameSpace: Xtreams }" |
|
4 |
||
5 |
WriteStream subclass:#WriteSubstream |
|
6 |
instanceVariableNames:'destinationAtEnd closeBlock substreamClosed' |
|
7 |
classVariableNames:'' |
|
8 |
poolDictionaries:'' |
|
22
e0653bbdbe61
added XtreamsPool to fix DefaultBufferSize; set proper category names
mkobetic
parents:
4
diff
changeset
|
9 |
category:'Xtreams-Substreams' |
4 | 10 |
! |
11 |
||
12 |
WriteSubstream comment:'This is abstract superclass of all substreams. Substreams normally don''t close their underlying source, their closing behavior is customized via closeBlock. |
|
13 |
||
14 |
Instance Variables |
|
109 | 15 |
destinationAtEnd <Boolean> flags end of the destination |
16 |
closeBlock <BlockClosure> unary block invoked in response to #close, allows customizing closing behavior |
|
17 |
substreamClosed <Boolean> flags the end of the receiver |
|
4 | 18 |
|
19 |
' |
|
20 |
! |
|
21 |
||
22 |
||
23 |
!WriteSubstream class methodsFor:'private'! |
|
24 |
||
25 |
slice: sliceBlock close: closeBlock |
|
26 |
| substream | |
|
27 |
substream := nil. |
|
28 |
^[substream == nil ifFalse: |
|
29 |
[substream substreamClosed ifFalse: [substream close]. |
|
30 |
substream subseekend. |
|
31 |
substream destinationAtEnd ifTrue: [Incomplete zero raise]]. |
|
32 |
substream := sliceBlock value] |
|
33 |
reading |
|
34 |
closeBlock: closeBlock; |
|
35 |
yourself |
|
36 |
! ! |
|
37 |
||
38 |
!WriteSubstream methodsFor:'accessing'! |
|
39 |
||
40 |
closeBlock |
|
41 |
^closeBlock |
|
42 |
! |
|
43 |
||
44 |
closeBlock: anObject |
|
45 |
closeBlock := anObject |
|
46 |
! |
|
47 |
||
48 |
insert: anInteger from: aSequenceableCollection at: startIndex |
|
49 |
[destination insert: anInteger from: aSequenceableCollection at: startIndex] on: Incomplete do: [:incomplete | |
|
50 |
destinationAtEnd := true. |
|
51 |
incomplete pass]. |
|
52 |
^anInteger |
|
53 |
! |
|
54 |
||
55 |
put: anObject |
|
56 |
[destination put: anObject] on: Incomplete do: [:incomplete | |
|
57 |
destinationAtEnd := true. |
|
58 |
incomplete pass] |
|
59 |
! |
|
60 |
||
61 |
write: anInteger from: aSequenceableCollection at: startIndex |
|
62 |
[destination write: anInteger from: aSequenceableCollection at: startIndex] on: Incomplete do: [:incomplete | |
|
63 |
destinationAtEnd := true. |
|
64 |
incomplete pass]. |
|
65 |
^anInteger |
|
66 |
! ! |
|
67 |
||
68 |
!WriteSubstream methodsFor:'initialize-release'! |
|
69 |
||
70 |
close |
|
71 |
closeBlock cull: self. |
|
72 |
substreamClosed := true |
|
73 |
! |
|
74 |
||
75 |
contentsSpecies |
|
76 |
^destination contentsSpecies |
|
77 |
! |
|
78 |
||
79 |
on: aDestination |
|
80 |
super on: aDestination. |
|
81 |
closeBlock := []. |
|
82 |
destinationAtEnd := false. |
|
83 |
substreamClosed := false |
|
84 |
! |
|
85 |
||
86 |
subseekend |
|
87 |
! ! |
|
88 |
||
89 |
!WriteSubstream methodsFor:'testing'! |
|
90 |
||
91 |
destinationAtEnd |
|
92 |
^destinationAtEnd |
|
93 |
! |
|
94 |
||
95 |
substreamClosed |
|
96 |
^substreamClosed |
|
97 |
! ! |
|
98 |
||
99 |
!WriteSubstream class methodsFor:'documentation'! |
|
100 |
||
109 | 101 |
version_HG |
102 |
||
103 |
^ '$Changeset: <not expanded> $' |
|
4 | 104 |
! ! |
109 | 105 |