author | mkobetic |
Sun, 15 Jan 2012 02:18:17 +0000 | |
changeset 39 | 80fdc4602b14 |
parent 25 | 02e7c3b6f63c |
child 43 | b9a077d6ce14 |
permissions | -rw-r--r-- |
39 | 1 |
'From Smalltalk/X, Version:6.2.1 on 14-01-2012 at 09:10:26 PM' ! |
2 |
||
9 | 3 |
"{ Package: 'stx:goodies/xtreams/terminals' }" |
4 |
||
5 |
"{ NameSpace: Xtreams }" |
|
6 |
||
7 |
WriteStream subclass:#BufferWriteStream |
|
8 |
instanceVariableNames:'' |
|
9 |
classVariableNames:'' |
|
10 |
poolDictionaries:'' |
|
25
02e7c3b6f63c
added XtreamsPool to fix DefaultBufferSize; set proper category names
mkobetic
parents:
9
diff
changeset
|
11 |
category:'Xtreams-Terminals' |
9 | 12 |
! |
13 |
||
14 |
BufferWriteStream comment:'Write stream on a Buffer. Usually used in tandem with a read stream to access buffer contents conveniently. |
|
15 |
{{{ |
|
16 |
buffer := ElasticBuffer on: String new. |
|
17 |
bufferIn := buffer writing. |
|
18 |
bufferOut := buffer reading. |
|
19 |
100000 timesRepeat: [ bufferIn write: ''Hello World''. bufferOut read: 11 ]. |
|
20 |
buffer cacheSize |
|
21 |
}}} |
|
22 |
' |
|
23 |
! |
|
24 |
||
25 |
||
26 |
!BufferWriteStream methodsFor:'accessing'! |
|
27 |
||
28 |
insert: anInteger from: aSequenceableCollection at: startIndex |
|
29 |
^destination insert: anInteger from: aSequenceableCollection at: startIndex |
|
30 |
! |
|
31 |
||
32 |
put: anObject |
|
33 |
^destination put: anObject |
|
34 |
! |
|
35 |
||
36 |
write: anInteger from: aSequenceableCollection at: startIndex |
|
37 |
^destination write: anInteger from: aSequenceableCollection at: startIndex |
|
38 |
! ! |
|
39 |
||
40 |
!BufferWriteStream methodsFor:'initialize-release'! |
|
41 |
||
42 |
close |
|
43 |
destination close |
|
44 |
! |
|
45 |
||
46 |
contentsSpecies |
|
47 |
^destination contentsSpecies |
|
48 |
! |
|
49 |
||
50 |
flush |
|
51 |
! ! |
|
52 |
||
53 |
!BufferWriteStream methodsFor:'seeking'! |
|
54 |
||
55 |
++ anInteger |
|
56 |
| count | |
|
57 |
anInteger < 0 ifTrue: [ ^self -- anInteger negated ]. |
|
58 |
count := destination writeSkip: anInteger. |
|
59 |
count < anInteger ifTrue: [(Incomplete count: count) raise]. |
|
60 |
^anInteger |
|
61 |
! |
|
62 |
||
63 |
-- anInteger |
|
64 |
| count | |
|
65 |
anInteger < 0 ifTrue: [ ^self ++ anInteger negated ]. |
|
66 |
count := (destination writeSkip: anInteger negated) negated. |
|
67 |
count = anInteger ifTrue: [^anInteger]. |
|
68 |
(Incomplete count: count) raise |
|
69 |
! |
|
70 |
||
71 |
available |
|
72 |
^destination writeSize |
|
73 |
! |
|
74 |
||
75 |
length |
|
76 |
^destination activeSize |
|
77 |
! |
|
78 |
||
79 |
position |
|
80 |
^destination writePosition |
|
81 |
! |
|
82 |
||
83 |
position: aPosition |
|
84 |
| available | |
|
85 |
aPosition < 0 ifTrue: [ Incomplete zero raise ]. |
|
86 |
available := aPosition min: destination activeSize. |
|
87 |
destination writePosition: available. |
|
88 |
available = aPosition ifTrue: [^aPosition ]. |
|
89 |
(Incomplete count: available) raise |
|
90 |
! |
|
91 |
||
92 |
skip: anInteger |
|
93 |
| count | |
|
94 |
count := destination writeSkip: anInteger. |
|
95 |
count ~= anInteger ifTrue: [(Incomplete count: count) raise] |
|
96 |
! ! |
|
97 |
||
98 |
!BufferWriteStream methodsFor:'testing'! |
|
99 |
||
100 |
isPositionable |
|
101 |
^true |
|
102 |
! ! |
|
103 |
||
104 |
!BufferWriteStream class methodsFor:'documentation'! |
|
105 |
||
106 |
version_SVN |
|
107 |
^ '$Id$' |
|
108 |
! ! |