comp.lang.ada
 help / color / mirror / Atom feed
From: "John J. Cupak Jr." <jcj@swl.msd.ray.com>
To: Tom Moran <tmoran@bix.com>
Subject: Re: Stream_IO
Date: 1998/03/04
Date: 1998-03-04T00:00:00+00:00	[thread overview]
Message-ID: <34FD9042.41C67EA6@swl.msd.ray.com> (raw)
In-Reply-To: 34fcb5c5.33132164@SantaClara01.news.InterNex.Net


Tom Moran wrote:
> 
> Is there a way to use Stream_IO to read a file produced by other than
> the program doing the reading, in particular, a file binary file
> produced, say, with C?  The RM indicates the representation is
> implementation defined, and 'read apparently quite ignores rep
> clauses, so I find one compiler reads integer things of 'size 8 or 16
> as 16, and another reads size 16 things as size 32.  I hate to read
> into a String and then do Unchecked_Conversions or 'address overlays,
> but I don't see any other portable approach.  Help!

Tom,

I solved a similar problem a while ago by creating a "Byte_IO" package,
with generic Read and Write procedures for the user's data (typically, a
record).

The package instantiated Sequential_IO for bytes, and did unchecked
conversion of the user's data (in the generic Read and Write code
bodies) to byte arrays of corresponding size which were then read and
written (depending on the appropriate procedure, of course).

The application program had to "know" what kind of data it was supposed
to read or write, as the generic Read and Write procedures certianly did
not. This was easy, actually, since the first read/write was always a
"header" record containing the counts of the various data records.

Hope this helps. 
-- 
--------------------------------------------------------------
-                 John J. Cupak Jr, CCP                      -
- Raytheon Systems Company - Software Engineering Laboratory -
- tel: 508-858-1222   email (work): jcj@swl.msd.ray.com      -
- fax: 508-858-4336   email (home): jcupak@aol.com           -
--------------------------------------------------------------




  reply	other threads:[~1998-03-04  0:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-03-04  0:00 Stream_IO Tom Moran
1998-03-04  0:00 ` John J. Cupak Jr. [this message]
1998-03-04  0:00 ` Stream_IO Stephen Leake
replies disabled

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