discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Need help with serialization/deserialization interface.


From: Richard Frith-Macdonald
Subject: Re: Need help with serialization/deserialization interface.
Date: Mon, 22 Jan 2007 08:46:07 +0000


On 21 Jan 2007, at 22:28, Tima wrote:

Most of the time JSON will be read from stream socket, sometimes from file, therefore I was seeking for some universal object that provides per- character read
access without requiring any knowledge of the media.

In C++ there are input and output streams (<iostream>) that are widely used for
I/O when a programmer wants to detach the API from a particular media.

I was reading about NSStream and its subclasses and got confused. I realized I can get them for socket, file or memory buffer, but I did not realize how to use them for
per-character input or output.

NSStream is probably what you want to use, but it provides per-byte I/ O. not per-character I/O. There is no API for per-character I/O, but you could subclass NSStream to add that if you really want it.

What is the recommended way to do buffered I/O in NextStep?

You can use NSStream or NSFileHandle. Both are pretty low-level in their own way, so quite likely you would want to add your own higher- level control. NSFileHandle does I/O in large chunks ... which might be what suits you. NSStream can be used for buffered I/O by chaining together a memory stream and a stream that writes to a device directly.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]