--- a/ByteArray.st Thu Nov 17 12:05:15 2005 +0100
+++ b/ByteArray.st Thu Nov 17 12:07:08 2005 +0100
@@ -71,136 +71,6 @@
!ByteArray class methodsFor:'instance creation'!
-from:aByteArray
- "return new instance which is a copy of aByteArray"
-
- |len bytes|
-
- len := aByteArray size.
- bytes := self new:len.
- bytes replaceBytesFrom:1 to:len with:aByteArray startingAt:1.
- ^ bytes
-
- "Created: / 5.3.1998 / 15:57:52 / stefan"
-!
-
-fromHexString:aString
- "Dolphin compatibility:
- decode a byteArray from a hex string (as generated by hexPrintOn:)"
-
- |sz "{ Class: SmallInteger }"
- chars s bytes|
-
- sz := aString size.
- sz == 0 ifTrue:[^ self new].
- sz odd ifTrue:[self error:'invalid hex string (odd size)'.].
-
- bytes := self new:(sz // 2).
- s := aString readStream.
- 1 to:sz // 2 do:[:idx |
- chars := s next:2.
- bytes at:idx put:(Integer readFrom:chars radix:16).
- ].
- ^ bytes
-
- "
- ByteArray fromHexString:'1234FEFF'
- "
- "
- |s|
- s := String streamContents:[:s | #[1 2 3] hexPrintOn:s].
- ByteArray fromHexString:s
- "
-
- "Modified: / 6.3.1997 / 15:28:52 / cg"
-!
-
-fromPackedString:aString
- "ST-80 compatibility: decode a byteArray from a packed string in which
- 6bits are encoded per character. The argument, aString must be a multiple
- of 4 in size (since 24 is the lcm of 6 and 8). This is somewhat like
- the radix-encoding used in good old PDP11 times ;-)
- ST-80 uses this encoding for Images ...
- This is very similar (but not equal) to the algorithm used in RFC1421.
- PS: It took a while to figure that one out ... I dont like it ;-)"
-
- |index "{ Class: SmallInteger }"
- dstIndex "{ Class: SmallInteger }"
- stop "{ Class: SmallInteger }"
- sixBits "{ Class: SmallInteger }"
- n "{ Class: SmallInteger }"
- sz "{ Class: SmallInteger }"
- lastCharacter bytes|
-
- sz := aString size.
- sz == 0 ifTrue:[^ self new].
- sz := sz - (aString occurrencesOf:Character linefeed).
- sz := sz - (aString occurrencesOf:Character return).
- sz := sz - (aString occurrencesOf:Character tab).
-
- stop := sz // 4 * 3.
- "the size modulo 3 is encoded in the last character, if its in the
- range 97 .. otherwise, its exact."
-
- lastCharacter := aString last.
- lastCharacter codePoint > 96 ifTrue:[
- stop := stop - 3 + lastCharacter codePoint - 96
- ].
- bytes := self new:stop.
-
- index := 1. dstIndex := 1.
- [dstIndex <= stop] whileTrue:[
- "/ take 4 characters ...
- "/ allow a line break before each group of 4
- sixBits := (aString at:index) codePoint.
- [sixBits < 32] whileTrue:[
- index := index + 1.
- sixBits := (aString at:index) codePoint.
- ].
- sixBits := sixBits bitAnd:16r3F.
- n := sixBits.
-
- sixBits := (aString at:index+1) codePoint.
- sixBits := sixBits bitAnd:16r3F.
- n := (n bitShift:6) + sixBits.
-
- sixBits := (aString at:index+2) codePoint.
- sixBits := sixBits bitAnd:16r3F.
- n := (n bitShift:6) + sixBits.
-
- sixBits := (aString at:index+3) codePoint.
- sixBits := sixBits bitAnd:16r3F.
- n := (n bitShift:6) + sixBits.
-
- index := index + 4.
-
- "/ now have 24 bits in n
-
- bytes at:dstIndex put:(n bitShift:-16).
-
- dstIndex < stop ifTrue:[
- bytes at:dstIndex+1 put:((n bitShift:-8) bitAnd:16rFF).
- dstIndex+2 <= stop ifTrue:[
- bytes at:dstIndex+2 put:(n bitAnd:16rFF).
- ]
- ].
- dstIndex := dstIndex + 3.
- ].
- ^ bytes
-
- "
- ByteArray fromPackedString:(#[1 1 1 1] asPackedString)
- ByteArray fromPackedString:(#[1 1 1 1 1] asPackedString)
- ByteArray fromPackedString:(#[1 1 1 1 1 1] asPackedString)
- ByteArray fromPackedString:(#[1 1 1 1 1 1 1] asPackedString)
- ByteArray fromPackedString:(#[1 1 1 1 1 1 1 1] asPackedString)
-
- "
-
- "Modified: / 6.3.1997 / 15:28:52 / cg"
- "Modified: / 18.12.1997 / 17:17:11 / stefan"
-!
-
uninitializedNew:anInteger
"return a new instance of the receiver with uninitialized
(i.e. undefined) contents. The indexed elements have any random
@@ -290,20 +160,6 @@
out:;
%}.
^ self basicNew:anInteger
-!
-
-with:aByteArray from:start to:stop
- "return new instance with a copy of aByteArray
- beginning at index start up to and including index stop"
-
- |len bytes|
-
- len := stop-start+1.
- bytes := self new:len.
- bytes replaceBytesFrom:1 to:len with:aByteArray startingAt:start.
- ^ bytes
-
- "Modified: / 5.3.1998 / 16:00:18 / stefan"
! !
!ByteArray class methodsFor:'binary storage'!
@@ -3249,6 +3105,7 @@
"
! !
+
!ByteArray methodsFor:'searching'!
indexOf:aByte startingAt:start
@@ -3338,5 +3195,5 @@
!ByteArray class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/ByteArray.st,v 1.171 2005-07-08 21:13:38 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/ByteArray.st,v 1.172 2005-11-17 11:07:08 stefan Exp $'
! !