[Pharo-project] Help "migrating" from classic streams to XStreams

Nicolas Cellier nicolas.cellier.aka.nice at gmail.com
Fri May 13 21:50:18 CEST 2011


And concerning nextNumber nextString etc... this supposes a certain
format, we can't guess.
If you have a DSL for your data with known grammar, you could try a PEG parser.

Otherwise, if your data are in a classical Smalltalk format in ASCII,
you could use Number readFrom: yourXTCompatibilityReadStream.
Otherwise if you have a specific binary encoded data, it's up to you...

Nicolas

2011/5/13 Nicolas Cellier <nicolas.cellier.aka.nice at gmail.com>:
> Of course, another way is simply to define a
> *XTream-classic-API-compatibility in upper level XTReadStream, but
> that's less fun :)
>
> Nicolas
>
> 2011/5/13 Nicolas Cellier <nicolas.cellier.aka.nice at gmail.com>:
>> Don't do it exclusively for file, but do it for every XTream
>> One way to do it would be with a wrapper.
>> I mean create a new subclass of XTReadStream, say
>> XTCompatibilityReadStream  implement the compatibility methods you
>> want.
>> Same for WriteStream.
>> You'll have to define a few XTream messages too that delegates to the
>> source/destination
>>
>> blah
>>    ^source blah
>>
>> foo
>>    ^destination foo
>>
>>
>> Then define something like
>>
>> XTReadStream>>classicalStreamAPI
>>    ^XTCompatibilityReadStream on: self
>>
>> My 2c.
>>
>> Nicolas
>>
>> 2011/5/13 Mariano Martinez Peck <marianopeck at gmail.com>:
>>> Hi guys. We are developing Fuel with Martin Dias. Fuel is a binary
>>> serializer similar to Parcels. More info in
>>> http://rmod.lille.inria.fr/web/pier/software/Fuel
>>>
>>> For the moment, we are using the "classic" streams we want to give it a try
>>> to XStreams. My knowledge on streams is very little, so if someone can give
>>> me a hint I would really appreciate it.
>>> What I want to do right now is an adaptor of XStreams to classic stream. I
>>> mean, I want to create custom subclasses of XTFileWriteStream and
>>> XTFileReadStream that implements the same API from classic streams that we
>>> use in Fuel. And the implementations of such methods will do just a "self
>>> something" where something is the way of doing that in XStreams.
>>>
>>> So, the following is the protocol we use in Fuel for streams, and what I
>>> would love to know is the associated way to do it it XStreams. The left is
>>> classic streams, and after the "->" it is XStreams:
>>>
>>> Reading:
>>>
>>> nextNumber: -> ??
>>> nextPutAll: -> write:
>>> nextStringPut: -> ??
>>> nextPut:  -> put:
>>> nextNumber:put: -> ??
>>> nextWordPut: -> ??
>>>
>>> Writing:
>>>
>>> nextNumber: -> ??
>>> next:  -> read:
>>> nextString -> ??
>>> next  -> get
>>> nextWord -> ??
>>>
>>> Thanks a lot in advance,
>>>
>>>
>>> --
>>> Mariano
>>> http://marianopeck.wordpress.com
>>>
>>>
>>
>



More information about the Pharo-project mailing list