
BOSS without writing to files
Quote:
> Has anyone used BOSS (VisualWorks 2.0) without writing to files.
> I'm interested in shipping object structures through sockets but
> I don't want to be required to use a file to do so. Memory is
> much faster!!
Try this in for instance a workspace:
| boss o bytes bossIn object |
"Construct an arbitrary object"
o := OrderedCollection new.
100 timesRepeat: [o add: Random new next].
"create a fresh local boss object"
boss := BinaryObjectStorage onNew: (bytes := ByteArray new: 1000) writeStream.
"put the object on this byte array"
boss nextPut: o.
boss close.
"create a boss object on the byte stream"
bossIn := BinaryObjectStorage onOldNoScan: bytes readStream.
"read object"
object := bossIn next.
bossIn close.
"inspect the result"
object inspect
------------------
If you use a socket then you perhaps also want to add some
info about the length of the bytes that constitutes the
byte array of the bossed package.
But that is trivial!
Regards,
Bjorn Eiderback
---
THE ROYAL INSTITUTE OF TECHNOLOGY voice: +46 (8) 790 6277
Department of Numerical Analysis fax: +46 (8) 102477, 7900930
and Computing Science
Osquars backe 2
S-100 44 Stockholm
Sweden