EncodedStream.st
author Stefan Vogel <sv@exept.de>
Tue, 13 Jul 2004 15:10:20 +0200
changeset 8447 9bdea3431846
parent 8444 354d0c48618d
child 8459 1f59b17291a3
permissions -rw-r--r--
EncodedStream inherts from PeekableStream
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8148
dbf64e3142d9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8147
diff changeset
     1
"
dbf64e3142d9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8147
diff changeset
     2
 COPYRIGHT (c) 2004 by eXept Software AG
dbf64e3142d9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8147
diff changeset
     3
              All Rights Reserved
dbf64e3142d9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8147
diff changeset
     4
dbf64e3142d9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8147
diff changeset
     5
 This software is furnished under a license and may be used
dbf64e3142d9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8147
diff changeset
     6
 only in accordance with the terms of that license and with the
dbf64e3142d9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8147
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
dbf64e3142d9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8147
diff changeset
     8
 be provided or otherwise made available to, or used by, any
dbf64e3142d9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8147
diff changeset
     9
 other person.  No title to or ownership of the software is
dbf64e3142d9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8147
diff changeset
    10
 hereby transferred.
dbf64e3142d9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8147
diff changeset
    11
"
dbf64e3142d9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8147
diff changeset
    12
8047
9cfc575512eb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
"{ Package: 'stx:libbasic' }"
9cfc575512eb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
8447
9bdea3431846 EncodedStream inherts from PeekableStream
Stefan Vogel <sv@exept.de>
parents: 8444
diff changeset
    15
PeekableStream subclass:#EncodedStream
8047
9cfc575512eb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
	instanceVariableNames:'encoder stream'
9cfc575512eb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	classVariableNames:''
9cfc575512eb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
	poolDictionaries:''
9cfc575512eb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
	category:'Collections-Text-Encodings'
9cfc575512eb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
!
9cfc575512eb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
8148
dbf64e3142d9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8147
diff changeset
    22
!EncodedStream class methodsFor:'documentation'!
dbf64e3142d9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8147
diff changeset
    23
dbf64e3142d9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8147
diff changeset
    24
copyright
dbf64e3142d9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8147
diff changeset
    25
"
dbf64e3142d9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8147
diff changeset
    26
 COPYRIGHT (c) 2004 by eXept Software AG
dbf64e3142d9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8147
diff changeset
    27
              All Rights Reserved
dbf64e3142d9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8147
diff changeset
    28
dbf64e3142d9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8147
diff changeset
    29
 This software is furnished under a license and may be used
dbf64e3142d9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8147
diff changeset
    30
 only in accordance with the terms of that license and with the
dbf64e3142d9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8147
diff changeset
    31
 inclusion of the above copyright notice.   This software may not
dbf64e3142d9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8147
diff changeset
    32
 be provided or otherwise made available to, or used by, any
dbf64e3142d9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8147
diff changeset
    33
 other person.  No title to or ownership of the software is
dbf64e3142d9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8147
diff changeset
    34
 hereby transferred.
dbf64e3142d9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8147
diff changeset
    35
"
dbf64e3142d9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8147
diff changeset
    36
! !
8047
9cfc575512eb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
9cfc575512eb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
!EncodedStream class methodsFor:'instance creation'!
9cfc575512eb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
9cfc575512eb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
stream:streamArg encoder:encoder
9cfc575512eb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
    ^ (self basicNew) stream:streamArg; encoder:encoder
9cfc575512eb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
! !
9cfc575512eb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
9cfc575512eb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
!EncodedStream methodsFor:'accessing'!
9cfc575512eb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
9cfc575512eb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
encoder
9cfc575512eb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
    ^ encoder
9cfc575512eb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
!
9cfc575512eb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
9cfc575512eb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
encoder:something
9cfc575512eb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
    encoder := something.
9cfc575512eb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
!
9cfc575512eb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
9cfc575512eb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
stream
9cfc575512eb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
    ^ stream
9cfc575512eb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
!
9cfc575512eb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
9cfc575512eb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
stream:something
9cfc575512eb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
    stream := something.
9cfc575512eb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
! !
9cfc575512eb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
9cfc575512eb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
!EncodedStream methodsFor:'stream protocol'!
9cfc575512eb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
8175
3548845d3c09 more stream protocol
Claus Gittinger <cg@exept.de>
parents: 8165
diff changeset
    64
atEnd
3548845d3c09 more stream protocol
Claus Gittinger <cg@exept.de>
parents: 8165
diff changeset
    65
    ^ stream atEnd
3548845d3c09 more stream protocol
Claus Gittinger <cg@exept.de>
parents: 8165
diff changeset
    66
!
3548845d3c09 more stream protocol
Claus Gittinger <cg@exept.de>
parents: 8165
diff changeset
    67
8165
d6446fc1ea3b more stream protocol
ca
parents: 8148
diff changeset
    68
close
d6446fc1ea3b more stream protocol
ca
parents: 8148
diff changeset
    69
    stream close
d6446fc1ea3b more stream protocol
ca
parents: 8148
diff changeset
    70
!
d6446fc1ea3b more stream protocol
ca
parents: 8148
diff changeset
    71
8213
0f9d34b2afb2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8197
diff changeset
    72
cr
0f9d34b2afb2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8197
diff changeset
    73
    stream cr
0f9d34b2afb2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8197
diff changeset
    74
!
0f9d34b2afb2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8197
diff changeset
    75
8147
416bcaa573ef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 8047
diff changeset
    76
nextChunk
8175
3548845d3c09 more stream protocol
Claus Gittinger <cg@exept.de>
parents: 8165
diff changeset
    77
    |chunk|
3548845d3c09 more stream protocol
Claus Gittinger <cg@exept.de>
parents: 8165
diff changeset
    78
3548845d3c09 more stream protocol
Claus Gittinger <cg@exept.de>
parents: 8165
diff changeset
    79
    chunk := stream nextChunk.
3548845d3c09 more stream protocol
Claus Gittinger <cg@exept.de>
parents: 8165
diff changeset
    80
    chunk isNil ifTrue:[^ chunk].
3548845d3c09 more stream protocol
Claus Gittinger <cg@exept.de>
parents: 8165
diff changeset
    81
    ^ encoder decodeString:chunk
8147
416bcaa573ef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 8047
diff changeset
    82
!
416bcaa573ef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 8047
diff changeset
    83
8213
0f9d34b2afb2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8197
diff changeset
    84
nextChunkPut:chunk
0f9d34b2afb2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8197
diff changeset
    85
    stream nextChunkPut:(encoder encodeString:chunk)
0f9d34b2afb2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8197
diff changeset
    86
!
0f9d34b2afb2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8197
diff changeset
    87
8047
9cfc575512eb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
nextPut:aCharacter
9cfc575512eb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
    self nextPutAll:(aCharacter asString).
9cfc575512eb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
!
9cfc575512eb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
9cfc575512eb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
nextPutAll:aCollection
9cfc575512eb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
    stream nextPutAll:(encoder encodeString:aCollection).
8147
416bcaa573ef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 8047
diff changeset
    94
!
416bcaa573ef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 8047
diff changeset
    95
8444
354d0c48618d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8213
diff changeset
    96
peek
354d0c48618d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8213
diff changeset
    97
    ^ stream peek
354d0c48618d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8213
diff changeset
    98
!
354d0c48618d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8213
diff changeset
    99
8175
3548845d3c09 more stream protocol
Claus Gittinger <cg@exept.de>
parents: 8165
diff changeset
   100
peekFor:aCharacter
3548845d3c09 more stream protocol
Claus Gittinger <cg@exept.de>
parents: 8165
diff changeset
   101
    ^ stream peekFor:aCharacter
3548845d3c09 more stream protocol
Claus Gittinger <cg@exept.de>
parents: 8165
diff changeset
   102
!
3548845d3c09 more stream protocol
Claus Gittinger <cg@exept.de>
parents: 8165
diff changeset
   103
8165
d6446fc1ea3b more stream protocol
ca
parents: 8148
diff changeset
   104
position
d6446fc1ea3b more stream protocol
ca
parents: 8148
diff changeset
   105
    ^ stream position
d6446fc1ea3b more stream protocol
ca
parents: 8148
diff changeset
   106
!
d6446fc1ea3b more stream protocol
ca
parents: 8148
diff changeset
   107
8197
4fccb2671b9d stream protocol
Claus Gittinger <cg@exept.de>
parents: 8175
diff changeset
   108
position0Based
4fccb2671b9d stream protocol
Claus Gittinger <cg@exept.de>
parents: 8175
diff changeset
   109
    ^ stream position0Based
4fccb2671b9d stream protocol
Claus Gittinger <cg@exept.de>
parents: 8175
diff changeset
   110
!
4fccb2671b9d stream protocol
Claus Gittinger <cg@exept.de>
parents: 8175
diff changeset
   111
4fccb2671b9d stream protocol
Claus Gittinger <cg@exept.de>
parents: 8175
diff changeset
   112
position0Based:newPosition
4fccb2671b9d stream protocol
Claus Gittinger <cg@exept.de>
parents: 8175
diff changeset
   113
    stream position0Based:newPosition
4fccb2671b9d stream protocol
Claus Gittinger <cg@exept.de>
parents: 8175
diff changeset
   114
!
4fccb2671b9d stream protocol
Claus Gittinger <cg@exept.de>
parents: 8175
diff changeset
   115
8175
3548845d3c09 more stream protocol
Claus Gittinger <cg@exept.de>
parents: 8165
diff changeset
   116
position1Based
3548845d3c09 more stream protocol
Claus Gittinger <cg@exept.de>
parents: 8165
diff changeset
   117
    ^ stream position1Based
3548845d3c09 more stream protocol
Claus Gittinger <cg@exept.de>
parents: 8165
diff changeset
   118
!
3548845d3c09 more stream protocol
Claus Gittinger <cg@exept.de>
parents: 8165
diff changeset
   119
8147
416bcaa573ef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 8047
diff changeset
   120
position1Based:newPosition
416bcaa573ef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 8047
diff changeset
   121
    stream position1Based:newPosition
8175
3548845d3c09 more stream protocol
Claus Gittinger <cg@exept.de>
parents: 8165
diff changeset
   122
!
3548845d3c09 more stream protocol
Claus Gittinger <cg@exept.de>
parents: 8165
diff changeset
   123
8197
4fccb2671b9d stream protocol
Claus Gittinger <cg@exept.de>
parents: 8175
diff changeset
   124
position:newPosition
4fccb2671b9d stream protocol
Claus Gittinger <cg@exept.de>
parents: 8175
diff changeset
   125
    stream position:newPosition
4fccb2671b9d stream protocol
Claus Gittinger <cg@exept.de>
parents: 8175
diff changeset
   126
!
4fccb2671b9d stream protocol
Claus Gittinger <cg@exept.de>
parents: 8175
diff changeset
   127
8213
0f9d34b2afb2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8197
diff changeset
   128
setToEnd
0f9d34b2afb2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8197
diff changeset
   129
    stream setToEnd
0f9d34b2afb2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8197
diff changeset
   130
!
0f9d34b2afb2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8197
diff changeset
   131
8175
3548845d3c09 more stream protocol
Claus Gittinger <cg@exept.de>
parents: 8165
diff changeset
   132
skipSeparators
3548845d3c09 more stream protocol
Claus Gittinger <cg@exept.de>
parents: 8165
diff changeset
   133
    ^ stream skipSeparators
8047
9cfc575512eb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
! !
9cfc575512eb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
9cfc575512eb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
!EncodedStream class methodsFor:'documentation'!
9cfc575512eb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
9cfc575512eb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
version
8447
9bdea3431846 EncodedStream inherts from PeekableStream
Stefan Vogel <sv@exept.de>
parents: 8444
diff changeset
   139
    ^ '$Header: /cvs/stx/stx/libbasic/EncodedStream.st,v 1.9 2004-07-13 13:10:20 stefan Exp $'
8047
9cfc575512eb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
! !