author | Claus Gittinger <cg@exept.de> |
Mon, 26 Aug 2019 23:13:45 +0200 | |
changeset 5168 | fee2c272b167 |
parent 5152 | 8834593e27e1 |
child 5459 | 70e5b29dd7d3 |
permissions | -rw-r--r-- |
4741 | 1 |
"{ Encoding: utf8 }" |
2 |
||
1965 | 3 |
" |
4 |
COPYRIGHT (c) 2002 by eXept Software AG |
|
5 |
All Rights Reserved |
|
6 |
||
7 |
This software is furnished under a license and may be used |
|
8 |
only in accordance with the terms of that license and with the |
|
9 |
inclusion of the above copyright notice. This software may not |
|
10 |
be provided or otherwise made available to, or used by, any |
|
11 |
other person. No title to or ownership of the software is |
|
12 |
hereby transferred. |
|
13 |
" |
|
14 |
"{ Package: 'stx:libbasic2' }" |
|
15 |
||
3548
5424405a96ed
initialization done lazily (to speed up startup)
Claus Gittinger <cg@exept.de>
parents:
2638
diff
changeset
|
16 |
"{ NameSpace: Smalltalk }" |
5424405a96ed
initialization done lazily (to speed up startup)
Claus Gittinger <cg@exept.de>
parents:
2638
diff
changeset
|
17 |
|
1965 | 18 |
ObjectCoder subclass:#BaseNCoder |
4741 | 19 |
instanceVariableNames:'buffer bits charCount peekByte atEnd lineLimit mapping |
20 |
reverseMapping' |
|
1965 | 21 |
classVariableNames:'' |
22 |
poolDictionaries:'' |
|
23 |
category:'System-Storage' |
|
24 |
! |
|
25 |
||
26 |
!BaseNCoder class methodsFor:'documentation'! |
|
27 |
||
28 |
copyright |
|
29 |
" |
|
30 |
COPYRIGHT (c) 2002 by eXept Software AG |
|
31 |
All Rights Reserved |
|
32 |
||
33 |
This software is furnished under a license and may be used |
|
34 |
only in accordance with the terms of that license and with the |
|
35 |
inclusion of the above copyright notice. This software may not |
|
36 |
be provided or otherwise made available to, or used by, any |
|
37 |
other person. No title to or ownership of the software is |
|
38 |
hereby transferred. |
|
39 |
" |
|
40 |
! |
|
41 |
||
42 |
documentation |
|
43 |
" |
|
44 |
Abstract superclass of Base64Coder and Base32Coder |
|
4278 | 45 |
Their main entry point API is |
46 |
<BaseNCoder> encode:aStringOrBytes |
|
47 |
and |
|
48 |
<BaseNCoder> decode:aString |
|
1965 | 49 |
|
4278 | 50 |
If the decoder should return a string, use |
51 |
<BaseNCoder> decodeAsString:aString. |
|
52 |
||
53 |
[examples:] |
|
54 |
Base64Coder encode:'helloWorld' |
|
55 |
||
56 |
Base64Coder decode:'aGVsbG9Xb3JsZA==' |
|
57 |
||
58 |
Base64Coder decodeAsString:'aGVsbG9Xb3JsZA==' |
|
59 |
||
1965 | 60 |
[author:] |
61 |
Stefan Vogel (stefan@zwerg) |
|
62 |
||
63 |
[instance variables:] |
|
64 |
buffer SmallInteger buffered data |
|
65 |
bits SmallInteger Number of valid bits in buffer |
|
66 |
charCount SmallInteger Number of characters since last cr |
|
67 |
atEnd Boolean true if end of Base64 string reached |
|
68 |
||
69 |
[class variables:] |
|
70 |
||
71 |
[see also:] |
|
72 |
||
73 |
" |
|
74 |
! ! |
|
75 |
||
3548
5424405a96ed
initialization done lazily (to speed up startup)
Claus Gittinger <cg@exept.de>
parents:
2638
diff
changeset
|
76 |
!BaseNCoder class methodsFor:'initialization'! |
5424405a96ed
initialization done lazily (to speed up startup)
Claus Gittinger <cg@exept.de>
parents:
2638
diff
changeset
|
77 |
|
5424405a96ed
initialization done lazily (to speed up startup)
Claus Gittinger <cg@exept.de>
parents:
2638
diff
changeset
|
78 |
initializeMappings |
5424405a96ed
initialization done lazily (to speed up startup)
Claus Gittinger <cg@exept.de>
parents:
2638
diff
changeset
|
79 |
self subclassResponsibility |
4741 | 80 |
|
81 |
" |
|
82 |
self withAllSubclassesDo:#initialize |
|
83 |
" |
|
84 |
||
85 |
"Modified (comment): / 30-09-2018 / 15:39:16 / Claus Gittinger" |
|
86 |
! |
|
87 |
||
88 |
mapping |
|
89 |
self subclassResponsibility |
|
90 |
||
91 |
"Created: / 30-09-2018 / 15:30:08 / Claus Gittinger" |
|
92 |
! |
|
93 |
||
94 |
reverseMapping |
|
95 |
self subclassResponsibility |
|
96 |
||
97 |
"Created: / 30-09-2018 / 15:30:11 / Claus Gittinger" |
|
98 |
! |
|
99 |
||
100 |
reverseMappingFor:mapping |
|
101 |
"initialize class variables" |
|
102 |
||
103 |
|revMapping| |
|
104 |
||
105 |
revMapping := ByteArray new:128 withAll:255. |
|
106 |
mapping keysAndValuesDo:[:idx :char| |
|
107 |
revMapping at:char codePoint put:idx-1. |
|
108 |
]. |
|
109 |
^ revMapping |
|
110 |
||
111 |
"Created: / 30-09-2018 / 15:34:37 / Claus Gittinger" |
|
3548
5424405a96ed
initialization done lazily (to speed up startup)
Claus Gittinger <cg@exept.de>
parents:
2638
diff
changeset
|
112 |
! ! |
5424405a96ed
initialization done lazily (to speed up startup)
Claus Gittinger <cg@exept.de>
parents:
2638
diff
changeset
|
113 |
|
1965 | 114 |
!BaseNCoder class methodsFor:'instance creation'! |
115 |
||
116 |
new |
|
3548
5424405a96ed
initialization done lazily (to speed up startup)
Claus Gittinger <cg@exept.de>
parents:
2638
diff
changeset
|
117 |
self initializeMappings. |
1965 | 118 |
^ self basicNew initialize |
119 |
! ! |
|
120 |
||
4893 | 121 |
!BaseNCoder class methodsFor:'constants'! |
122 |
||
123 |
lineLimit |
|
124 |
^ 76. "/ RFC 2045 says: max 76 characters in one line |
|
125 |
||
126 |
"Created: / 21-03-2019 / 21:54:41 / Claus Gittinger" |
|
127 |
! ! |
|
128 |
||
2090 | 129 |
!BaseNCoder class methodsFor:'decoding'! |
130 |
||
131 |
decodeAsString:encodedString |
|
132 |
"decode a base-n encoded string. |
|
133 |
We already expect a string instead of a ByteArray" |
|
134 |
||
135 |
^ (self on:encodedString readStream) stringUpToEnd |
|
136 |
! ! |
|
137 |
||
4310 | 138 |
!BaseNCoder class methodsFor:'queries'! |
139 |
||
140 |
isAbstract |
|
141 |
"Return if this class is an abstract class. |
|
142 |
True is returned here for myself only; false for subclasses. |
|
143 |
Abstract subclasses must redefine this again." |
|
144 |
||
145 |
^ self == BaseNCoder. |
|
146 |
! ! |
|
147 |
||
1965 | 148 |
!BaseNCoder methodsFor:'accessing'! |
149 |
||
150 |
lineLimit:something |
|
151 |
"set the line length of the encoded output. |
|
152 |
Default is a line length of 76 characters. |
|
153 |
||
154 |
If nil, no line breaks will be done." |
|
155 |
||
156 |
lineLimit := something. |
|
157 |
! ! |
|
158 |
||
159 |
!BaseNCoder methodsFor:'decoding'! |
|
160 |
||
161 |
next |
|
162 |
"answer the next decoded byte" |
|
163 |
||
164 |
|b| |
|
165 |
||
166 |
peekByte notNil ifTrue:[ |
|
167 |
b := peekByte. |
|
168 |
peekByte := nil. |
|
169 |
^ b |
|
170 |
]. |
|
171 |
^ self basicNext. |
|
172 |
! |
|
173 |
||
2638 | 174 |
next:count |
175 |
"return the next count bytes of the stream as ByteArray" |
|
176 |
||
177 |
|answerStream |
|
178 |
cnt "{ Class: SmallInteger }" | |
|
179 |
||
180 |
cnt := count. |
|
181 |
answerStream := WriteStream on:(ByteArray new:cnt). |
|
182 |
answerStream signalAtEnd:true. |
|
183 |
1 to:cnt do:[:index | |
|
184 |
|next| |
|
185 |
||
186 |
next := self next. |
|
187 |
next isNil ifTrue:[ |
|
188 |
"if next did not raise EndOfStreamError, we have to do it" |
|
189 |
EndOfStreamError raiseRequestFrom:self. |
|
190 |
"if you proceed, you get what we have already collected" |
|
191 |
^ answerStream contents |
|
192 |
]. |
|
193 |
answerStream nextPut:next. |
|
194 |
]. |
|
195 |
^ answerStream contents |
|
196 |
! |
|
197 |
||
1965 | 198 |
peek |
199 |
"answer the next decoded byte. Do not consume this byte" |
|
200 |
||
201 |
peekByte isNil ifTrue:[ |
|
202 |
peekByte := self basicNext. |
|
203 |
]. |
|
204 |
^ peekByte |
|
205 |
! ! |
|
206 |
||
207 |
!BaseNCoder methodsFor:'encoding'! |
|
208 |
||
4893 | 209 |
encodingOf:anObject with:aParameter |
210 |
lineLimit := aParameter. |
|
211 |
^ super encodingOf:anObject with:aParameter |
|
212 |
||
213 |
"Created: / 21-03-2019 / 22:01:20 / Claus Gittinger" |
|
214 |
! |
|
215 |
||
1965 | 216 |
visitByteArray:aByteArray with:aParameter |
217 |
^ self |
|
3764 | 218 |
nextPutBytes:aByteArray; |
1965 | 219 |
flush. |
220 |
||
221 |
" |
|
3764 | 222 |
Base64Coder encodingOf:#[1 2 3 4 5 6 255] |
1965 | 223 |
" |
224 |
! |
|
225 |
||
226 |
visitObject:anObject with:aParameter |
|
227 |
"not defined. Use nextPut or nextPutAll:. |
|
228 |
Could encode the printString here" |
|
229 |
||
230 |
^ self shouldNotImplement |
|
231 |
! |
|
232 |
||
2160 | 233 |
visitStream:aStream with:aParameter |
3764 | 234 |
aStream copyToEndInto:self. |
2160 | 235 |
self flush. |
236 |
||
237 |
" |
|
238 |
Base64Coder encodingOf:#[1 2 3 4 5 6 255] |
|
239 |
Base64Coder encodingOf:#[1 2 3 4 5 6 255] readStream |
|
240 |
" |
|
241 |
! |
|
242 |
||
1965 | 243 |
visitString:aString with:aParameter |
244 |
^ self |
|
3764 | 245 |
nextPutAll:aString; |
1965 | 246 |
flush. |
247 |
||
248 |
" |
|
249 |
|encoded decoded decoder| |
|
250 |
||
3764 | 251 |
encoded := Base64Coder encode:'hello world'. |
1965 | 252 |
decoded := #[] writeStream. |
253 |
decoder := Base64Coder on:encoded readStream. |
|
254 |
[decoder atEnd] whileFalse:[ |
|
255 |
decoded nextPut:(decoder next). |
|
256 |
]. |
|
257 |
decoded := decoded contents. |
|
258 |
decoded asString. |
|
259 |
" |
|
260 |
! ! |
|
261 |
||
262 |
!BaseNCoder methodsFor:'initialization'! |
|
263 |
||
264 |
emptyWriteStream |
|
265 |
"answer an empty stream. We encode as string" |
|
266 |
||
267 |
^ WriteStream on:(String new:64) |
|
268 |
! |
|
269 |
||
270 |
initialize |
|
271 |
||
4305 | 272 |
<modifier: #super> "must be called if redefined" |
273 |
||
1965 | 274 |
buffer := bits := charCount := 0. |
275 |
lineLimit := 76. "RFC 2045 says: max 76 characters in one line" |
|
276 |
atEnd := false. |
|
4305 | 277 |
|
4741 | 278 |
mapping := self class mapping. |
279 |
reverseMapping := self class reverseMapping. |
|
280 |
||
4305 | 281 |
"Modified: / 08-02-2017 / 00:33:07 / cg" |
4741 | 282 |
"Modified: / 30-09-2018 / 15:29:41 / Claus Gittinger" |
1965 | 283 |
! ! |
284 |
||
285 |
!BaseNCoder methodsFor:'misc'! |
|
286 |
||
287 |
reset |
|
288 |
"reset to initial state" |
|
289 |
||
290 |
super reset. |
|
291 |
buffer := bits := charCount := 0. |
|
292 |
atEnd := false. |
|
293 |
peekByte := nil. |
|
294 |
! ! |
|
295 |
||
296 |
!BaseNCoder methodsFor:'private'! |
|
297 |
||
298 |
basicNext |
|
299 |
"answer the next decoded byte. |
|
300 |
No peekByte handling is done here." |
|
301 |
||
302 |
|b| |
|
303 |
||
304 |
bits == 0 ifTrue:[ |
|
305 |
self fillBuffer. |
|
306 |
bits == 0 ifTrue:[ |
|
307 |
^ stream pastEndRead. |
|
308 |
] |
|
309 |
]. |
|
310 |
b := (buffer bitShift:(8 - bits)) bitAnd:16rFF. |
|
311 |
bits := bits - 8. |
|
312 |
||
313 |
^ b. |
|
314 |
! ! |
|
315 |
||
316 |
!BaseNCoder methodsFor:'queries'! |
|
317 |
||
318 |
atEnd |
|
319 |
"answer true, if no more bytes can be read" |
|
320 |
||
321 |
bits == 0 ifTrue:[ |
|
322 |
atEnd ifTrue:[^ true]. |
|
323 |
self fillBuffer. |
|
324 |
bits == 0 ifTrue:[^ true]. |
|
325 |
]. |
|
326 |
^ false. |
|
327 |
! |
|
328 |
||
329 |
binary |
|
330 |
"switch to binary mode - nothing is done here. |
|
331 |
Defined for compatibility with ExternalStream." |
|
332 |
||
333 |
^ self |
|
334 |
! |
|
335 |
||
4839 | 336 |
binary:beBinaryBool |
337 |
"ExternalStream protocol compatibility" |
|
338 |
||
339 |
^ false "/ no-op, I am not in binary mode |
|
340 |
||
341 |
"Created: / 13-03-2019 / 19:15:17 / Stefan Vogel" |
|
342 |
! |
|
343 |
||
1965 | 344 |
isStream |
345 |
"we simulate a stream" |
|
346 |
||
347 |
^ true |
|
348 |
! ! |
|
349 |
||
350 |
!BaseNCoder methodsFor:'stream compatibility'! |
|
351 |
||
4842 | 352 |
bufferSizeForBulkCopy |
353 |
^ 1024 |
|
354 |
||
355 |
"Created: / 14-03-2019 / 12:58:47 / Stefan Vogel" |
|
356 |
! |
|
357 |
||
4928 | 358 |
nextByte |
359 |
"ExternalStream compatibility" |
|
360 |
||
361 |
^ self next |
|
362 |
||
363 |
"Created: / 27-03-2019 / 23:39:24 / stefan" |
|
364 |
! |
|
365 |
||
366 |
nextBytes:count into:anObject |
|
367 |
"read the next count bytes into an object and return the number of |
|
368 |
bytes read. On EOF, 0 is returned. |
|
369 |
If the receiver is some socket/pipe-like stream, an exception |
|
370 |
is raised if the connection is broken. |
|
371 |
||
372 |
The object must have non-pointer indexed instvars (i.e. it must be |
|
373 |
a ByteArray, String, Float- or DoubleArray). |
|
374 |
If anObject is a string or byteArray and reused, this provides the |
|
375 |
fastest possible physical I/O (since no new objects are allocated). |
|
376 |
||
377 |
Use with care - non object oriented i/o. |
|
378 |
Warning: in general, you cannot use this method to pass data from other |
|
379 |
architectures since it does not care for byte order or float representation." |
|
380 |
||
381 |
^ self nextBytes:count into:anObject startingAt:1 |
|
382 |
||
383 |
"Created: / 27-03-2019 / 23:37:31 / stefan" |
|
384 |
! |
|
385 |
||
386 |
nextBytes:numBytes into:anObject startingAt:initialIndex |
|
387 |
"copy bytes into anObject starting at offset" |
|
388 |
||
389 |
|n "{Class: SmallInteger }"| |
|
390 |
||
391 |
n := 0. |
|
392 |
||
393 |
[n ~= numBytes and:[self atEnd not]] whileTrue:[ |
|
394 |
anObject byteAt:initialIndex+n put:self next. |
|
395 |
n := n + 1. |
|
396 |
]. |
|
397 |
^ n |
|
398 |
||
399 |
"Created: / 27-03-2019 / 23:36:59 / stefan" |
|
400 |
! |
|
401 |
||
402 |
nextBytesInto:anObject startingAt:initialIndex |
|
1965 | 403 |
"copy bytes into anObject starting at offset" |
404 |
||
4928 | 405 |
|n "{Class: SmallInteger }"| |
1965 | 406 |
|
4928 | 407 |
n := 0. |
408 |
||
1965 | 409 |
[self atEnd] whileFalse:[ |
4928 | 410 |
anObject byteAt:initialIndex+n put:self next. |
411 |
n := n + 1. |
|
1965 | 412 |
]. |
4928 | 413 |
^ n |
414 |
||
415 |
"Modified: / 27-03-2019 / 23:48:16 / stefan" |
|
416 |
! |
|
417 |
||
418 |
nextInt32MSB:msbFlag |
|
419 |
"return a signed long (4 bytes) from the stream. |
|
420 |
The receiver must support reading of binary bytes. |
|
421 |
||
422 |
The msbFlag argument controls if the integer is to be read with |
|
423 |
most-significant-byte-first (true) or least-first (false). |
|
424 |
This interface is provided to allow talking to external programs, |
|
425 |
where it's known that the byte order is some definite one. |
|
426 |
If you don't care (i.e. talk to other smalltalks) or you can control the |
|
427 |
order, please use the corresponding xxxNet methods, which use a standard |
|
428 |
network byte order. |
|
429 |
||
430 |
1-to-1 copy from Stream" |
|
431 |
||
432 |
|b1 b2 b3 b4 uval "{ Class: SmallInteger }" val| |
|
433 |
||
434 |
b1 := self nextByte. |
|
435 |
b2 := self nextByte. |
|
436 |
b3 := self nextByte. |
|
437 |
b4 := self nextByte. |
|
438 |
||
439 |
msbFlag ifTrue:[ |
|
440 |
"most significant first" |
|
441 |
uval := (b1 bitShift:8) bitOr:b2. |
|
442 |
uval := (uval bitShift:8) bitOr:b3. |
|
443 |
val := (uval bitShift:8) bitOr:b4. |
|
444 |
] ifFalse:[ |
|
445 |
"least significant first" |
|
446 |
uval := (b4 bitShift:8) bitOr:b3. |
|
447 |
uval := (uval bitShift:8) bitOr:b2. |
|
448 |
val := (uval bitShift:8) bitOr:b1. |
|
449 |
]. |
|
450 |
"change from unsigned 0..FFFFFFFF to signed -80000000..7FFFFFFF" |
|
451 |
||
452 |
val >= 16r80000000 ifTrue:[ |
|
453 |
^ val - 16r100000000 |
|
454 |
]. |
|
455 |
^ val |
|
456 |
||
457 |
" |
|
458 |
|bytes s| |
|
459 |
||
460 |
bytes := #[16rFF 16rFF 16rFF 16rFF]. |
|
461 |
s := bytes readStream. |
|
462 |
Transcript showCR:(s nextInt32MSB:true). |
|
463 |
s reset. |
|
464 |
Transcript showCR:(s nextInt32MSB:false). |
|
465 |
||
466 |
bytes := #[16r12 16r34 16r56 16r78]. |
|
467 |
s := bytes readStream. |
|
468 |
Transcript showCR:(s nextInt32MSB:true). |
|
469 |
s reset. |
|
470 |
Transcript showCR:(s nextInt32MSB:false). |
|
471 |
||
472 |
bytes := #[16r89 16rab 16rcd 16ref]. |
|
473 |
s := bytes readStream. |
|
474 |
Transcript showCR:(s nextInt32MSB:true). |
|
475 |
s reset. |
|
476 |
Transcript showCR:(s nextInt32MSB:false). |
|
477 |
" |
|
478 |
||
479 |
"Created: / 27-03-2019 / 23:38:32 / stefan" |
|
1965 | 480 |
! |
481 |
||
3764 | 482 |
nextPut:aByte |
5168 | 483 |
"encode aByte on the output stream. |
484 |
Answer aByte" |
|
3764 | 485 |
|
5152 | 486 |
self nextPutByte:aByte asInteger. |
5168 | 487 |
^ aByte |
3764 | 488 |
! |
489 |
||
3760 | 490 |
nextPutAll:aCollection startingAt:first to:last |
491 |
"append the elements with index from first to last |
|
3761 | 492 |
of the argument, aCollection onto the receiver." |
3760 | 493 |
|
494 |
aCollection from:first to:last do:[:element | |
|
3764 | 495 |
self nextPutByte:element |
3760 | 496 |
]. |
5152 | 497 |
|
3760 | 498 |
! |
499 |
||
3764 | 500 |
nextPutBytes:aCollectionOfBytes |
501 |
"encode all objects from the argument" |
|
502 |
||
503 |
aCollectionOfBytes do:[:o | |
|
504 |
self nextPutByte:o |
|
505 |
] |
|
506 |
! |
|
507 |
||
4928 | 508 |
skip:numberToSkip |
509 |
"skip numberToSkip objects, return the receiver. |
|
510 |
1-to-1 copy from Stream." |
|
511 |
||
512 |
"don't know how to unread ..." |
|
513 |
numberToSkip < 0 ifTrue:[ |
|
514 |
PositionError raiseRequest. |
|
515 |
^ self |
|
516 |
]. |
|
517 |
numberToSkip timesRepeat:[self next] |
|
518 |
||
519 |
"Created: / 27-03-2019 / 23:43:26 / stefan" |
|
520 |
! |
|
521 |
||
2090 | 522 |
stringUpToEnd |
523 |
"return a collection of the elements up-to the end" |
|
524 |
||
525 |
|answerStream| |
|
526 |
||
527 |
answerStream := WriteStream on:(String new:128). |
|
528 |
peekByte notNil ifTrue:[ |
|
529 |
answerStream nextPut:(Character codePoint:peekByte). |
|
530 |
peekByte := nil. |
|
531 |
]. |
|
532 |
[ |
|
533 |
[bits >= 8] whileTrue:[ |
|
534 |
answerStream nextPut:(Character codePoint:((buffer bitShift:(8 - bits)) bitAnd:16rFF)). |
|
535 |
bits := bits - 8. |
|
536 |
]. |
|
537 |
atEnd ifTrue:[ |
|
538 |
bits ~~ 0 ifTrue:[ |
|
539 |
answerStream nextPut:(Character codePoint:(buffer bitAnd:16rFF)). |
|
540 |
bits := 0. |
|
541 |
] |
|
542 |
] ifFalse:[ |
|
543 |
self fillBuffer. |
|
544 |
]. |
|
545 |
] doWhile:[bits > 0]. |
|
546 |
||
547 |
^ answerStream contents |
|
548 |
! |
|
549 |
||
1965 | 550 |
upToEnd |
551 |
"return a collection of the elements up-to the end" |
|
552 |
||
553 |
|answerStream| |
|
554 |
||
555 |
answerStream := WriteStream on:(ByteArray new:128). |
|
556 |
peekByte notNil ifTrue:[ |
|
557 |
answerStream nextPut:peekByte. |
|
558 |
peekByte := nil. |
|
559 |
]. |
|
560 |
[ |
|
561 |
[bits >= 8] whileTrue:[ |
|
562 |
answerStream nextPut:((buffer bitShift:(8 - bits)) bitAnd:16rFF). |
|
563 |
bits := bits - 8. |
|
564 |
]. |
|
4752 | 565 |
atEnd ifFalse:[ |
1965 | 566 |
self fillBuffer. |
567 |
]. |
|
568 |
] doWhile:[bits > 0]. |
|
569 |
||
570 |
^ answerStream contents |
|
4752 | 571 |
|
572 |
"Modified: / 30-09-2018 / 16:37:03 / Claus Gittinger" |
|
1965 | 573 |
! ! |
574 |
||
575 |
!BaseNCoder methodsFor:'subclass responsibility'! |
|
576 |
||
577 |
fillBuffer |
|
578 |
"fill buffer with next n characters each representing m bits" |
|
579 |
||
580 |
^ self subclassResponsibility. |
|
581 |
! |
|
582 |
||
583 |
flush |
|
584 |
"flush the remaining bits of buffer. |
|
585 |
The number of bits in buffer is not a multiple of m, so we pad |
|
586 |
the buffer and signal that padding has been done via $= characters." |
|
587 |
||
588 |
^ self subclassResponsibility. |
|
589 |
! |
|
590 |
||
3764 | 591 |
nextPutByte:aByte |
1965 | 592 |
"encode aByte on the output stream" |
593 |
||
594 |
^ self subclassResponsibility. |
|
595 |
! ! |
|
596 |
||
597 |
!BaseNCoder class methodsFor:'documentation'! |
|
598 |
||
599 |
version |
|
3760 | 600 |
^ '$Header$' |
3761 | 601 |
! |
602 |
||
603 |
version_CVS |
|
604 |
^ '$Header$' |
|
1965 | 605 |
! ! |
3548
5424405a96ed
initialization done lazily (to speed up startup)
Claus Gittinger <cg@exept.de>
parents:
2638
diff
changeset
|
606 |