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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,7876e4356325725b X-Google-Attributes: gid103376,public From: dennison@telepath.com Subject: Re: Ada.Streams examples Date: 1999/03/10 Message-ID: <7c6s4s$hrt$1@nnrp1.dejanews.com>#1/1 X-Deja-AN: 453562684 References: <36e61db4.50430543@news.pacbell.net> <7c64kl$r8s$1@nnrp1.dejanews.com> <36e6cd2c.3377267@news.pacbell.net> X-Http-User-Agent: Mozilla/4.5 [en] (WinNT; I) X-Http-Proxy: 1.0 x17.dejanews.com:80 (Squid/1.1.22) for client 204.48.27.130 Organization: Deja News - The Leader in Internet Discussion X-Article-Creation-Date: Wed Mar 10 22:36:14 1999 GMT Newsgroups: comp.lang.ada Date: 1999-03-10T00:00:00+00:00 List-Id: In article <36e6cd2c.3377267@news.pacbell.net>, tmoran@bix.com (Tom Moran) wrote: > I'll take a look at Cohen (my son took my copy away to college). Cool! You must be very proud of him. :-) > I want to do an S'Read routine for a large array. I really don't > want to iteratively call Element'Read for each element. Is there an > alternative to the usual Unchecked_Conversion, overlaying, etc to get > the data into my array? If the array were in a Sequential_IO file I Not that I've discovered. But in this context I don't see anything wrong with Unchecked_Conversion. Converting types is what its there for. > The RM implies that an object's stream representation should be > similar to its in-memory representation (a generalization from > 13.13.2(17)). If I have an object which has a standard external Not only is that just implementation advice, but it also starts with the word "If". > representation (a Windows bmp bitmap, for instance) but a slightly > different Ada representation in my program (discriminants, say), is it > better to convert the object on Write to the "standard" external form, > or to write it out as an Ada object as close as possible to its > internal, Ada, memory form? This is not addressed in AQS - anybody > have any experience with these choices? It depends on what you want to do. If you want to be able to write a bmp to any stream, not just a file, then you should probably put the conversion in the 'Write. If you will always write bmp's to the same type of stream, and never want to put other non-bmp information in those same stream objects, then it might make sense to create your own "bmp stream". If neither really holds, I'd go with the one that seems the better abstraction in your environment. Now lets say you have a screen bitmap stored memory. You want to write this to disk as a BMP file. I see three options: o Create a 'Write procedure for that bitmap type which converts the bitmap to a bmp and does one massive Write call for the stream. The problem with this approach is that if anyone ever wants to do a 'Write on a bitmap for any reason, the'll get a BMP. You can't overload it to get a JPG or GIF or a straight memory dump (which is what they might be expecting). o Create a new stream that converts Write data into GIF format, and saves it to a file. The problem here is that the input data *must* be a bitmap of our specified format, or this stream will produce garbage. There's no real way in the language to enforce this. Also, we can't count on getting all the data in one big Write call. This may be OK for BMP, but for a compressing scheme like GIF it complicates matters. o Create a Write_BMP and Read_BMP routine that take in files and bitmaps as parameters, and forget about streams. Random objects cannot now be placed an a "BMP" file. The strength of streams IMHO is the ability to do I/O on hetrogenious data. In our example I don't think that's a loss, so the last option is probably the way to go. T.E.D. -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own