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