From: "David C. Hoos, Sr." <david.c.hoos.sr@ada95.com>
Subject: Re: Usage of Ada.Streams
Date: 2000/01/19
Date: 2000-01-19T00:00:00+00:00 [thread overview]
Message-ID: <H89h4.6268$Wn2.140519@newsread2.prod.itd.earthlink.net> (raw)
In-Reply-To: 862lc7$s8a$1@inf2.informatik.uni-stuttgart.de
Joerg Ruedenauer <ruedenjg@trick.informatik.uni-stuttgart.de> wrote in
message news:862lc7$s8a$1@inf2.informatik.uni-stuttgart.de...
> Hello there,
>
> I don't quite know how to use Ada.Streams to read Objects using
> dispatching.
> To be specific, I have a private tagged type, say Data, and want to
> read/write Objects derived from that type. Writing works fine like this:
> Data_Pointer: PData; -- an access all Data'class
> Str: Stream_Access;
> ...
> Data'Class'Write(Str, Data.all);
> But I can't find a solution to read the objects equally nice. From the
> Ada95 Rationale I gather I should use 'Input and 'Output somehow, but I'm
> just missing an example. Could anyone help me?
>
If you want to have the tags in the stream (so that the specific
types can be distinguished when reading back), you need to use:
Data'Class'Output(Str, Data_Pointer.all);
Then, to read them back, you would say:
Data_Pointer := new Data'Class'(Data'Class'Input (str));
That statement allocates memory for the object, and initializes it
with the value read from the stream.
next prev parent reply other threads:[~2000-01-19 0:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-01-18 0:00 Usage of Ada.Streams Joerg Ruedenauer
2000-01-19 0:00 ` David C. Hoos, Sr. [this message]
2000-01-19 0:00 ` Pascal Obry
2000-01-19 0:00 ` David C. Hoos, Sr.
2000-01-19 0:00 ` Pascal Obry
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox