Read/write structs in streams (Tango, and Strings)

Bill Baxter wbaxter at gmail.com
Wed Oct 22 07:55:47 PDT 2008


On Wed, Oct 22, 2008 at 11:24 PM, Steven Schveighoffer
<schveiguy at yahoo.com> wrote:
> "Robert Kosek"  wrote
>> Robert Kosek Wrote:
>>
>>> Hello again folks,
>>
>> I know I asked a really basic question, but I haven't found a real answer
>> either in the Tango documentation or the D language documentation either.
>> This makes it really tough to know how I can save structures to a stream
>> for later use.
>>
>> Can someone please tell me if I can read/write structures with dynamic
>> length strings from/to a stream?  And if not, then how can I read and
>> write a string to the stream (without the helper stream class)?
>
> I am not completely knowledgable in the stream classes of Tango that do
> serialization, but I don't think there's anything to do what you want.  It
> would be difficult for the stream class to know the exact layout of your
> struct, so how would it know when to output strings?  I think DataStream is
> what you are looking for, but it will only output a block of data.
>
> Again, not completely knowledgable.  You might try asking on the Tango
> forums to get the attention of some of the Tango devs that don't pay
> attention to the NG.

Tom S. was working on a nifty ctfe/mixin serialization module.  But I
think it's been on the back burner for a while.  Aarti_pl has one too
in the doost libs.
Neither is really complete.

And yes you need some kind of library if you want to stream arbitrary
structs which may or may not contain pointers to disk.   And no,
neither Tango nor Phobos has such a library.

--bb


More information about the Digitalmars-d-learn mailing list