comp.lang.ada
 help / color / mirror / Atom feed
From: sjw <simon.j.wright@mac.com>
Subject: Re: Overriding the "lowest level" stream procedures
Date: Sun, 11 Oct 2009 11:57:34 -0700 (PDT)
Date: 2009-10-11T11:57:34-07:00	[thread overview]
Message-ID: <7335707d-21d2-4060-b51a-b4077eea6a79@f16g2000yqm.googlegroups.com> (raw)
In-Reply-To: 87tyy6c52o.fsf@willow.rfc1149.net

On Oct 11, 4:39 pm, Samuel Tardieu <s...@rfc1149.net> wrote:
> >>>>> "xorque" == xorque  <xorquew...@googlemail.com> writes:
>
> xorque> I think I probably need to define my own Stream type. Is this
> xorque> the case?
>
> You can plug your code at two different levels:
>
>   - define your own stream type; you will manipulate byte arrays, but
>     you will not have access to any type information;
>
>   - define your own stream attributes: you will decide how typed values
>     are transformed into/from byte arrays, but you cannot override this
>     choice for predefined types as you have to define those attributes
>     in the same declarative unit as the type definition itself.
>
> You will likely want to use the second method, in which case you'll have
> to refrain from using predefined types.

A third way, if you are using GNAT, is to provide your own body for
System.Stream_Attributes (s-stratt.adb) and compile using gnatmake -a
(not sure how to do this using gprbuild, though).

This gives you the ability to control how the individual elements of
the data are mapped to the bytes of the stream; but there is no
knowledge of what the elements mean at an application level (ie, no
visibility of the type that's being streamed, just that this element
is a Float).




  reply	other threads:[~2009-10-11 18:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-11 14:56 Overriding the "lowest level" stream procedures xorque
2009-10-11 15:39 ` Samuel Tardieu
2009-10-11 18:57   ` sjw [this message]
2009-10-11 19:31     ` Samuel Tardieu
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox