eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'BinaryStream':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: BinaryStream


Inheritance:

   Object
   |
   +--Stream
      |
      +--BinaryStream

Package:
stx:libcompat
Category:
Compatibility-Squeak
Version:
rev: 1.1 date: 2018/05/08 18:14:47
user: cg
file: BinaryStream.st directory: libcompat
module: stx stc-classLibrary: libcompat

Description:


DO NOT DIRECTLY REFER TO THIS CLASS OR USE IT OTHERWISE IN YOUR CODE:

This is a mimicry class to allow some squeak code to be filed in without changing.
Its protocol is neither complete, nor fully compatible with the corresponding
squeak original class.

This stream is used (in squeak) for storage of binary data in either MSB or LSB 
byte order. In contrast to ST/X streams (where the MSB/LSB parameter is passed around
as argument), this one keeps it as a state, and provides the usual nextShort/nextInt
protocol without that parameter.
It is needed to port the Matlab reader (goodies/math).

By default, this stream is in MSB mode (network byte order) 


Class protocol:

instance creation
o  new
return an initialized instance

o  on: aStream
return an initialized instance


Instance protocol:

accessing
o  beBigEndian

o  beLittleEndian

o  rawStream: anotherStream

initialization
o  initialize
Invoked when a new instance is created.

misc
o  position

o  position: newPosition

o  reset

reading
o  next: nBytes

o  nextShort

o  nextUnsignedShort

o  peek


Examples:


more examples to be added:
  |bytes rawStream binaryStream val|

  bytes := #[1 2 3 4 5 6 7 8 9].
  rawStream := bytes readStream.
  binaryStream := BinaryStream on:rawStream.
  binaryStream beBigEndian.
  self assert:((val := binaryStream nextShort) = 16r0102).
  self assert:((val := binaryStream nextUnsignedShort) = 16r0304).
  binaryStream reset.
  binaryStream beLittleEndian.
  self assert:((val := binaryStream nextShort) = 16r0201).
  self assert:((val := binaryStream nextUnsignedShort) = 16r0403).


ST/X 7.1.0.0; WebServer 1.663 at exept.de:8081; Wed, 19 Sep 2018 03:02:43 GMT