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=-0.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,da8a419b0e3fda81 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1994-09-20 05:14:23 PST Newsgroups: comp.lang.ada Path: bga.com!news.sprintlink.net!howland.reston.ans.net!noc.near.net!inmet!dsd!bobduff From: bobduff@dsd.camb.inmet.com (Bob Duff) Subject: Re: Portable way to read/write from a binary file? Message-ID: Sender: news@inmet.camb.inmet.com Organization: Intermetrics, Inc. References: <355kao$38d@goanna.cs.rmit.oz.au> <122484@cup.portal.com> <122506@cup.portal.com> <35iuqj$5dj@goanna.cs.rmit.oz.au> Date: Mon, 19 Sep 1994 17:46:15 GMT Date: 1994-09-19T17:46:15+00:00 List-Id: In article <35iuqj$5dj@goanna.cs.rmit.oz.au>, Dale Stanbrough wrote: >In article , kst@alsys.com writes: >>For Ada 94 (assuming X=4 8-)}), I think Stream_IO does what you want. >> > >Unfortunately not (as I read it!) >Each object in a stream has a tag appended to it so that the >procedure S'Class'Read can reconstruct the value from the tag >contained within the stream (13.13.2.14). No. S'Class'Read and S'Class'Write do not generally read and write tags. (S'Class'Input and S'Class'Output do.) Furthermore, if you're not using tagged types, then no tags are written or read by any of these things. The Stream_IO package and the streams stuff in 13.13 are definitely intended for doing binary I/O. A typical case is where the various types are *not* tagged (or discriminated or unconstrained arrays or anything fancy like that), and S'Write and S'Read can be used directly. You won't get tags or other dope mixed in with your data. >As well the representation of stream elements is implementation >defined (13.13.2.17) True, but in practice that's not a big problem. After all, the representation of Sequential_IO, Direct_IO, and Text_IO files are also implementation defined. You have to trust the implementation to use a "reasonable" representation. 13.13.2(18-20) give advice about what a reasonable representation is. Most languages that support binary I/O are similar in this regard. (Not COBOL, though.) >The best solution seems to be to use pragma import or use the >Posix_IO package. Note that Posix_IO, or pretty much any other I/O package, also has an implementation-defined representation of the data. -- Bob Duff bobduff@inmet.com Oak Tree Software, Inc. Ada 9X Mapping/Revision Team (Intermetrics, Inc.)