From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,c4c8028cd0fdf47 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!f16g2000yqm.googlegroups.com!not-for-mail From: sjw Newsgroups: comp.lang.ada Subject: Re: Overriding the "lowest level" stream procedures Date: Sun, 11 Oct 2009 11:57:34 -0700 (PDT) Organization: http://groups.google.com Message-ID: <7335707d-21d2-4060-b51a-b4077eea6a79@f16g2000yqm.googlegroups.com> References: <87tyy6c52o.fsf@willow.rfc1149.net> NNTP-Posting-Host: 82.30.110.254 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1255287454 24649 127.0.0.1 (11 Oct 2009 18:57:34 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sun, 11 Oct 2009 18:57:34 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: f16g2000yqm.googlegroups.com; posting-host=82.30.110.254; posting-account=_RXWmAoAAADQS3ojtLFDmTNJCT0N2R4U User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_8; en-us) AppleWebKit/531.9 (KHTML, like Gecko) Version/4.0.3 Safari/531.9,gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:8672 Date: 2009-10-11T11:57:34-07:00 List-Id: On Oct 11, 4:39=A0pm, Samuel Tardieu wrote: > >>>>> "xorque" =3D=3D xorque =A0 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: > > =A0 - define your own stream type; you will manipulate byte arrays, but > =A0 =A0 you will not have access to any type information; > > =A0 - define your own stream attributes: you will decide how typed values > =A0 =A0 are transformed into/from byte arrays, but you cannot override th= is > =A0 =A0 choice for predefined types as you have to define those attribute= s > =A0 =A0 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).