author | Stefan Vogel <sv@exept.de> |
Sat, 20 Jun 2009 11:16:54 +0200 | |
changeset 11778 | a4d708790f90 |
parent 11766 | b26aac1e4eb1 |
child 11946 | 1d2aefade06e |
child 17711 | 39faaaf888b4 |
permissions | -rw-r--r-- |
8148 | 1 |
" |
2 |
COPYRIGHT (c) 2004 by eXept Software AG |
|
3 |
All Rights Reserved |
|
4 |
||
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
8047 | 12 |
"{ Package: 'stx:libbasic' }" |
13 |
||
8447
9bdea3431846
EncodedStream inherts from PeekableStream
Stefan Vogel <sv@exept.de>
parents:
8444
diff
changeset
|
14 |
PeekableStream subclass:#EncodedStream |
8047 | 15 |
instanceVariableNames:'encoder stream' |
16 |
classVariableNames:'' |
|
17 |
poolDictionaries:'' |
|
18 |
category:'Collections-Text-Encodings' |
|
19 |
! |
|
20 |
||
8148 | 21 |
!EncodedStream class methodsFor:'documentation'! |
22 |
||
23 |
copyright |
|
24 |
" |
|
25 |
COPYRIGHT (c) 2004 by eXept Software AG |
|
26 |
All Rights Reserved |
|
27 |
||
28 |
This software is furnished under a license and may be used |
|
29 |
only in accordance with the terms of that license and with the |
|
30 |
inclusion of the above copyright notice. This software may not |
|
31 |
be provided or otherwise made available to, or used by, any |
|
32 |
other person. No title to or ownership of the software is |
|
33 |
hereby transferred. |
|
34 |
" |
|
35 |
! ! |
|
8047 | 36 |
|
37 |
!EncodedStream class methodsFor:'instance creation'! |
|
38 |
||
39 |
stream:streamArg encoder:encoder |
|
40 |
^ (self basicNew) stream:streamArg; encoder:encoder |
|
41 |
! ! |
|
42 |
||
43 |
!EncodedStream methodsFor:'accessing'! |
|
44 |
||
45 |
encoder |
|
46 |
^ encoder |
|
47 |
! |
|
48 |
||
49 |
encoder:something |
|
50 |
encoder := something. |
|
51 |
! |
|
52 |
||
11766 | 53 |
readStream |
54 |
^ self |
|
55 |
! |
|
56 |
||
8047 | 57 |
stream |
58 |
^ stream |
|
59 |
! |
|
60 |
||
61 |
stream:something |
|
62 |
stream := something. |
|
63 |
! ! |
|
64 |
||
65 |
!EncodedStream methodsFor:'stream protocol'! |
|
66 |
||
8175 | 67 |
atEnd |
68 |
^ stream atEnd |
|
69 |
! |
|
70 |
||
8165 | 71 |
close |
72 |
stream close |
|
73 |
! |
|
74 |
||
8213 | 75 |
cr |
8459 | 76 |
self nextPutAll:(Character cr asString) |
8213 | 77 |
! |
78 |
||
11766 | 79 |
next |
80 |
"that is a bad kludge - should care for the decoding here. |
|
81 |
Added to be able to show the classDefinition of SOAP::SoXmlUtil, |
|
82 |
which reads the comment from an encoded file." |
|
83 |
||
84 |
^ stream next |
|
85 |
! |
|
86 |
||
8147 | 87 |
nextChunk |
8175 | 88 |
|chunk| |
89 |
||
90 |
chunk := stream nextChunk. |
|
91 |
chunk isNil ifTrue:[^ chunk]. |
|
92 |
^ encoder decodeString:chunk |
|
8147 | 93 |
! |
94 |
||
8213 | 95 |
nextChunkPut:chunk |
96 |
stream nextChunkPut:(encoder encodeString:chunk) |
|
97 |
! |
|
98 |
||
8047 | 99 |
nextPut:aCharacter |
100 |
self nextPutAll:(aCharacter asString). |
|
101 |
! |
|
102 |
||
103 |
nextPutAll:aCollection |
|
104 |
stream nextPutAll:(encoder encodeString:aCollection). |
|
8147 | 105 |
! |
106 |
||
8444 | 107 |
peek |
108 |
^ stream peek |
|
109 |
! |
|
110 |
||
8175 | 111 |
peekFor:aCharacter |
112 |
^ stream peekFor:aCharacter |
|
113 |
! |
|
114 |
||
8165 | 115 |
position |
116 |
^ stream position |
|
117 |
! |
|
118 |
||
8197 | 119 |
position0Based |
120 |
^ stream position0Based |
|
121 |
! |
|
122 |
||
123 |
position0Based:newPosition |
|
124 |
stream position0Based:newPosition |
|
125 |
! |
|
126 |
||
8175 | 127 |
position1Based |
128 |
^ stream position1Based |
|
129 |
! |
|
130 |
||
8147 | 131 |
position1Based:newPosition |
132 |
stream position1Based:newPosition |
|
8175 | 133 |
! |
134 |
||
8197 | 135 |
position:newPosition |
136 |
stream position:newPosition |
|
137 |
! |
|
138 |
||
8213 | 139 |
setToEnd |
140 |
stream setToEnd |
|
141 |
! |
|
142 |
||
8175 | 143 |
skipSeparators |
144 |
^ stream skipSeparators |
|
8047 | 145 |
! ! |
146 |
||
8712
bcef3a0c0a1d
skipEncodingCHunk now in EncodedStream
Claus Gittinger <cg@exept.de>
parents:
8459
diff
changeset
|
147 |
!EncodedStream methodsFor:'utilities'! |
bcef3a0c0a1d
skipEncodingCHunk now in EncodedStream
Claus Gittinger <cg@exept.de>
parents:
8459
diff
changeset
|
148 |
|
bcef3a0c0a1d
skipEncodingCHunk now in EncodedStream
Claus Gittinger <cg@exept.de>
parents:
8459
diff
changeset
|
149 |
skipEncodingChunk |
bcef3a0c0a1d
skipEncodingCHunk now in EncodedStream
Claus Gittinger <cg@exept.de>
parents:
8459
diff
changeset
|
150 |
|pos chunk tree| |
bcef3a0c0a1d
skipEncodingCHunk now in EncodedStream
Claus Gittinger <cg@exept.de>
parents:
8459
diff
changeset
|
151 |
|
bcef3a0c0a1d
skipEncodingCHunk now in EncodedStream
Claus Gittinger <cg@exept.de>
parents:
8459
diff
changeset
|
152 |
pos := self position. |
bcef3a0c0a1d
skipEncodingCHunk now in EncodedStream
Claus Gittinger <cg@exept.de>
parents:
8459
diff
changeset
|
153 |
chunk := self nextChunk. |
bcef3a0c0a1d
skipEncodingCHunk now in EncodedStream
Claus Gittinger <cg@exept.de>
parents:
8459
diff
changeset
|
154 |
tree := (Parser parseExpression:chunk). |
bcef3a0c0a1d
skipEncodingCHunk now in EncodedStream
Claus Gittinger <cg@exept.de>
parents:
8459
diff
changeset
|
155 |
"/ if this is a valid chunk (i.e. not a comment or encoding-directive), |
bcef3a0c0a1d
skipEncodingCHunk now in EncodedStream
Claus Gittinger <cg@exept.de>
parents:
8459
diff
changeset
|
156 |
"/ then position back, so it will be processed as usual. |
bcef3a0c0a1d
skipEncodingCHunk now in EncodedStream
Claus Gittinger <cg@exept.de>
parents:
8459
diff
changeset
|
157 |
tree notNil ifTrue:[ |
bcef3a0c0a1d
skipEncodingCHunk now in EncodedStream
Claus Gittinger <cg@exept.de>
parents:
8459
diff
changeset
|
158 |
self position:pos |
bcef3a0c0a1d
skipEncodingCHunk now in EncodedStream
Claus Gittinger <cg@exept.de>
parents:
8459
diff
changeset
|
159 |
] |
bcef3a0c0a1d
skipEncodingCHunk now in EncodedStream
Claus Gittinger <cg@exept.de>
parents:
8459
diff
changeset
|
160 |
! ! |
bcef3a0c0a1d
skipEncodingCHunk now in EncodedStream
Claus Gittinger <cg@exept.de>
parents:
8459
diff
changeset
|
161 |
|
8047 | 162 |
!EncodedStream class methodsFor:'documentation'! |
163 |
||
164 |
version |
|
11766 | 165 |
^ '$Header: /cvs/stx/stx/libbasic/EncodedStream.st,v 1.12 2009-06-12 13:37:31 mb Exp $' |
8047 | 166 |
! ! |