235 |
235 |
236 ^ self subclassResponsibility |
236 ^ self subclassResponsibility |
237 ! |
237 ! |
238 |
238 |
239 signalAtEnd |
239 signalAtEnd |
240 "return the signalAtEnd flag setting. |
240 "return the signalAtEnd flag setting. |
241 If true, reading past the end will always raise an EndOfStream exception. |
241 If true, reading past the end will always raise an EndOfStream exception. |
242 If false, no exception is raised and nil is returned from all reading messages. |
242 If false, no exception is raised and nil is returned from all reading messages. |
243 If nil (default), the exception is raised if there is a handler; otherwise, nil is returned. |
243 If nil (default), the exception is raised if there is a handler; otherwise, nil is returned. |
244 The default is nil (for ST80 compatibility) i.e. to only raise a signal if there is a handler." |
244 The default is nil (for ST80 compatibility) i.e. to only raise a signal if there is a handler." |
245 |
245 |
246 ^ signalAtEnd |
246 ^ signalAtEnd |
315 |
315 |
316 !Stream methodsFor:'converting'! |
316 !Stream methodsFor:'converting'! |
317 |
317 |
318 asLineNumberReadStream |
318 asLineNumberReadStream |
319 "returns a new stream, which keeps track of the line number. |
319 "returns a new stream, which keeps track of the line number. |
320 It can be asked for the current linenumber, |
320 It can be asked for the current linenumber, |
321 which is useful eg. for error message generation" |
321 which is useful eg. for error message generation" |
322 |
322 |
323 ^ LineNumberReadStream on:self |
323 ^ LineNumberReadStream on:self |
324 ! |
324 ! |
325 |
325 |
504 "Modified: / 18-11-2006 / 15:36:44 / cg" |
504 "Modified: / 18-11-2006 / 15:36:44 / cg" |
505 ! |
505 ! |
506 |
506 |
507 pastEndRead |
507 pastEndRead |
508 "someone tried to read after the end of the stream. |
508 "someone tried to read after the end of the stream. |
509 If signalAtEnd == true, raise a signal. |
509 If signalAtEnd == true, raise a signal. |
510 If it is false, return nil. |
510 If it is false, return nil. |
511 Otherwise raise a notification, which is ignored if not handled; |
511 Otherwise raise a notification, which is ignored if not handled; |
512 otherwise return nil." |
512 otherwise return nil." |
513 |
513 |
514 |shouldSignalAtEnd| |
514 |shouldSignalAtEnd| |
515 |
515 |
516 shouldSignalAtEnd := self signalAtEnd. |
516 shouldSignalAtEnd := self signalAtEnd. |
590 |
590 |
591 binary |
591 binary |
592 "switch to binary mode. In binary mode, reading of text streams |
592 "switch to binary mode. In binary mode, reading of text streams |
593 returns byte-valued integers instead of characters; writing expects |
593 returns byte-valued integers instead of characters; writing expects |
594 byte-valued integers respectively. |
594 byte-valued integers respectively. |
595 Ignored here, but added to make internalStreams protocol compatible |
595 Ignored here, but added to make internalStreams protocol compatible |
596 with externalStreams." |
596 with externalStreams." |
597 |
597 |
598 "Modified: 15.5.1996 / 17:38:36 / cg" |
598 "Modified: 15.5.1996 / 17:38:36 / cg" |
599 ! |
599 ! |
600 |
600 |
604 |
604 |
605 ^ false. |
605 ^ false. |
606 ! |
606 ! |
607 |
607 |
608 eolMode |
608 eolMode |
609 "Dummy here, but added to make internalStreams protocol compatible |
609 "Dummy here, but added to make internalStreams protocol compatible |
610 with externalStreams." |
610 with externalStreams." |
611 |
611 |
612 ^ nil "/ transparent |
612 ^ nil "/ transparent |
613 ! |
613 ! |
614 |
614 |
615 eolMode:aSymbol |
615 eolMode:aSymbol |
616 "Ignored here, but added to make internalStreams protocol compatible |
616 "Ignored here, but added to make internalStreams protocol compatible |
617 with externalStreams." |
617 with externalStreams." |
618 ! |
618 ! |
619 |
619 |
620 lineEndCRLF |
620 lineEndCRLF |
621 "Ignored here, but added to make internalStreams protocol compatible |
621 "Ignored here, but added to make internalStreams protocol compatible |
622 with externalStreams." |
622 with externalStreams." |
623 ! |
623 ! |
624 |
624 |
625 lineEndLF |
625 lineEndLF |
626 "Ignored here, but added to make internalStreams protocol compatible |
626 "Ignored here, but added to make internalStreams protocol compatible |
627 with externalStreams." |
627 with externalStreams." |
628 ! |
628 ! |
629 |
629 |
630 lineEndTransparent |
630 lineEndTransparent |
631 "Ignored here, but added to make internalStreams protocol compatible |
631 "Ignored here, but added to make internalStreams protocol compatible |
632 with externalStreams." |
632 with externalStreams." |
633 ! |
633 ! |
634 |
634 |
635 stream |
635 stream |
636 "for compatibility with encodedStream" |
636 "for compatibility with encodedStream" |
637 |
637 |
638 ^ self |
638 ^ self |
639 ! |
639 ! |
640 |
640 |
641 text |
641 text |
642 "switch to text mode. |
642 "switch to text mode. |
643 Ignored here, but added to make internalStreams protocol compatible |
643 Ignored here, but added to make internalStreams protocol compatible |
644 with externalStreams." |
644 with externalStreams." |
645 |
645 |
646 "Modified: 15.5.1996 / 17:38:36 / cg" |
646 "Modified: 15.5.1996 / 17:38:36 / cg" |
647 "Created: 13.9.1996 / 18:33:26 / cg" |
647 "Created: 13.9.1996 / 18:33:26 / cg" |
648 ! ! |
648 ! ! |
689 writeCount := 0. |
689 writeCount := 0. |
690 "write loop: write until all is written" |
690 "write loop: write until all is written" |
691 [ |
691 [ |
692 |count| |
692 |count| |
693 |
693 |
694 count := aWriteStream |
694 count := aWriteStream |
695 nextPutAll:readCount-writeCount |
695 nextPutAll:readCount-writeCount |
696 from:buffer |
696 from:buffer |
697 startingAt:writeCount+1. |
697 startingAt:writeCount+1. |
698 writeCount := writeCount + count. |
698 writeCount := writeCount + count. |
699 writeCount < readCount ifTrue:[ |
699 writeCount < readCount ifTrue:[ |
700 aWriteStream writeWait. |
700 aWriteStream writeWait. |
701 true. |
701 true. |
702 ] ifFalse:[ |
702 ] ifFalse:[ |
703 false |
703 false |
704 ]. |
704 ]. |
705 ] whileTrue. |
705 ] whileTrue. |
706 countWritten := countWritten + writeCount. |
706 countWritten := countWritten + writeCount. |
707 ]. |
707 ]. |
708 "Note: atEnd will block if reading from an empty pipe or socket. |
708 "Note: atEnd will block if reading from an empty pipe or socket. |
709 avoid atEnd if possible, because it reads a single byte." |
709 avoid atEnd if possible, because it reads a single byte." |
710 bytesLeft ~~ 0 or:[self atEnd not] |
710 bytesLeft ~~ 0 or:[self atEnd not] |
711 ] whileTrue. |
711 ] whileTrue. |
712 |
712 |
778 writeCount := 0. |
778 writeCount := 0. |
779 "write loop: write until all is written" |
779 "write loop: write until all is written" |
780 [ |
780 [ |
781 |count| |
781 |count| |
782 |
782 |
783 count := outStream |
783 count := outStream |
784 nextPutAll:readCount-writeCount |
784 nextPutAll:readCount-writeCount |
785 from:buffer |
785 from:buffer |
786 startingAt:writeCount+1. |
786 startingAt:writeCount+1. |
787 writeCount := writeCount + count. |
787 writeCount := writeCount + count. |
788 writeCount < readCount ifTrue:[ |
788 writeCount < readCount ifTrue:[ |
789 outStream writeWait. |
789 outStream writeWait. |
790 true. |
790 true. |
791 ] ifFalse:[ |
791 ] ifFalse:[ |
792 false |
792 false |
793 ]. |
793 ]. |
794 ] whileTrue. |
794 ] whileTrue. |
795 countWritten := countWritten + writeCount. |
795 countWritten := countWritten + writeCount. |
796 ]. |
796 ]. |
797 "Note: atEnd will block if reading from an empty pipe or socket. |
797 "Note: atEnd will block if reading from an empty pipe or socket. |
798 avoid atEnd if possible, because it reads a single byte." |
798 avoid atEnd if possible, because it reads a single byte." |
799 readCount ~~ 0 or:[self atEnd not] |
799 readCount ~~ 0 or:[self atEnd not] |
800 ] whileTrue. |
800 ] whileTrue. |
801 |
801 |
853 "read the next count bytes into an object and return the number of |
853 "read the next count bytes into an object and return the number of |
854 bytes read. On EOF, 0 is returned. |
854 bytes read. On EOF, 0 is returned. |
855 If the receiver is some socket/pipe-like stream, an exception |
855 If the receiver is some socket/pipe-like stream, an exception |
856 is raised if the connection is broken. |
856 is raised if the connection is broken. |
857 |
857 |
858 The object must have non-pointer indexed instvars (i.e. it must be |
858 The object must have non-pointer indexed instvars (i.e. it must be |
859 a ByteArray, String, Float- or DoubleArray). |
859 a ByteArray, String, Float- or DoubleArray). |
860 If anObject is a string or byteArray and reused, this provides the |
860 If anObject is a string or byteArray and reused, this provides the |
861 fastest possible physical I/O (since no new objects are allocated). |
861 fastest possible physical I/O (since no new objects are allocated). |
862 |
862 |
863 Use with care - non object oriented i/o. |
863 Use with care - non object oriented i/o. |
864 Warning: in general, you cannot use this method to pass data from other |
864 Warning: in general, you cannot use this method to pass data from other |
865 architectures since it does not care for byte order or float representation." |
865 architectures since it does not care for byte order or float representation." |
866 |
866 |
867 ^ self nextBytes:count into:anObject startingAt:1 |
867 ^ self nextBytes:count into:anObject startingAt:1 |
868 |
868 |
869 "Modified: 22.4.1997 / 10:41:39 / cg" |
869 "Modified: 22.4.1997 / 10:41:39 / cg" |
946 The number of bytes to read is defined by the object's size. |
946 The number of bytes to read is defined by the object's size. |
947 Return the number of bytes read. On EOF, 0 is returned. |
947 Return the number of bytes read. On EOF, 0 is returned. |
948 If the receiver is some socket/pipe-like stream, an exception |
948 If the receiver is some socket/pipe-like stream, an exception |
949 is raised if the connection is broken. |
949 is raised if the connection is broken. |
950 |
950 |
951 The object to read into must have non-pointer indexed instvars |
951 The object to read into must have non-pointer indexed instvars |
952 (i.e. it must be a ByteArray, String, Float- or DoubleArray). |
952 (i.e. it must be a ByteArray, String, Float- or DoubleArray). |
953 If anObject is a string or byteArray and reused, this provides the |
953 If anObject is a string or byteArray and reused, this provides the |
954 fastest possible physical I/O (since no new objects are allocated). |
954 fastest possible physical I/O (since no new objects are allocated). |
955 |
955 |
956 Use with care - non object oriented i/o. |
956 Use with care - non object oriented i/o. |
957 Warning: in general, you cannot use this method to pass data from other |
957 Warning: in general, you cannot use this method to pass data from other |
958 architectures since it does not care for byte order or float representation." |
958 architectures since it does not care for byte order or float representation." |
959 |
959 |
960 ^ self nextBytes:(anObject byteSize) into:anObject startingAt:1 |
960 ^ self nextBytes:(anObject byteSize) into:anObject startingAt:1 |
961 |
961 |
962 " to read 100 bytes from a stream: |
962 " to read 100 bytes from a stream: |
963 |
963 |
964 |b aStream| |
964 |b aStream| |
965 |
965 |
966 aStream := 'smalltalk.rc' asFilename readStream. |
966 aStream := 'smalltalk.rc' asFilename readStream. |
967 b := ByteArray new:100. |
967 b := ByteArray new:100. |
968 aStream nextBytesInto:b. |
968 aStream nextBytesInto:b. |
1194 |uval "{ Class: SmallInteger }"| |
1194 |uval "{ Class: SmallInteger }"| |
1195 |
1195 |
1196 uval := self nextByte. |
1196 uval := self nextByte. |
1197 "change from unsigned 0..FF to signed -80..7F" |
1197 "change from unsigned 0..FF to signed -80..7F" |
1198 uval >= 16r80 ifTrue:[ |
1198 uval >= 16r80 ifTrue:[ |
1199 ^ uval - 16r100 |
1199 ^ uval - 16r100 |
1200 ]. |
1200 ]. |
1201 ^ uval |
1201 ^ uval |
1202 |
1202 |
1203 " |
1203 " |
1204 #[16rFF 16r80 16r7F 16r01] readStream nextSignedByte |
1204 #[16rFF 16r80 16r7F 16r01] readStream nextSignedByte |
1205 " |
1205 " |
1206 ! |
1206 ! |
1207 |
1207 |
1208 nextString:count |
1208 nextString:count |
1209 "read the next count bytes and return it as a string. |
1209 "read the next count bytes and return it as a string. |
1210 If EOF is encountered while reading, a truncated string is returned. |
1210 If EOF is encountered while reading, a truncated string is returned. |
1211 If EOF is already reached before the first byte can be read, |
1211 If EOF is already reached before the first byte can be read, |
1212 an error is raised." |
1212 an error is raised." |
1213 |
1213 |
1214 |data n| |
1214 |data n| |
1215 |
1215 |
1276 |
1276 |
1277 " |
1277 " |
1278 |s| |
1278 |s| |
1279 |
1279 |
1280 s := #[ 16r01 16r02 16r03 16r04 16r05 ] readStream. |
1280 s := #[ 16r01 16r02 16r03 16r04 16r05 ] readStream. |
1281 (s nextUnsigned:3 MSB:true) hexPrintString. |
1281 (s nextUnsigned:3 MSB:true) hexPrintString. |
1282 s := #[ 16r01 16r02 16r03 16r04 16r05 16r06 16r07 16r08 16r09 ] readStream. |
1282 s := #[ 16r01 16r02 16r03 16r04 16r05 16r06 16r07 16r08 16r09 ] readStream. |
1283 (s nextUnsigned:9 MSB:true) hexPrintString. |
1283 (s nextUnsigned:9 MSB:true) hexPrintString. |
1284 |
1284 |
1285 s := #[ 16r01 16r02 16r03 16r04 16r05 ] readStream. |
1285 s := #[ 16r01 16r02 16r03 16r04 16r05 ] readStream. |
1286 (s nextUnsigned:3 MSB:false) hexPrintString. |
1286 (s nextUnsigned:3 MSB:false) hexPrintString. |
1287 s := #[ 16r01 16r02 16r03 16r04 16r05 16r06 16r07 16r08 16r09 ] readStream. |
1287 s := #[ 16r01 16r02 16r03 16r04 16r05 16r06 16r07 16r08 16r09 ] readStream. |
1288 (s nextUnsigned:9 MSB:false) hexPrintString. |
1288 (s nextUnsigned:9 MSB:false) hexPrintString. |
1289 " |
1289 " |
1290 ! |
1290 ! |
1291 |
1291 |
1292 nextUnsignedInt16MSB:msbFlag |
1292 nextUnsignedInt16MSB:msbFlag |
1293 "return an unsigned short (2 bytes) from the stream. |
1293 "return an unsigned short (2 bytes) from the stream. |
1866 s nextPutByte:2. |
1866 s nextPutByte:2. |
1867 s contents |
1867 s contents |
1868 " |
1868 " |
1869 ! |
1869 ! |
1870 |
1870 |
1871 nextNumber:n put:v |
1871 nextNumber:n put:v |
1872 "Append to the receiver the argument, v, which is a positive Integer, |
1872 "Append to the receiver the argument, v, which is a positive Integer, |
1873 as the next n bytes. Bytes are written msb first. |
1873 as the next n bytes. Bytes are written msb first. |
1874 Possibly pad with leading zeros. |
1874 Possibly pad with leading zeros. |
1875 The receiver must support writing of binary bytes." |
1875 The receiver must support writing of binary bytes." |
1876 |
1876 |
1877 self nextNumber:n put:v MSB:true |
1877 self nextNumber:n put:v MSB:true |
1878 ! |
1878 ! |
1879 |
1879 |
1880 nextNumber:n put:v MSB:msb |
1880 nextNumber:n put:v MSB:msb |
1881 "Append to the receiver the argument, v, which is a positive Integer, |
1881 "Append to the receiver the argument, v, which is a positive Integer, |
1882 as the next n bytes. |
1882 as the next n bytes. |
1883 Bytes are written in the specified byte order. |
1883 Bytes are written in the specified byte order. |
1884 Possibly pad with leading zeros (trailing zeros, if lsb). |
1884 Possibly pad with leading zeros (trailing zeros, if lsb). |
1885 The receiver must support writing of binary bytes." |
1885 The receiver must support writing of binary bytes." |
1886 |
1886 |
1887 |vlen "{ Class: SmallInteger }" |
1887 |vlen "{ Class: SmallInteger }" |
1888 i "{ Class: SmallInteger }" |
1888 i "{ Class: SmallInteger }" |
1961 |
1961 |
1962 msb ifTrue:[ |
1962 msb ifTrue:[ |
1963 "pad with leading zeros" |
1963 "pad with leading zeros" |
1964 i := n. |
1964 i := n. |
1965 [i > vlen] whileTrue:[ |
1965 [i > vlen] whileTrue:[ |
1966 self nextPutByte:0. |
1966 self nextPutByte:0. |
1967 i := i - 1 |
1967 i := i - 1 |
1968 ]. |
1968 ]. |
1969 |
1969 |
1970 i == 1 ifTrue:[ |
1970 i == 1 ifTrue:[ |
1971 ^ self nextPutByte:v |
1971 ^ self nextPutByte:v |
1972 ]. |
1972 ]. |
1973 |
1973 |
1974 [i > 0] whileTrue:[ |
1974 [i > 0] whileTrue:[ |
1975 self nextPutByte:(v digitAt:i). |
1975 self nextPutByte:(v digitAt:i). |
1976 i := i - 1 |
1976 i := i - 1 |
1977 ] |
1977 ] |
1978 ] ifFalse:[ |
1978 ] ifFalse:[ |
1979 1 to:vlen do:[:i | |
1979 1 to:vlen do:[:i | |
1980 self nextPutByte:(v digitAt:i). |
1980 self nextPutByte:(v digitAt:i). |
1981 ]. |
1981 ]. |
1982 "pad with trailing zeros" |
1982 "pad with trailing zeros" |
1983 vlen+1 to:n do:[:i | |
1983 vlen+1 to:n do:[:i | |
1984 self nextPutByte:0. |
1984 self nextPutByte:0. |
1985 ]. |
1985 ]. |
1986 ]. |
1986 ]. |
1987 |
1987 |
1988 "Modified: / 22-06-2006 / 11:31:13 / fm" |
1988 "Modified: / 22-06-2006 / 11:31:13 / fm" |
1989 ! |
1989 ! |
1990 |
1990 |
1991 nextPutAllUtf16:aString |
1991 nextPutAllUtf16:aString |
2045 |
2045 |
2046 nextPutBytes:anObject |
2046 nextPutBytes:anObject |
2047 "write bytes from an object; the number of bytes is defined by |
2047 "write bytes from an object; the number of bytes is defined by |
2048 the object's size. |
2048 the object's size. |
2049 Return the number of bytes written or nil on error. |
2049 Return the number of bytes written or nil on error. |
2050 The object must have non-pointer indexed instvars |
2050 The object must have non-pointer indexed instvars |
2051 (i.e. be a ByteArray, String, Float- or DoubleArray). |
2051 (i.e. be a ByteArray, String, Float- or DoubleArray). |
2052 Use with care - non object oriented i/o. |
2052 Use with care - non object oriented i/o. |
2053 Warning: in general, you cannot use this method to pass non-byte data to other |
2053 Warning: in general, you cannot use this method to pass non-byte data to other |
2054 architectures since it does not care for byte order or float representation." |
2054 architectures since it does not care for byte order or float representation." |
2055 |
2055 |
2056 ^ self nextPutBytes:(anObject size) from:anObject startingAt:1 |
2056 ^ self nextPutBytes:(anObject size) from:anObject startingAt:1 |
2057 |
2057 |
2058 "Created: 22.4.1997 / 10:44:18 / cg" |
2058 "Created: 22.4.1997 / 10:44:18 / cg" |
2059 ! |
2059 ! |
2060 |
2060 |
2061 nextPutBytes:count from:anObject |
2061 nextPutBytes:count from:anObject |
2062 "write count bytes from an object. |
2062 "write count bytes from an object. |
2063 Return the number of bytes written or nil on error. |
2063 Return the number of bytes written or nil on error. |
2064 The object must have non-pointer indexed instvars |
2064 The object must have non-pointer indexed instvars |
2065 (i.e. be a ByteArray, String, Float- or DoubleArray). |
2065 (i.e. be a ByteArray, String, Float- or DoubleArray). |
2066 Use with care - non object oriented i/o. |
2066 Use with care - non object oriented i/o. |
2067 Warning: in general, you cannot use this method to pass non-byte data to other |
2067 Warning: in general, you cannot use this method to pass non-byte data to other |
2068 architectures since it does not care for byte order or float representation." |
2068 architectures since it does not care for byte order or float representation." |
2069 |
2069 |
2070 ^ self nextPutBytes:count from:anObject startingAt:1 |
2070 ^ self nextPutBytes:count from:anObject startingAt:1 |
2071 |
2071 |
2072 "Created: 22.4.1997 / 10:43:59 / cg" |
2072 "Created: 22.4.1997 / 10:43:59 / cg" |
2137 |
2137 |
2138 ShortFloat storeBinaryIEEESingle:aFloat on:self MSB:msb. |
2138 ShortFloat storeBinaryIEEESingle:aFloat on:self MSB:msb. |
2139 ! |
2139 ! |
2140 |
2140 |
2141 nextPutInt16:anIntegerOrCharacter MSB:msbFlag |
2141 nextPutInt16:anIntegerOrCharacter MSB:msbFlag |
2142 "Write the argument, anIntegerOrCharacter as a short (two bytes). |
2142 "Write the argument, anIntegerOrCharacter as a short (two bytes). |
2143 If msbFlag is true, data is written most-significant byte first; |
2143 If msbFlag is true, data is written most-significant byte first; |
2144 otherwise least first. |
2144 otherwise least first. |
2145 Returns the receiver on ok, nil on error. |
2145 Returns the receiver on ok, nil on error. |
2146 The receiver must support writing of binary bytes. |
2146 The receiver must support writing of binary bytes. |
2147 |
2147 |
2148 This interface is provided to allow talking to external programs, |
2148 This interface is provided to allow talking to external programs, |
2149 where it's known that the byte order is some definite one. |
2149 where it's known that the byte order is some definite one. |
2212 |
2212 |
2213 "Created: 10.1.1996 / 19:50:33 / cg" |
2213 "Created: 10.1.1996 / 19:50:33 / cg" |
2214 ! |
2214 ! |
2215 |
2215 |
2216 nextPutInt32:aNumber MSB:msbFlag |
2216 nextPutInt32:aNumber MSB:msbFlag |
2217 "Write the argument, aNumber as a long (four bytes). |
2217 "Write the argument, aNumber as a long (four bytes). |
2218 If msbFlag is true, data is written most-significant byte first; |
2218 If msbFlag is true, data is written most-significant byte first; |
2219 otherwise least first. |
2219 otherwise least first. |
2220 Returns the receiver on ok, nil on error. |
2220 Returns the receiver on ok, nil on error. |
2221 The receiver must support writing of binary bytes. |
2221 The receiver must support writing of binary bytes. |
2222 |
2222 |
2223 This interface is provided to allow talking to external programs, |
2223 This interface is provided to allow talking to external programs, |
2224 where it's known that the byte order is some definite one. |
2224 where it's known that the byte order is some definite one. |
2255 |
2255 |
2256 s := #[] writeStream. |
2256 s := #[] writeStream. |
2257 s nextPutInt32:16r12345678 MSB:false. |
2257 s nextPutInt32:16r12345678 MSB:false. |
2258 bytes := s contents. |
2258 bytes := s contents. |
2259 s := bytes readStream. |
2259 s := bytes readStream. |
2260 (s nextInt32MSB:false) hexPrintString. |
2260 (s nextInt32MSB:false) hexPrintString. |
2261 " |
2261 " |
2262 " |
2262 " |
2263 |s bytes| |
2263 |s bytes| |
2264 |
2264 |
2265 s := #[] writeStream. |
2265 s := #[] writeStream. |
2266 s nextPutInt32:16r12345678 MSB:true. |
2266 s nextPutInt32:16r12345678 MSB:true. |
2267 bytes := s contents. |
2267 bytes := s contents. |
2268 s := bytes readStream. |
2268 s := bytes readStream. |
2269 (s nextInt32MSB:true) hexPrintString. |
2269 (s nextInt32MSB:true) hexPrintString. |
2270 . |
2270 . |
2271 " |
2271 " |
2272 " |
2272 " |
2273 |s bytes| |
2273 |s bytes| |
2274 |
2274 |
2275 s := #[] writeStream. |
2275 s := #[] writeStream. |
2276 s nextPutInt32:16r-80000000 MSB:true. |
2276 s nextPutInt32:16r-80000000 MSB:true. |
2277 bytes := s contents. |
2277 bytes := s contents. |
2278 s := bytes readStream. |
2278 s := bytes readStream. |
2279 (s nextInt32MSB:true) hexPrintString. |
2279 (s nextInt32MSB:true) hexPrintString. |
2280 " |
2280 " |
2281 " |
2281 " |
2282 |s bytes| |
2282 |s bytes| |
2283 |
2283 |
2284 s := #[] writeStream. |
2284 s := #[] writeStream. |
2285 s nextPutInt32:16r-80000000 MSB:false. |
2285 s nextPutInt32:16r-80000000 MSB:false. |
2286 bytes := s contents. |
2286 bytes := s contents. |
2287 s := bytes readStream. |
2287 s := bytes readStream. |
2288 (s nextInt32MSB:false) hexPrintString. |
2288 (s nextInt32MSB:false) hexPrintString. |
2289 " |
2289 " |
2290 |
2290 |
2291 "Modified: / 01-11-1997 / 18:30:52 / cg" |
2291 "Modified: / 01-11-1997 / 18:30:52 / cg" |
2292 "Modified: / 22-06-2006 / 11:31:43 / fm" |
2292 "Modified: / 22-06-2006 / 11:31:43 / fm" |
2293 ! |
2293 ! |
2316 |
2316 |
2317 ^ self nextPutInt32:aNumber MSB:true |
2317 ^ self nextPutInt32:aNumber MSB:true |
2318 ! |
2318 ! |
2319 |
2319 |
2320 nextPutInt64:aNumber MSB:msbFlag |
2320 nextPutInt64:aNumber MSB:msbFlag |
2321 "Write the argument, aNumber as a longlong (8 bytes). |
2321 "Write the argument, aNumber as a longlong (8 bytes). |
2322 If msbFlag is true, data is written most-significant byte first; |
2322 If msbFlag is true, data is written most-significant byte first; |
2323 otherwise least first. |
2323 otherwise least first. |
2324 Returns the receiver on ok, nil on error. |
2324 Returns the receiver on ok, nil on error. |
2325 The receiver must support writing of binary bytes. |
2325 The receiver must support writing of binary bytes. |
2326 |
2326 |
2327 This interface is provided to allow talking to external programs, |
2327 This interface is provided to allow talking to external programs, |
2328 where it's known that the byte order is some definite one. |
2328 where it's known that the byte order is some definite one. |
2345 |
2345 |
2346 s := #[] writeStream. |
2346 s := #[] writeStream. |
2347 s nextPutInt64:16r123456789abcdef0 MSB:false. |
2347 s nextPutInt64:16r123456789abcdef0 MSB:false. |
2348 bytes := s contents. |
2348 bytes := s contents. |
2349 s := bytes readStream. |
2349 s := bytes readStream. |
2350 (s nextUInt64MSB:false) hexPrintString. |
2350 (s nextUInt64MSB:false) hexPrintString. |
2351 " |
2351 " |
2352 " |
2352 " |
2353 |s bytes| |
2353 |s bytes| |
2354 |
2354 |
2355 s := #[] writeStream. |
2355 s := #[] writeStream. |
2356 s nextPutInt64:16r123456789abcdef0 MSB:true. |
2356 s nextPutInt64:16r123456789abcdef0 MSB:true. |
2357 bytes := s contents. |
2357 bytes := s contents. |
2358 s := bytes readStream. |
2358 s := bytes readStream. |
2359 (s nextUInt64MSB:true) hexPrintString. |
2359 (s nextUInt64MSB:true) hexPrintString. |
2360 " |
2360 " |
2361 " |
2361 " |
2362 |s bytes| |
2362 |s bytes| |
2363 |
2363 |
2364 s := #[] writeStream. |
2364 s := #[] writeStream. |
2365 s nextPutInt64:16r-8000000000000000 MSB:true. |
2365 s nextPutInt64:16r-8000000000000000 MSB:true. |
2366 bytes := s contents. |
2366 bytes := s contents. |
2367 s := bytes readStream. |
2367 s := bytes readStream. |
2368 (s nextUInt64MSB:true) hexPrintString. |
2368 (s nextUInt64MSB:true) hexPrintString. |
2369 " |
2369 " |
2370 " |
2370 " |
2371 |s bytes| |
2371 |s bytes| |
2372 |
2372 |
2373 s := #[] writeStream. |
2373 s := #[] writeStream. |
2374 s nextPutInt64:16r-8000000000000000 MSB:false. |
2374 s nextPutInt64:16r-8000000000000000 MSB:false. |
2375 bytes := s contents. |
2375 bytes := s contents. |
2376 s := bytes readStream. |
2376 s := bytes readStream. |
2377 (s nextUInt64MSB:false) hexPrintString. |
2377 (s nextUInt64MSB:false) hexPrintString. |
2378 " |
2378 " |
2379 |
2379 |
2380 "Modified: / 01-11-1997 / 18:30:52 / cg" |
2380 "Modified: / 01-11-1997 / 18:30:52 / cg" |
2381 "Modified: / 22-06-2006 / 11:31:37 / fm" |
2381 "Modified: / 22-06-2006 / 11:31:37 / fm" |
2382 ! |
2382 ! |
2438 nextPutUtf16:(Character codePoint:16r10CCCC) |
2438 nextPutUtf16:(Character codePoint:16r10CCCC) |
2439 yourself) contents |
2439 yourself) contents |
2440 " |
2440 " |
2441 ! |
2441 ! |
2442 |
2442 |
2443 nextPutUtf16Bytes:aCharacter MSB:msb |
2443 nextPutUtf16Bytes:aCharacter MSB:msb |
2444 "append my UTF-16 representation to the argument, aStream. |
2444 "append my UTF-16 representation to the argument, aStream. |
2445 UTF-16 can encode only characters with code points between 0 to 16r10FFFF. |
2445 UTF-16 can encode only characters with code points between 0 to 16r10FFFF. |
2446 The underlying stream must support writing of bytes." |
2446 The underlying stream must support writing of bytes." |
2447 |
2447 |
2448 |codePoint| |
2448 |codePoint| |
2449 |
2449 |
2450 codePoint := aCharacter codePoint. |
2450 codePoint := aCharacter codePoint. |
2451 (codePoint <= 16rD7FF |
2451 (codePoint <= 16rD7FF |
2452 or:[ codePoint >= 16rE000 and:[ codePoint <= 16rFFFF ] ]) |
2452 or:[ codePoint >= 16rE000 and:[ codePoint <= 16rFFFF ] ]) |
2453 ifTrue:[ self nextPutInt16:codePoint MSB:msb. ] |
2453 ifTrue:[ self nextPutInt16:codePoint MSB:msb. ] |
2454 ifFalse:[ |
2454 ifFalse:[ |
2455 codePoint <= 16r10FFFF ifTrue:[ |
2455 codePoint <= 16r10FFFF ifTrue:[ |
2456 |highBits lowBits| |
2456 |highBits lowBits| |
2457 |
2457 |
2536 ]. |
2536 ]. |
2537 |
2537 |
2538 EncodingError raiseWith:aCharacter errorString:'codePoint > 31bit in #nextPutUtf8:'. |
2538 EncodingError raiseWith:aCharacter errorString:'codePoint > 31bit in #nextPutUtf8:'. |
2539 |
2539 |
2540 " |
2540 " |
2541 (String streamContents:[:s| |
2541 (String streamContents:[:s| |
2542 s nextPutUtf8:$a. |
2542 s nextPutUtf8:$a. |
2543 s nextPutUtf8:$ü. |
2543 s nextPutUtf8:$ü. |
2544 s nextPutUtf8: (Character value:16r1fff). |
2544 s nextPutUtf8: (Character value:16r1fff). |
2545 s nextPutUtf8: (Character value:16rffff). |
2545 s nextPutUtf8: (Character value:16rffff). |
2546 s nextPutUtf8: (Character value:16r1ffffff). |
2546 s nextPutUtf8: (Character value:16r1ffffff). |
2547 s nextPutUtf8: (Character value:16r800). |
2547 s nextPutUtf8: (Character value:16r800). |
2548 ]) |
2548 ]) |
2549 asByteArray |
2549 asByteArray |
2550 |
2550 |
2551 " |
2551 " |
2552 ! ! |
2552 ! ! |
2553 |
2553 |
2554 !Stream methodsFor:'non homogenous writing - obsolete'! |
2554 !Stream methodsFor:'non homogenous writing - obsolete'! |
2555 |
2555 |
2556 nextPutHyper:aNumber MSB:msbFlag |
2556 nextPutHyper:aNumber MSB:msbFlag |
2557 <resource: #obsolete> |
2557 <resource: #obsolete> |
2558 "Write the argument, aNumber as a hyper (8 bytes). |
2558 "Write the argument, aNumber as a hyper (8 bytes). |
2559 If msbFlag is true, data is written most-significant byte first; |
2559 If msbFlag is true, data is written most-significant byte first; |
2560 otherwise least first. |
2560 otherwise least first. |
2561 Returns the receiver on ok, nil on error. |
2561 Returns the receiver on ok, nil on error. |
2562 The receiver must support writing of binary bytes. |
2562 The receiver must support writing of binary bytes. |
2563 |
2563 |
2564 This interface is provided to allow talking to external programs, |
2564 This interface is provided to allow talking to external programs, |
2565 where it's known that the byte order is some definite one. |
2565 where it's known that the byte order is some definite one. |
2574 |
2574 |
2575 s := #[] writeStream. |
2575 s := #[] writeStream. |
2576 s nextPutHyper:16r123456789abcdef0 MSB:false. |
2576 s nextPutHyper:16r123456789abcdef0 MSB:false. |
2577 bytes := s contents. |
2577 bytes := s contents. |
2578 s := bytes readStream. |
2578 s := bytes readStream. |
2579 (s nextHyperMSB:false) hexPrintString. |
2579 (s nextHyperMSB:false) hexPrintString. |
2580 " |
2580 " |
2581 " |
2581 " |
2582 |s bytes| |
2582 |s bytes| |
2583 |
2583 |
2584 s := #[] writeStream. |
2584 s := #[] writeStream. |
2585 s nextPutHyper:16r123456789abcdef0 MSB:true. |
2585 s nextPutHyper:16r123456789abcdef0 MSB:true. |
2586 bytes := s contents. |
2586 bytes := s contents. |
2587 s := bytes readStream. |
2587 s := bytes readStream. |
2588 (s nextHyperMSB:true) hexPrintString. |
2588 (s nextHyperMSB:true) hexPrintString. |
2589 . |
2589 . |
2590 " |
2590 " |
2591 " |
2591 " |
2592 |s bytes| |
2592 |s bytes| |
2593 |
2593 |
2594 s := #[] writeStream. |
2594 s := #[] writeStream. |
2595 s nextPutHyper:16r-8000000000000000 MSB:true. |
2595 s nextPutHyper:16r-8000000000000000 MSB:true. |
2596 bytes := s contents. |
2596 bytes := s contents. |
2597 s := bytes readStream. |
2597 s := bytes readStream. |
2598 (s nextHyperMSB:true) hexPrintString. |
2598 (s nextHyperMSB:true) hexPrintString. |
2599 " |
2599 " |
2600 " |
2600 " |
2601 |s bytes| |
2601 |s bytes| |
2602 |
2602 |
2603 s := #[] writeStream. |
2603 s := #[] writeStream. |
2604 s nextPutHyper:16r-8000000000000000 MSB:false. |
2604 s nextPutHyper:16r-8000000000000000 MSB:false. |
2605 bytes := s contents. |
2605 bytes := s contents. |
2606 s := bytes readStream. |
2606 s := bytes readStream. |
2607 (s nextHyperMSB:false) hexPrintString. |
2607 (s nextHyperMSB:false) hexPrintString. |
2608 " |
2608 " |
2609 |
2609 |
2610 "Modified: / 01-11-1997 / 18:30:52 / cg" |
2610 "Modified: / 01-11-1997 / 18:30:52 / cg" |
2611 "Modified: / 22-06-2006 / 11:31:37 / fm" |
2611 "Modified: / 22-06-2006 / 11:31:37 / fm" |
2612 ! |
2612 ! |
2613 |
2613 |
2614 nextPutLong:aNumber MSB:msbFlag |
2614 nextPutLong:aNumber MSB:msbFlag |
2615 <resource: #obsolete> |
2615 <resource: #obsolete> |
2616 "Write the argument, aNumber as a long (four bytes). |
2616 "Write the argument, aNumber as a long (four bytes). |
2617 If msbFlag is true, data is written most-significant byte first; |
2617 If msbFlag is true, data is written most-significant byte first; |
2618 otherwise least first. |
2618 otherwise least first. |
2619 Returns the receiver on ok, nil on error. |
2619 Returns the receiver on ok, nil on error. |
2620 The receiver must support writing of binary bytes. |
2620 The receiver must support writing of binary bytes. |
2621 |
2621 |
2622 This interface is provided to allow talking to external programs, |
2622 This interface is provided to allow talking to external programs, |
2623 where it's known that the byte order is some definite one. |
2623 where it's known that the byte order is some definite one. |
2632 |
2632 |
2633 s := #[] writeStream. |
2633 s := #[] writeStream. |
2634 s nextPutLong:16r12345678 MSB:false. |
2634 s nextPutLong:16r12345678 MSB:false. |
2635 bytes := s contents. |
2635 bytes := s contents. |
2636 s := bytes readStream. |
2636 s := bytes readStream. |
2637 (s nextLongMSB:false) hexPrintString. |
2637 (s nextLongMSB:false) hexPrintString. |
2638 " |
2638 " |
2639 " |
2639 " |
2640 |s bytes| |
2640 |s bytes| |
2641 |
2641 |
2642 s := #[] writeStream. |
2642 s := #[] writeStream. |
2643 s nextPutLong:16r12345678 MSB:true. |
2643 s nextPutLong:16r12345678 MSB:true. |
2644 bytes := s contents. |
2644 bytes := s contents. |
2645 s := bytes readStream. |
2645 s := bytes readStream. |
2646 (s nextLongMSB:true) hexPrintString. |
2646 (s nextLongMSB:true) hexPrintString. |
2647 . |
2647 . |
2648 " |
2648 " |
2649 " |
2649 " |
2650 |s bytes| |
2650 |s bytes| |
2651 |
2651 |
2652 s := #[] writeStream. |
2652 s := #[] writeStream. |
2653 s nextPutLong:16r-80000000 MSB:true. |
2653 s nextPutLong:16r-80000000 MSB:true. |
2654 bytes := s contents. |
2654 bytes := s contents. |
2655 s := bytes readStream. |
2655 s := bytes readStream. |
2656 (s nextLongMSB:true) hexPrintString. |
2656 (s nextLongMSB:true) hexPrintString. |
2657 " |
2657 " |
2658 " |
2658 " |
2659 |s bytes| |
2659 |s bytes| |
2660 |
2660 |
2661 s := #[] writeStream. |
2661 s := #[] writeStream. |
2662 s nextPutLong:16r-80000000 MSB:false. |
2662 s nextPutLong:16r-80000000 MSB:false. |
2663 bytes := s contents. |
2663 bytes := s contents. |
2664 s := bytes readStream. |
2664 s := bytes readStream. |
2665 (s nextLongMSB:false) hexPrintString. |
2665 (s nextLongMSB:false) hexPrintString. |
2666 " |
2666 " |
2667 |
2667 |
2668 "Modified: / 01-11-1997 / 18:30:52 / cg" |
2668 "Modified: / 01-11-1997 / 18:30:52 / cg" |
2669 "Modified: / 22-06-2006 / 11:31:43 / fm" |
2669 "Modified: / 22-06-2006 / 11:31:43 / fm" |
2670 ! |
2670 ! |
2681 "Created: 10.1.1996 / 19:50:23 / cg" |
2681 "Created: 10.1.1996 / 19:50:23 / cg" |
2682 ! |
2682 ! |
2683 |
2683 |
2684 nextPutShort:anIntegerOrCharacter MSB:msbFlag |
2684 nextPutShort:anIntegerOrCharacter MSB:msbFlag |
2685 <resource: #obsolete> |
2685 <resource: #obsolete> |
2686 "Write the argument, anIntegerOrCharacter as a short (two bytes). |
2686 "Write the argument, anIntegerOrCharacter as a short (two bytes). |
2687 If msbFlag is true, data is written most-significant byte first; |
2687 If msbFlag is true, data is written most-significant byte first; |
2688 otherwise least first. |
2688 otherwise least first. |
2689 Returns the receiver on ok, nil on error. |
2689 Returns the receiver on ok, nil on error. |
2690 The receiver must support writing of binary bytes. |
2690 The receiver must support writing of binary bytes. |
2691 |
2691 |
2692 This interface is provided to allow talking to external programs, |
2692 This interface is provided to allow talking to external programs, |
2693 where it's known that the byte order is some definite one. |
2693 where it's known that the byte order is some definite one. |
2739 !Stream methodsFor:'private'! |
2739 !Stream methodsFor:'private'! |
2740 |
2740 |
2741 contentsSpecies |
2741 contentsSpecies |
2742 "this should return the class of which an instance is |
2742 "this should return the class of which an instance is |
2743 returned by the #contents method. Here, Array is returned, |
2743 returned by the #contents method. Here, Array is returned, |
2744 since the abstract Stream-class has no idea of the underlying |
2744 since the abstract Stream-class has no idea of the underlying |
2745 collection class. |
2745 collection class. |
2746 It is redefined in some subclasses - for example, to return String." |
2746 It is redefined in some subclasses - for example, to return String." |
2747 |
2747 |
2748 ^ Array |
2748 ^ Array |
2749 |
2749 |
2750 "Modified: 15.5.1996 / 17:53:31 / cg" |
2750 "Modified: 15.5.1996 / 17:53:31 / cg" |
3006 answerStream nextPut:(self next) |
3006 answerStream nextPut:(self next) |
3007 ]. |
3007 ]. |
3008 ^ answerStream contents |
3008 ^ answerStream contents |
3009 |
3009 |
3010 " |
3010 " |
3011 (ReadStream on:#(1 2 3 4 5)) nextAvailable:3 |
3011 (ReadStream on:#(1 2 3 4 5)) nextAvailable:3 |
3012 (ReadStream on:#(1 2 3 4 5)) nextAvailable:10 |
3012 (ReadStream on:#(1 2 3 4 5)) nextAvailable:10 |
3013 (ReadStream on:'hello') nextAvailable:3 |
3013 (ReadStream on:'hello') nextAvailable:3 |
3014 (ReadStream on:'hello') nextAvailable:10 |
3014 (ReadStream on:'hello') nextAvailable:10 |
3015 " |
3015 " |
3016 |
3016 |
3017 "Modified: / 16.6.1998 / 15:52:41 / cg" |
3017 "Modified: / 16.6.1998 / 15:52:41 / cg" |
3018 ! |
3018 ! |
3019 |
3019 |
3080 |
3080 |
3081 "Modified: / 30.7.1999 / 12:12:10 / cg" |
3081 "Modified: / 30.7.1999 / 12:12:10 / cg" |
3082 ! |
3082 ! |
3083 |
3083 |
3084 skipFor:anObject |
3084 skipFor:anObject |
3085 "skip all objects up-to and including anObject; |
3085 "skip all objects up-to and including anObject; |
3086 read and return the element after anObject." |
3086 read and return the element after anObject." |
3087 |
3087 |
3088 (self skipThrough:anObject) notNil ifTrue:[ |
3088 (self skipThrough:anObject) notNil ifTrue:[ |
3089 ^ self next |
3089 ^ self next |
3090 ]. |
3090 ]. |
3091 ^ nil |
3091 ^ nil |
3092 |
3092 |
3093 " |
3093 " |
3094 |s next rest| |
3094 |s next rest| |
3095 s := ReadStream on:#(1 2 3 4 5 6 7 8). |
3095 s := ReadStream on:#(1 2 3 4 5 6 7 8). |
3096 next := s skipFor:4. |
3096 next := s skipFor:4. |
3097 rest := s upToEnd. |
3097 rest := s upToEnd. |
3098 " |
3098 " |
3099 " |
3099 " |
3100 |s next rest| |
3100 |s next rest| |
3101 s := ReadStream on:'12345678'. |
3101 s := ReadStream on:'12345678'. |
3102 next := s skipFor:$4. |
3102 next := s skipFor:$4. |
3113 |
3113 |
3114 ^ self skipThrough:Character cr |
3114 ^ self skipThrough:Character cr |
3115 ! |
3115 ! |
3116 |
3116 |
3117 skipThrough:anObject |
3117 skipThrough:anObject |
3118 "skip all objects up-to and including anObject. |
3118 "skip all objects up-to and including anObject. |
3119 Return the receiver if skip was successful, |
3119 Return the receiver if skip was successful, |
3120 otherwise (i.e. if not found) return nil and leave the stream positioned at the end. |
3120 otherwise (i.e. if not found) return nil and leave the stream positioned at the end. |
3121 The next read operation will return the element after anObject." |
3121 The next read operation will return the element after anObject." |
3122 |
3122 |
3123 |nextElement| |
3123 |nextElement| |
3124 |
3124 |
3139 " |
3139 " |
3140 |s| |
3140 |s| |
3141 s := ReadStream on:#(1 2 3 4 5 6 7 8). |
3141 s := ReadStream on:#(1 2 3 4 5 6 7 8). |
3142 s skipThrough:4. |
3142 s skipThrough:4. |
3143 s skipThrough:4. |
3143 s skipThrough:4. |
3144 s next |
3144 s next |
3145 " |
3145 " |
3146 " |
3146 " |
3147 |s| |
3147 |s| |
3148 s := ReadStream on:'12345678'. |
3148 s := ReadStream on:'12345678'. |
3149 s skipThrough:$4. |
3149 s skipThrough:$4. |
3150 s next |
3150 s next |
3151 " |
3151 " |
3152 " |
3152 " |
3153 |s| |
3153 |s| |
3154 s := ReadStream on:'12345678'. |
3154 s := ReadStream on:'12345678'. |
3155 s skipThrough:$4. |
3155 s skipThrough:$4. |
3156 s skipThrough:$4. |
3156 s skipThrough:$4. |
3157 s next |
3157 s next |
3158 " |
3158 " |
3159 " |
3159 " |
3160 |s| |
3160 |s| |
3161 s := ReadStream on:'12345678'. |
3161 s := ReadStream on:'12345678'. |
3162 s skipThrough:$4. |
3162 s skipThrough:$4. |
3163 s skipThrough:$4. |
3163 s skipThrough:$4. |
3164 s atEnd |
3164 s atEnd |
3165 " |
3165 " |
3166 ! |
3166 ! |
3167 |
3167 |
3168 skipThroughAll:aCollection |
3168 skipThroughAll:aCollection |
3169 "skip for and through the sequence given by the argument, aCollection; |
3169 "skip for and through the sequence given by the argument, aCollection; |
3170 return nil if not found, the receiver otherwise. |
3170 return nil if not found, the receiver otherwise. |
3171 On a successful match, the next read will return elements after aCollection; |
3171 On a successful match, the next read will return elements after aCollection; |
3172 if no match was found, the receiver will be positioned at the end." |
3172 if no match was found, the receiver will be positioned at the end." |
3173 |
3173 |
3174 |buffer l first idx| |
3174 |buffer l first idx| |
3175 |
3175 |
3176 l := aCollection size. |
3176 l := aCollection size. |
3177 first := aCollection at:1. |
3177 first := aCollection at:1. |
3178 [self atEnd] whileFalse:[ |
3178 [self atEnd] whileFalse:[ |
3179 buffer isNil ifTrue:[ |
3179 buffer isNil ifTrue:[ |
3180 buffer := self nextAvailable:l. |
3180 buffer := self nextAvailable:l. |
3181 ]. |
3181 ]. |
3182 buffer = aCollection ifTrue:[ |
3182 buffer = aCollection ifTrue:[ |
3183 ^ self |
3183 ^ self |
3184 ]. |
3184 ]. |
3185 idx := buffer indexOf:first startingAt:2. |
3185 idx := buffer indexOf:first startingAt:2. |
3186 idx == 0 ifTrue:[ |
3186 idx == 0 ifTrue:[ |
3187 buffer := nil |
3187 buffer := nil |
3188 ] ifFalse:[ |
3188 ] ifFalse:[ |
3189 buffer := (buffer copyFrom:idx) , (self nextAvailable:(idx - 1)) |
3189 buffer := (buffer copyFrom:idx) , (self nextAvailable:(idx - 1)) |
3190 ] |
3190 ] |
3191 ]. |
3191 ]. |
3192 ^ nil |
3192 ^ nil |
3193 |
3193 |
3194 " |
3194 " |
3195 |s| |
3195 |s| |
3196 s := ReadStream on:'12345678901234567890'. |
3196 s := ReadStream on:'12345678901234567890'. |
3197 s skipThroughAll:'901'. |
3197 s skipThroughAll:'901'. |
3198 s upToEnd |
3198 s upToEnd |
3199 " |
3199 " |
3200 " |
3200 " |
3201 |s| |
3201 |s| |
3202 s := ReadStream on:'12345678901234567890'. |
3202 s := ReadStream on:'12345678901234567890'. |
3203 s skipThroughAll:'1234'. |
3203 s skipThroughAll:'1234'. |
3204 s upToEnd |
3204 s upToEnd |
3205 " |
3205 " |
3206 " |
3206 " |
3207 |s| |
3207 |s| |
3208 s := ReadStream on:'12345678901234567890'. |
3208 s := ReadStream on:'12345678901234567890'. |
3209 s skipThroughAll:'999'. |
3209 s skipThroughAll:'999'. |
3210 s atEnd |
3210 s atEnd |
3211 " |
3211 " |
3212 |
3212 |
3213 "Created: 11.1.1997 / 18:55:13 / cg" |
3213 "Created: 11.1.1997 / 18:55:13 / cg" |
3214 "Modified: 11.1.1997 / 19:09:06 / cg" |
3214 "Modified: 11.1.1997 / 19:09:06 / cg" |
3215 ! |
3215 ! |
3216 |
3216 |
3217 skipUntil:aBlock |
3217 skipUntil:aBlock |
3218 "skip all elements for which aBlock returns false. |
3218 "skip all elements for which aBlock returns false. |
3219 Return true if more elements can be read, false if eof has been reached." |
3219 Return true if more elements can be read, false if eof has been reached." |
3220 |
3220 |
3221 [self atEnd] whileFalse:[ |
3221 [self atEnd] whileFalse:[ |
3222 (aBlock value: self peek) ifTrue:[^ true]. |
3222 (aBlock value: self peek) ifTrue:[^ true]. |
3223 self next |
3223 self next |
3250 "Created: / 23-09-2011 / 13:32:40 / cg" |
3250 "Created: / 23-09-2011 / 13:32:40 / cg" |
3251 ! |
3251 ! |
3252 |
3252 |
3253 through:anObject |
3253 through:anObject |
3254 "read a collection of all objects up-to anObject and return these |
3254 "read a collection of all objects up-to anObject and return these |
3255 elements, including anObject. |
3255 elements, including anObject. |
3256 The next read operation will return the element after anObject. |
3256 The next read operation will return the element after anObject. |
3257 If anObject is not encountered, all elements up to the end are read |
3257 If anObject is not encountered, all elements up to the end are read |
3258 and returned. |
3258 and returned. |
3259 Compare this with #upTo: which also reads up to some object |
3259 Compare this with #upTo: which also reads up to some object |
3260 and also positions behind it, but does not include it in the returned |
3260 and also positions behind it, but does not include it in the returned |
3262 |
3262 |
3263 |answerStream element| |
3263 |answerStream element| |
3264 |
3264 |
3265 answerStream := WriteStream on:(self contentsSpecies new). |
3265 answerStream := WriteStream on:(self contentsSpecies new). |
3266 [self atEnd] whileFalse:[ |
3266 [self atEnd] whileFalse:[ |
3267 element := self next. |
3267 element := self next. |
3268 answerStream nextPut:element. |
3268 answerStream nextPut:element. |
3269 (element = anObject) ifTrue: [ |
3269 (element = anObject) ifTrue: [ |
3270 ^ answerStream contents |
3270 ^ answerStream contents |
3271 ] |
3271 ] |
3272 ]. |
3272 ]. |
3273 ^ answerStream contents |
3273 ^ answerStream contents |
3274 |
3274 |
3275 " |
3275 " |
3276 |s| |
3276 |s| |
3277 s := ReadStream on:#(1 2 3 4 5 6 7 8). |
3277 s := ReadStream on:#(1 2 3 4 5 6 7 8). |
3278 Transcript showCR:(s through:4). |
3278 Transcript showCR:(s through:4). |
3279 Transcript showCR:s next |
3279 Transcript showCR:s next |
3280 |
3280 |
3281 |s| |
3281 |s| |
3282 s := ReadStream on:#(1 2 3 4 5 6 7 8). |
3282 s := ReadStream on:#(1 2 3 4 5 6 7 8). |
3283 Transcript showCR:(s through:9). |
3283 Transcript showCR:(s through:9). |
3284 Transcript showCR:s next |
3284 Transcript showCR:s next |
3285 |
3285 |
3286 |s| |
3286 |s| |
3287 s := ReadStream on:'hello world'. |
3287 s := ReadStream on:'hello world'. |
3288 Transcript showCR:(s through:Character space). |
3288 Transcript showCR:(s through:Character space). |
3291 |
3291 |
3292 "Modified: 17.5.1996 / 08:51:40 / cg" |
3292 "Modified: 17.5.1996 / 08:51:40 / cg" |
3293 ! |
3293 ! |
3294 |
3294 |
3295 throughAll:aCollection |
3295 throughAll:aCollection |
3296 "read & return a collection of all objects up-to and including |
3296 "read & return a collection of all objects up-to and including |
3297 a subcollection given by aCollection. |
3297 a subcollection given by aCollection. |
3298 (i.e. read until a ``substring'' is encountered.) |
3298 (i.e. read until a ``substring'' is encountered.) |
3299 The next read operation will return the element after aCollection. |
3299 The next read operation will return the element after aCollection. |
3300 If aCollection is not encountered, all elements up to the end are read |
3300 If aCollection is not encountered, all elements up to the end are read |
3301 and returned." |
3301 and returned." |
3303 |answerStream element last rslt| |
3303 |answerStream element last rslt| |
3304 |
3304 |
3305 last := aCollection last. |
3305 last := aCollection last. |
3306 answerStream := WriteStream on:(self contentsSpecies new). |
3306 answerStream := WriteStream on:(self contentsSpecies new). |
3307 [self atEnd] whileFalse:[ |
3307 [self atEnd] whileFalse:[ |
3308 element := self next. |
3308 element := self next. |
3309 answerStream nextPut:element. |
3309 answerStream nextPut:element. |
3310 element == last ifTrue:[ |
3310 element == last ifTrue:[ |
3311 ((rslt := answerStream contents) endsWith:aCollection) ifTrue:[ |
3311 ((rslt := answerStream contents) endsWith:aCollection) ifTrue:[ |
3312 ^ rslt |
3312 ^ rslt |
3313 ] |
3313 ] |
3314 ]. |
3314 ]. |
3315 ]. |
3315 ]. |
3316 ^ answerStream contents |
3316 ^ answerStream contents |
3317 |
3317 |
3318 " |
3318 " |
3319 |s| |
3319 |s| |
3320 s := ReadStream on:#(1 2 3 4 5 6 7 8). |
3320 s := ReadStream on:#(1 2 3 4 5 6 7 8). |
3321 Transcript showCR:(s throughAll:#(4 4 4)). |
3321 Transcript showCR:(s throughAll:#(4 4 4)). |
3322 Transcript showCR:s next |
3322 Transcript showCR:s next |
3323 |
3323 |
3324 |s| |
3324 |s| |
3325 s := ReadStream on:#(1 2 3 4 5 6 7 8). |
3325 s := ReadStream on:#(1 2 3 4 5 6 7 8). |
3326 Transcript showCR:(s throughAll:#(4 5 6)). |
3326 Transcript showCR:(s throughAll:#(4 5 6)). |
3327 Transcript showCR:s next |
3327 Transcript showCR:s next |
3328 |
3328 |
3329 |s| |
3329 |s| |
3330 s := ReadStream on:'hello world, this is some text'. |
3330 s := ReadStream on:'hello world, this is some text'. |
3331 Transcript showCR:(s throughAll:'world'). |
3331 Transcript showCR:(s throughAll:'world'). |
3332 Transcript showCR:(s throughAll:'some'). |
3332 Transcript showCR:(s throughAll:'some'). |
3333 Transcript showCR:s upToEnd. |
3333 Transcript showCR:s upToEnd. |
3334 " |
3334 " |
3335 |
3335 |
3336 "Modified: 15.7.1996 / 09:08:07 / cg" |
3336 "Modified: 15.7.1996 / 09:08:07 / cg" |
3337 ! |
3337 ! |
3338 |
3338 |
3339 throughAny:aCollection |
3339 throughAny:aCollection |
3340 "read & return a collection of all objects up-to and including |
3340 "read & return a collection of all objects up-to and including |
3341 an element contained in aCollection. |
3341 an element contained in aCollection. |
3342 (i.e. read until any from aCollection is encountered.) |
3342 (i.e. read until any from aCollection is encountered.) |
3343 If no such character is encountered, all elements up to the end are read |
3343 If no such character is encountered, all elements up to the end are read |
3344 and returned." |
3344 and returned." |
3345 |
3345 |
3356 ^ answerStream contents |
3356 ^ answerStream contents |
3357 |
3357 |
3358 " |
3358 " |
3359 |s| |
3359 |s| |
3360 s := ReadStream on:#(1 2 3 4 5 6 7 8). |
3360 s := ReadStream on:#(1 2 3 4 5 6 7 8). |
3361 Transcript showCR:(s throughAny:#(3 4 5)). |
3361 Transcript showCR:(s throughAny:#(3 4 5)). |
3362 Transcript showCR:s next |
3362 Transcript showCR:s next |
3363 |
3363 |
3364 |s| |
3364 |s| |
3365 s := ReadStream on:'hello world, this is some text'. |
3365 s := ReadStream on:'hello world, this is some text'. |
3366 Transcript showCR:(s throughAny:'wt'). |
3366 Transcript showCR:(s throughAny:'wt'). |
3367 Transcript showCR:(s throughAny:'wt'). |
3367 Transcript showCR:(s throughAny:'wt'). |
3368 Transcript showCR:s upToEnd. |
3368 Transcript showCR:s upToEnd. |
3369 " |
3369 " |
3370 |
3370 |
3371 "Modified: / 11.1.1998 / 15:28:04 / cg" |
3371 "Modified: / 11.1.1998 / 15:28:04 / cg" |
3372 ! |
3372 ! |
3395 " |
3395 " |
3396 ! |
3396 ! |
3397 |
3397 |
3398 upTo:anObject |
3398 upTo:anObject |
3399 "read a collection of all objects up-to anObject and return these |
3399 "read a collection of all objects up-to anObject and return these |
3400 elements, but excluding anObject. |
3400 elements, but excluding anObject. |
3401 The next read operation will return the element after anObject. |
3401 The next read operation will return the element after anObject. |
3402 (i.e. anObject is considered a separator, which is skipped) |
3402 (i.e. anObject is considered a separator, which is skipped) |
3403 Similar to #through:, but the matching object is not included in the |
3403 Similar to #through:, but the matching object is not included in the |
3404 returned collection. |
3404 returned collection. |
3405 If anObject is not encountered, all elements up to the end are read |
3405 If anObject is not encountered, all elements up to the end are read |
3415 ^ answerStream contents |
3415 ^ answerStream contents |
3416 |
3416 |
3417 " |
3417 " |
3418 |s| |
3418 |s| |
3419 s := ReadStream on:#(1 2 3 4 5 6 7 8). |
3419 s := ReadStream on:#(1 2 3 4 5 6 7 8). |
3420 Transcript showCR:(s upTo:4). |
3420 Transcript showCR:(s upTo:4). |
3421 Transcript showCR:s next |
3421 Transcript showCR:s next |
3422 |
3422 |
3423 compare the above to: |
3423 compare the above to: |
3424 |s| |
3424 |s| |
3425 s := ReadStream on:#(1 2 3 4 5 6 7 8). |
3425 s := ReadStream on:#(1 2 3 4 5 6 7 8). |
3426 Transcript showCR:(s through:4). |
3426 Transcript showCR:(s through:4). |
3427 Transcript showCR:s next |
3427 Transcript showCR:s next |
3428 |
3428 |
3429 |s| |
3429 |s| |
3430 s := ReadStream on:#(1 2 3 4 5 6 7 8). |
3430 s := ReadStream on:#(1 2 3 4 5 6 7 8). |
3431 Transcript showCR:(s upTo:9). |
3431 Transcript showCR:(s upTo:9). |
3432 Transcript showCR:s next |
3432 Transcript showCR:s next |
3433 |
3433 |
3434 |s| |
3434 |s| |
3435 s := ReadStream on:'hello world'. |
3435 s := ReadStream on:'hello world'. |
3436 Transcript showCR:(s upTo:Character space). |
3436 Transcript showCR:(s upTo:Character space). |
3437 Transcript showCR:(s upToEnd) |
3437 Transcript showCR:(s upToEnd) |
3438 |
3438 |
3439 (ReadStream on:'12345678905') upTo:$5; next |
3439 (ReadStream on:'12345678905') upTo:$5; next |
3440 |
3440 |
3441 (ReadStream on:'12345678905') upTo:$5; upTo:$5 |
3441 (ReadStream on:'12345678905') upTo:$5; upTo:$5 |
3442 |
3442 |
3443 (ReadStream on:'123456') upTo:$7 |
3443 (ReadStream on:'123456') upTo:$7 |
3444 |
3444 |
3445 (ReadStream on:#(1 2 3 4 5 6)) upTo:4 |
3445 (ReadStream on:#(1 2 3 4 5 6)) upTo:4 |
3446 |
3446 |
3447 (ReadStream on:'line 1 |
3447 (ReadStream on:'line 1 |
3448 line 2') upTo:Character cr |
3448 line 2') upTo:Character cr |
3449 |
3449 |
3450 'Makefile' asFilename readStream upTo:Character cr;upTo:Character cr |
3450 'Makefile' asFilename readStream upTo:Character cr;upTo:Character cr |
3451 " |
3451 " |
3452 |
3452 |
3453 "Modified: / 12.1.1998 / 21:58:38 / cg" |
3453 "Modified: / 12.1.1998 / 21:58:38 / cg" |
3454 "Modified: / 15.1.1998 / 23:28:47 / stefan" |
3454 "Modified: / 15.1.1998 / 23:28:47 / stefan" |
3455 ! |
3455 ! |
3515 "Created: / 15.6.1998 / 19:11:31 / cg" |
3515 "Created: / 15.6.1998 / 19:11:31 / cg" |
3516 ! |
3516 ! |
3517 |
3517 |
3518 upToAny:aCollectionOfObjects |
3518 upToAny:aCollectionOfObjects |
3519 "read a collection of all objects up-to a element which is contained in |
3519 "read a collection of all objects up-to a element which is contained in |
3520 aCollectionOfObjects and return these elements, but excluding the matching one. |
3520 aCollectionOfObjects and return these elements, but excluding the matching one. |
3521 The next read operation will return the element AFTER anObject. |
3521 The next read operation will return the element AFTER anObject. |
3522 If no such element is encountered, all elements up to the end are read |
3522 If no such element is encountered, all elements up to the end are read |
3523 and returned. |
3523 and returned. |
3524 Compare this with #throughAll: which also reads up to some object |
3524 Compare this with #throughAll: which also reads up to some object |
3525 and also positions behind it, but DOES include it in the returned |
3525 and also positions behind it, but DOES include it in the returned |
3537 |s| |
3537 |s| |
3538 s := ReadStream on:'hello world'. |
3538 s := ReadStream on:'hello world'. |
3539 Transcript showCR:(s upToAny:(Array with:Character space)). |
3539 Transcript showCR:(s upToAny:(Array with:Character space)). |
3540 Transcript showCR:(s upToEnd) |
3540 Transcript showCR:(s upToEnd) |
3541 |
3541 |
3542 'Makefile' asFilename readStream upToAny:($A to:$Z) |
3542 'Makefile' asFilename readStream upToAny:($A to:$Z) |
3543 " |
3543 " |
3544 |
3544 |
3545 "Created: / 30.8.1997 / 03:02:05 / cg" |
3545 "Created: / 30.8.1997 / 03:02:05 / cg" |
3546 "Modified: / 11.1.1998 / 15:19:18 / cg" |
3546 "Modified: / 11.1.1998 / 15:19:18 / cg" |
3547 ! |
3547 ! |
3548 |
3548 |
3549 upToBeforeAny:aCollectionOfObjects |
3549 upToBeforeAny:aCollectionOfObjects |
3550 "read a collection of all objects up-to a element which is contained in |
3550 "read a collection of all objects up-to a element which is contained in |
3551 aCollectionOfObjects and return these elements, but excluding the matching one. |
3551 aCollectionOfObjects and return these elements, but excluding the matching one. |
3552 The next read operation will return the matching element. |
3552 The next read operation will return the matching element. |
3553 If no such element is encountered, all elements up to the end are read |
3553 If no such element is encountered, all elements up to the end are read |
3554 and returned. |
3554 and returned. |
3555 This returns the exact same as upToAny: would, but leaves the stream's position so that |
3555 This returns the exact same as upToAny: would, but leaves the stream's position so that |
3556 the next read returns the matching delimiter instead of skipping it. |
3556 the next read returns the matching delimiter instead of skipping it. |
3614 |
3614 |
3615 |answerStream| |
3615 |answerStream| |
3616 |
3616 |
3617 answerStream := WriteStream on:(self contentsSpecies new). |
3617 answerStream := WriteStream on:(self contentsSpecies new). |
3618 [self atEnd] whileFalse:[ |
3618 [self atEnd] whileFalse:[ |
3619 answerStream nextPut:(self next) |
3619 answerStream nextPut:(self next) |
3620 ]. |
3620 ]. |
3621 ^ answerStream contents |
3621 ^ answerStream contents |
3622 |
3622 |
3623 " |
3623 " |
3624 (ReadStream on:'1234567890') upToEnd |
3624 (ReadStream on:'1234567890') upToEnd |
3625 ('123456' readStream) next; next; upToEnd |
3625 ('123456' readStream) next; next; upToEnd |
3626 ('1 23456' readStream) upTo:Character space; upToEnd |
3626 ('1 23456' readStream) upTo:Character space; upToEnd |
3627 ('12' readStream) next; next; upToEnd |
3627 ('12' readStream) next; next; upToEnd |
3628 " |
3628 " |
3629 |
3629 |
3630 "Modified: 15.5.1996 / 18:00:39 / cg" |
3630 "Modified: 15.5.1996 / 18:00:39 / cg" |
3631 ! |
3631 ! |
3632 |
3632 |
3667 |
3667 |
3668 upToSeparator |
3668 upToSeparator |
3669 "Return the next elements up to but not including the next separator. |
3669 "Return the next elements up to but not including the next separator. |
3670 The next read will return the separator. |
3670 The next read will return the separator. |
3671 If no separator is encountered, the contents up to the end is returned. |
3671 If no separator is encountered, the contents up to the end is returned. |
3672 The elements are supposed to understand #isSeparator |
3672 The elements are supposed to understand #isSeparator |
3673 (i.e. the receiver is supposed to be a character-stream)." |
3673 (i.e. the receiver is supposed to be a character-stream)." |
3674 |
3674 |
3675 ^ self upToElementForWhich:[:ch | ch isSeparator] |
3675 ^ self upToElementForWhich:[:ch | ch isSeparator] |
3676 |
3676 |
3677 " |
3677 " |
3678 'hello world' readStream upToSeparator |
3678 'hello world' readStream upToSeparator |
3679 'helloworld' readStream upToSeparator |
3679 'helloworld' readStream upToSeparator |
3680 'helloworld' readStream upToSeparator |
3680 'helloworld' readStream upToSeparator |
3681 '' readStream upToSeparator |
3681 '' readStream upToSeparator |
3682 |
3682 |
3683 |s| |
3683 |s| |
3684 s := 'hello world' readStream. |
3684 s := 'hello world' readStream. |
3685 s upToSeparator. |
3685 s upToSeparator. |
3686 s upToEnd |
3686 s upToEnd |
3687 " |
3687 " |
3688 |
3688 |
3689 "Modified: 4.1.1997 / 23:38:05 / cg" |
3689 "Modified: 4.1.1997 / 23:38:05 / cg" |
3690 ! ! |
3690 ! ! |
3691 |
3691 |
4181 nextPutAll:count from:aCollection startingAt:initialIndex |
4181 nextPutAll:count from:aCollection startingAt:initialIndex |
4182 "append count elements with index starting at initialIndex |
4182 "append count elements with index starting at initialIndex |
4183 of the argument, aCollection onto the receiver. |
4183 of the argument, aCollection onto the receiver. |
4184 This is only allowed, if the receiver supports writing. |
4184 This is only allowed, if the receiver supports writing. |
4185 Answer the number of elements that were appended. |
4185 Answer the number of elements that were appended. |
4186 This is for compatibility with ExternalStream, where less then |
4186 This is for compatibility with ExternalStream, where less then |
4187 count elements may be written. Dolphin defines this as well." |
4187 count elements may be written. Dolphin defines this as well." |
4188 |
4188 |
4189 self nextPutAll:aCollection startingAt:initialIndex to:initialIndex+count-1. |
4189 self nextPutAll:aCollection startingAt:initialIndex to:initialIndex+count-1. |
4190 ^ count |
4190 ^ count |
4191 |
4191 |
4239 "Modified: 11.7.1996 / 10:00:32 / cg" |
4239 "Modified: 11.7.1996 / 10:00:32 / cg" |
4240 ! |
4240 ! |
4241 |
4241 |
4242 nextPutAllLines:aCollectionOfStrings |
4242 nextPutAllLines:aCollectionOfStrings |
4243 "put all elements of the argument, aCollection as individual lines |
4243 "put all elements of the argument, aCollection as individual lines |
4244 onto the receiver, append a cr (carriage return) after each. |
4244 onto the receiver, append a cr (carriage return) after each. |
4245 This is only useful with character streams in textMode, |
4245 This is only useful with character streams in textMode, |
4246 and only allowed, if the receiver supports writing." |
4246 and only allowed, if the receiver supports writing." |
4247 |
4247 |
4248 aCollectionOfStrings do:[:eachLine | |
4248 aCollectionOfStrings do:[:eachLine | |
4249 self nextPutLine:eachLine. |
4249 self nextPutLine:eachLine. |
4323 "Created: / 26-09-2012 / 18:21:06 / cg" |
4323 "Created: / 26-09-2012 / 18:21:06 / cg" |
4324 ! |
4324 ! |
4325 |
4325 |
4326 printf:format |
4326 printf:format |
4327 "C-style printing into a stream" |
4327 "C-style printing into a stream" |
4328 |
4328 |
4329 format printf:#() on:self. |
4329 format printf:#() on:self. |
4330 |
4330 |
4331 " |
4331 " |
4332 Transcript printf:'Hello World\n' |
4332 Transcript printf:'Hello World\n' |
4333 " |
4333 " |
4334 ! |
4334 ! |
4335 |
4335 |
4336 printf:format with:argument |
4336 printf:format with:argument |
4337 "C-style printing into a stream" |
4337 "C-style printing into a stream" |
4338 |
4338 |
4339 format printf:{argument} on:self. |
4339 format printf:{argument} on:self. |
4340 |
4340 |
4341 " |
4341 " |
4342 Transcript printf:'%05x\n' with:12345 |
4342 Transcript printf:'%05x\n' with:12345 |
4343 " |
4343 " |
4344 ! |
4344 ! |
4345 |
4345 |
4346 printf:format with:argument1 with:argument2 |
4346 printf:format with:argument1 with:argument2 |
4347 "C-style printing into a stream" |
4347 "C-style printing into a stream" |
4348 |
4348 |
4349 format printf:{argument1 . argument2} on:self. |
4349 format printf:{argument1 . argument2} on:self. |
4350 |
4350 |
4351 " |
4351 " |
4352 Transcript printf:'%05x %3s\n' with:12345 with:'abc' |
4352 Transcript printf:'%05x %3s\n' with:12345 with:'abc' |
4353 " |
4353 " |
4354 ! |
4354 ! |
4355 |
4355 |
4356 printf:format with:argument1 with:argument2 with:argument3 |
4356 printf:format with:argument1 with:argument2 with:argument3 |
4357 "C-style printing into a stream" |
4357 "C-style printing into a stream" |
4358 |
4358 |
4359 format printf:{argument1 . argument2 . argument3} on:self. |
4359 format printf:{argument1 . argument2 . argument3} on:self. |
4360 |
4360 |
4361 " |
4361 " |
4362 Transcript printf:'%05x %3s %09s\n' with:12345 with:'abc' with:'abc' |
4362 Transcript printf:'%05x %3s %09s\n' with:12345 with:'abc' with:'abc' |
4363 Transcript printf:'%05x %3s %9s\n' with:12345 with:'abc' with:'abc' |
4363 Transcript printf:'%05x %3s %9s\n' with:12345 with:'abc' with:'abc' |
4364 " |
4364 " |
4365 ! |
4365 ! |
4366 |
4366 |
4367 printf:format with:argument1 with:argument2 with:argument3 with:argument4 |
4367 printf:format with:argument1 with:argument2 with:argument3 with:argument4 |
4368 "C-style printing into a stream" |
4368 "C-style printing into a stream" |
4369 |
4369 |
4370 format printf:{argument1 . argument2 . argument3 . argument4} on:self. |
4370 format printf:{argument1 . argument2 . argument3 . argument4} on:self. |
4371 |
4371 |
4372 " |
4372 " |
4373 Transcript printf:'%02x %02x %02x %02x\n' with:1 with:2 with:3 with:4 |
4373 Transcript printf:'%02x %02x %02x %02x\n' with:1 with:2 with:3 with:4 |
4374 Transcript printf:'%2x %2x %2x %2x\n' with:1 with:2 with:3 with:4 |
4374 Transcript printf:'%2x %2x %2x %2x\n' with:1 with:2 with:3 with:4 |
4414 ! |
4414 ! |
4415 |
4415 |
4416 show:something |
4416 show:something |
4417 "append a printed representation of the argument to the stream. |
4417 "append a printed representation of the argument to the stream. |
4418 This makes streams somewhat compatible to TextCollectors and |
4418 This makes streams somewhat compatible to TextCollectors and |
4419 allows you to say: |
4419 allows you to say: |
4420 Smalltalk at:#Transcript put:Stdout |
4420 Smalltalk at:#Transcript put:Stdout |
4421 or to use #show:/#showCR: with internal or external streams." |
4421 or to use #show:/#showCR: with internal or external streams." |
4422 |
4422 |
4423 something printOn:self |
4423 something printOn:self |
4424 ! |
4424 ! |
4425 |
4425 |
4426 show:something with:arg |
4426 show:something with:arg |
4427 "append a printed representation of the argument to the stream, expanding |
4427 "append a printed representation of the argument to the stream, expanding |
4428 the placeHolder %1 with the printString of arg. |
4428 the placeHolder %1 with the printString of arg. |
4429 This makes streams somewhat compatible to TextCollectors and |
4429 This makes streams somewhat compatible to TextCollectors and |
4430 allows you to say: |
4430 allows you to say: |
4431 Smalltalk at:#Transcript put:Stdout |
4431 Smalltalk at:#Transcript put:Stdout |
4432 or to use #show:/#showCR: with internal or external streams." |
4432 or to use #show:/#showCR: with internal or external streams." |
4433 |
4433 |
4434 self show:(something bindWith:arg) |
4434 self show:(something bindWith:arg) |
4435 |
4435 |
4438 |
4438 |
4439 show:something with:arg1 with:arg2 |
4439 show:something with:arg1 with:arg2 |
4440 "append a printed representation of the argument to the stream, expanding |
4440 "append a printed representation of the argument to the stream, expanding |
4441 the placeHolders %1 and %2 with the printStrings of arg1 and arg2. |
4441 the placeHolders %1 and %2 with the printStrings of arg1 and arg2. |
4442 This makes streams somewhat compatible to TextCollectors and |
4442 This makes streams somewhat compatible to TextCollectors and |
4443 allows you to say: |
4443 allows you to say: |
4444 Smalltalk at:#Transcript put:Stdout |
4444 Smalltalk at:#Transcript put:Stdout |
4445 or to use #show:/#showCR: with internal or external streams." |
4445 or to use #show:/#showCR: with internal or external streams." |
4446 |
4446 |
4447 self show:(something bindWith:arg1 with:arg2) |
4447 self show:(something bindWith:arg1 with:arg2) |
4448 |
4448 |
4451 |
4451 |
4452 show:something with:arg1 with:arg2 with:arg3 |
4452 show:something with:arg1 with:arg2 with:arg3 |
4453 "append a printed representation of the argument to the stream, expanding |
4453 "append a printed representation of the argument to the stream, expanding |
4454 the placeHolders %1,%2 and %3 with the printStrings of arg1, arg2 and arg3. |
4454 the placeHolders %1,%2 and %3 with the printStrings of arg1, arg2 and arg3. |
4455 This makes streams somewhat compatible to TextCollectors and |
4455 This makes streams somewhat compatible to TextCollectors and |
4456 allows you to say: |
4456 allows you to say: |
4457 Smalltalk at:#Transcript put:Stdout |
4457 Smalltalk at:#Transcript put:Stdout |
4458 or to use #show:/#showCR: with internal or external streams." |
4458 or to use #show:/#showCR: with internal or external streams." |
4459 |
4459 |
4460 self show:(something bindWith:arg1 with:arg2 with:arg3) |
4460 self show:(something bindWith:arg1 with:arg2 with:arg3) |
4461 |
4461 |
4464 |
4464 |
4465 show:something with:arg1 with:arg2 with:arg3 with:arg4 |
4465 show:something with:arg1 with:arg2 with:arg3 with:arg4 |
4466 "append a printed representation of the argument to the stream, expanding |
4466 "append a printed representation of the argument to the stream, expanding |
4467 the placeHolders %1,%2 and %3 with the printStrings of arg1, arg2 and arg3. |
4467 the placeHolders %1,%2 and %3 with the printStrings of arg1, arg2 and arg3. |
4468 This makes streams somewhat compatible to TextCollectors and |
4468 This makes streams somewhat compatible to TextCollectors and |
4469 allows you to say: |
4469 allows you to say: |
4470 Smalltalk at:#Transcript put:Stdout |
4470 Smalltalk at:#Transcript put:Stdout |
4471 or to use #show:/#showCR: with internal or external streams." |
4471 or to use #show:/#showCR: with internal or external streams." |
4472 |
4472 |
4473 self show:(something bindWith:arg1 with:arg2 with:arg3 with:arg4) |
4473 self show:(something bindWith:arg1 with:arg2 with:arg3 with:arg4) |
4474 |
4474 |
4477 |
4477 |
4478 show:something with:arg1 with:arg2 with:arg3 with:arg4 with:arg5 |
4478 show:something with:arg1 with:arg2 with:arg3 with:arg4 with:arg5 |
4479 "append a printed representation of the argument to the stream, expanding |
4479 "append a printed representation of the argument to the stream, expanding |
4480 the placeHolders %1,%2 and %3 with the printStrings of arg1, arg2 and arg3. |
4480 the placeHolders %1,%2 and %3 with the printStrings of arg1, arg2 and arg3. |
4481 This makes streams somewhat compatible to TextCollectors and |
4481 This makes streams somewhat compatible to TextCollectors and |
4482 allows you to say: |
4482 allows you to say: |
4483 Smalltalk at:#Transcript put:Stdout |
4483 Smalltalk at:#Transcript put:Stdout |
4484 or to use #show:/#showCR: with internal or external streams." |
4484 or to use #show:/#showCR: with internal or external streams." |
4485 |
4485 |
4486 self show:(something bindWith:arg1 with:arg2 with:arg3 with:arg4 with:arg5) |
4486 self show:(something bindWith:arg1 with:arg2 with:arg3 with:arg4 with:arg5) |
4487 |
4487 |
4490 |
4490 |
4491 show:something withArguments:args |
4491 show:something withArguments:args |
4492 "append a printed representation of the argument to the stream, expanding |
4492 "append a printed representation of the argument to the stream, expanding |
4493 the placeHolders %1,%2 and %3 with the printStrings of argi. |
4493 the placeHolders %1,%2 and %3 with the printStrings of argi. |
4494 This makes streams somewhat compatible to TextCollectors and |
4494 This makes streams somewhat compatible to TextCollectors and |
4495 allows you to say: |
4495 allows you to say: |
4496 Smalltalk at:#Transcript put:Stdout |
4496 Smalltalk at:#Transcript put:Stdout |
4497 or to use #show:/#showCR: with internal or external streams." |
4497 or to use #show:/#showCR: with internal or external streams." |
4498 |
4498 |
4499 self show:(something bindWithArguments:args) |
4499 self show:(something bindWithArguments:args) |
4500 ! |
4500 ! |
4501 |
4501 |
4502 showCR:aString |
4502 showCR:aString |
4503 "append a printed representation of the argument to the stream |
4503 "append a printed representation of the argument to the stream |
4504 and append a newline character. |
4504 and append a newline character. |
4505 This makes streams somewhat compatible to TextCollectors and |
4505 This makes streams somewhat compatible to TextCollectors and |
4506 allows you to say: |
4506 allows you to say: |
4507 Smalltalk at:#Transcript put:Stdout |
4507 Smalltalk at:#Transcript put:Stdout |
4508 or to use #show:/#showCR: with internal or external streams." |
4508 or to use #show:/#showCR: with internal or external streams." |
4509 |
4509 |
4510 self show:aString. |
4510 self show:aString. |
4511 self cr |
4511 self cr |
4512 |
4512 |
4516 |
4516 |
4517 showCR:something with:arg |
4517 showCR:something with:arg |
4518 "append a printed representation of the argument to the stream, expanding |
4518 "append a printed representation of the argument to the stream, expanding |
4519 the placeHolder %1 with the printString of arg. |
4519 the placeHolder %1 with the printString of arg. |
4520 This makes streams somewhat compatible to TextCollectors and |
4520 This makes streams somewhat compatible to TextCollectors and |
4521 allows you to say: |
4521 allows you to say: |
4522 Smalltalk at:#Transcript put:Stdout |
4522 Smalltalk at:#Transcript put:Stdout |
4523 or to use #show:/#showCR: with internal or external streams." |
4523 or to use #show:/#showCR: with internal or external streams." |
4524 |
4524 |
4525 self showCR:(something bindWith:arg) |
4525 self showCR:(something bindWith:arg) |
4526 |
4526 |
4529 |
4529 |
4530 showCR:something with:arg1 with:arg2 |
4530 showCR:something with:arg1 with:arg2 |
4531 "append a printed representation of the argument to the stream, expanding |
4531 "append a printed representation of the argument to the stream, expanding |
4532 the placeHolders %1 and %2 with the printStrings of arg1 and arg2. |
4532 the placeHolders %1 and %2 with the printStrings of arg1 and arg2. |
4533 This makes streams somewhat compatible to TextCollectors and |
4533 This makes streams somewhat compatible to TextCollectors and |
4534 allows you to say: |
4534 allows you to say: |
4535 Smalltalk at:#Transcript put:Stdout |
4535 Smalltalk at:#Transcript put:Stdout |
4536 or to use #show:/#showCR: with internal or external streams." |
4536 or to use #show:/#showCR: with internal or external streams." |
4537 |
4537 |
4538 self showCR:(something bindWith:arg1 with:arg2) |
4538 self showCR:(something bindWith:arg1 with:arg2) |
4539 |
4539 |
4542 |
4542 |
4543 showCR:something with:arg1 with:arg2 with:arg3 |
4543 showCR:something with:arg1 with:arg2 with:arg3 |
4544 "append a printed representation of the argument to the stream, expanding |
4544 "append a printed representation of the argument to the stream, expanding |
4545 the placeHolders %1,%2 and %3 with the printStrings of arg1, arg2 and arg3. |
4545 the placeHolders %1,%2 and %3 with the printStrings of arg1, arg2 and arg3. |
4546 This makes streams somewhat compatible to TextCollectors and |
4546 This makes streams somewhat compatible to TextCollectors and |
4547 allows you to say: |
4547 allows you to say: |
4548 Smalltalk at:#Transcript put:Stdout |
4548 Smalltalk at:#Transcript put:Stdout |
4549 or to use #show:/#showCR: with internal or external streams." |
4549 or to use #show:/#showCR: with internal or external streams." |
4550 |
4550 |
4551 self showCR:(something bindWith:arg1 with:arg2 with:arg3) |
4551 self showCR:(something bindWith:arg1 with:arg2 with:arg3) |
4552 |
4552 |
4555 |
4555 |
4556 showCR:something with:arg1 with:arg2 with:arg3 with:arg4 |
4556 showCR:something with:arg1 with:arg2 with:arg3 with:arg4 |
4557 "append a printed representation of the argument to the stream, expanding |
4557 "append a printed representation of the argument to the stream, expanding |
4558 the placeHolders %1,%2 and %3 with the printStrings of arg1, arg2 and arg3. |
4558 the placeHolders %1,%2 and %3 with the printStrings of arg1, arg2 and arg3. |
4559 This makes streams somewhat compatible to TextCollectors and |
4559 This makes streams somewhat compatible to TextCollectors and |
4560 allows you to say: |
4560 allows you to say: |
4561 Smalltalk at:#Transcript put:Stdout |
4561 Smalltalk at:#Transcript put:Stdout |
4562 or to use #show:/#showCR: with internal or external streams." |
4562 or to use #show:/#showCR: with internal or external streams." |
4563 |
4563 |
4564 self showCR:(something bindWith:arg1 with:arg2 with:arg3 with:arg4) |
4564 self showCR:(something bindWith:arg1 with:arg2 with:arg3 with:arg4) |
4565 |
4565 |
4568 |
4568 |
4569 showCR:something with:arg1 with:arg2 with:arg3 with:arg4 with:arg5 |
4569 showCR:something with:arg1 with:arg2 with:arg3 with:arg4 with:arg5 |
4570 "append a printed representation of the argument to the stream, expanding |
4570 "append a printed representation of the argument to the stream, expanding |
4571 the placeHolders %1,%2 and %3 with the printStrings of arg1, arg2 and arg3. |
4571 the placeHolders %1,%2 and %3 with the printStrings of arg1, arg2 and arg3. |
4572 This makes streams somewhat compatible to TextCollectors and |
4572 This makes streams somewhat compatible to TextCollectors and |
4573 allows you to say: |
4573 allows you to say: |
4574 Smalltalk at:#Transcript put:Stdout |
4574 Smalltalk at:#Transcript put:Stdout |
4575 or to use #show:/#showCR: with internal or external streams." |
4575 or to use #show:/#showCR: with internal or external streams." |
4576 |
4576 |
4577 self showCR:(something bindWith:arg1 with:arg2 with:arg3 with:arg4 with:arg5) |
4577 self showCR:(something bindWith:arg1 with:arg2 with:arg3 with:arg4 with:arg5) |
4578 |
4578 |
4581 |
4581 |
4582 showCR:something withArguments:args |
4582 showCR:something withArguments:args |
4583 "append a printed representation of the argument to the stream, expanding |
4583 "append a printed representation of the argument to the stream, expanding |
4584 the placeHolders %1,%2 and %3 with the printStrings of argi. |
4584 the placeHolders %1,%2 and %3 with the printStrings of argi. |
4585 This makes streams somewhat compatible to TextCollectors and |
4585 This makes streams somewhat compatible to TextCollectors and |
4586 allows you to say: |
4586 allows you to say: |
4587 Smalltalk at:#Transcript put:Stdout |
4587 Smalltalk at:#Transcript put:Stdout |
4588 or to use #show:/#showCR: with internal or external streams." |
4588 or to use #show:/#showCR: with internal or external streams." |
4589 |
4589 |
4590 self showCR:(something bindWithArguments:args) |
4590 self showCR:(something bindWithArguments:args) |
4591 ! |
4591 ! |
4661 |
4661 |
4662 !Stream methodsFor:'writing-chunks'! |
4662 !Stream methodsFor:'writing-chunks'! |
4663 |
4663 |
4664 nextChunkPut:aString |
4664 nextChunkPut:aString |
4665 "put aString as a chunk onto the receiver; |
4665 "put aString as a chunk onto the receiver; |
4666 double all exclamation marks except within primitives and append a |
4666 double all exclamation marks except within primitives and append a |
4667 single delimiting exclamation mark at the end. |
4667 single delimiting exclamation mark at the end. |
4668 This modification of the chunk format (not doubling exclas in primitive code) |
4668 This modification of the chunk format (not doubling exclas in primitive code) |
4669 was done to have primitive code more readable and easier be edited in the fileBrowser |
4669 was done to have primitive code more readable and easier be edited in the fileBrowser |
4670 or other editors. |
4670 or other editors. |
4671 It's no incompatibility, since inline primitives are an ST/X special |
4671 It's no incompatibility, since inline primitives are an ST/X special |