* Ada streams @ 2004-12-15 7:43 Daniel Vencler 2004-12-15 13:41 ` John B. Matthews ` (2 more replies) 0 siblings, 3 replies; 5+ messages in thread From: Daniel Vencler @ 2004-12-15 7:43 UTC (permalink / raw) Hi, I want to ask you where I can get good explanation what are and how to use (and when) ada streams. There are few ada tutorials on net but not single one of them mentions streams. Best regards, Daniel Vencler ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Ada streams 2004-12-15 7:43 Ada streams Daniel Vencler @ 2004-12-15 13:41 ` John B. Matthews 2004-12-15 17:26 ` Nick Roberts 2004-12-15 19:26 ` David C. Hoos 2 siblings, 0 replies; 5+ messages in thread From: John B. Matthews @ 2004-12-15 13:41 UTC (permalink / raw) In article <cpoq0o$vuk$1@sunce.iskon.hr>, Daniel Vencler <danielMAKNI@geofoto.hr> wrote: > Hi, I want to ask you where I can get good explanation > what are and how to use (and when) ada streams. There are few > ada tutorials on net but not single one of them mentions streams. > > > Best regards, > Daniel Vencler Warren Gay has added a section on streams to "The Big Online Book of Linux Ada Programming": <http://www.pegasoft.ca/resources/boblap/11.html#11.12> -- John jmatthews at wright dot edu www dot wright dot edu/~john.matthews/ ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Ada streams 2004-12-15 7:43 Ada streams Daniel Vencler 2004-12-15 13:41 ` John B. Matthews @ 2004-12-15 17:26 ` Nick Roberts 2004-12-15 19:35 ` tmoran 2004-12-15 19:26 ` David C. Hoos 2 siblings, 1 reply; 5+ messages in thread From: Nick Roberts @ 2004-12-15 17:26 UTC (permalink / raw) Daniel Vencler wrote: > Hi, I want to ask you where I can get good explanation what are and > how to use (and when) ada streams. There are a few ada tutorials on > the net but not single one of them mentions streams. To answer the question of when to use streams, the brief answer is: in almost any situation where you are not using text I/O (using the package Ada.[Wide_]Text_IO and its children), and a few besides. Consider a variety of different file types in common use today: the JPEG pictorial image format; the PKWare ZIP compression format; the Microsoft word processor DOC format; the HTML (HyperText Markup Language) format used for web pages. For the HTML format, you may wish to use Ada.Text_IO, but for some rather esoteric (and unfortunate) technical reasons, you might want to use Ada.Streams.Stream_IO. For all the others, you will certainly want to use Ada.Streams.Stream_IO. Similarly, streams will be used to perform packet-based network communications, and possibly some other kinds of communications. A package will provide a stream into which you write data into a packet (it's payload), prior to sending the packet, as well as a stream to read the (payload) data out of a packet when it is received. A device driver (interface) package for a printer, say, may well provide a stream into which you write the data to be sent to the printer. There are certain rare situations in which you might want to streams for a purpose other than I/O, for example a memory buffer. Section 11.12 of the Big Online Book of Linux Ada Programming, as pointed to by another replier, seems to give quite a good introduction into how to use streams. Maybe I should say a quick word on what a stream is. In practice, a stream is a sequence of bytes -- which are called 'octets' formally -- which comprise the binary representation of one or a sequence of variable values. The values can be of any type. The bytes do not normally encode the type (they do if you use the Output procedure on a tagged type) of each value, nor do they encode what the sequence of values was (if there was more than one value). You simply have to know these things to read the values back again correctly. The binary representation of each type will depend on the target machine, and is in any case implementation specific. These means that, unless you take special precautions, you must use the same compiler and target machine to read a file as you used to write the file in the first place. Ada.Streams.Stream_IO can be used to read binary files in a standard format (such as JPEG, ZIP, or DOC), provided you know the exact details of the formats of all the data types in the format, and use representation clauses or other methods to read those data types correctly. I hope this is helpful. I think you'll have to ask more specific questions to get more detailed answers. -- Nick Roberts ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Ada streams 2004-12-15 17:26 ` Nick Roberts @ 2004-12-15 19:35 ` tmoran 0 siblings, 0 replies; 5+ messages in thread From: tmoran @ 2004-12-15 19:35 UTC (permalink / raw) >Maybe I should say a quick word on what a stream is. In practice, a >stream is a sequence of bytes -- which are called 'octets' formally -- >which comprise the binary representation of one or a sequence of >variable values. The values can be of any type. The bytes do not Ada.Streams gives a standardized way for the designer of an object to supply "IO" routines for that object. Thus Bitmap'Write might in fact create a JPEG compressed version of an in-memory bitmap array. If a user creates a composite object he automatically gets an IO routine that will make the necessary calls for the component parts. Thus given type Stereo_Image_Type is record Left, Right : Bitmap; end record; Stereo_Image_Type'Write(F,Scene); will automatically call Bitmap'Write on the Left and Right images (unless overridden, of course). Ada.Streams does not require you to use Ada.Streams.Stream_IO, however, so you can also create specialized children of Root_Stream_Type which don't do IO, but rather something else. You might just want the Stream_Element_Count of the size of the object, or perhaps a checksum of its Stream_Element_Array representation. ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Ada streams 2004-12-15 7:43 Ada streams Daniel Vencler 2004-12-15 13:41 ` John B. Matthews 2004-12-15 17:26 ` Nick Roberts @ 2004-12-15 19:26 ` David C. Hoos 2 siblings, 0 replies; 5+ messages in thread From: David C. Hoos @ 2004-12-15 19:26 UTC (permalink / raw) To: Daniel Vencler; +Cc: comp.lang.ada@ada.eu.org One answer to the "when" question is "when you want to read and write heterogeneous data to a file." Such an example may be found at my web site ftp://ada95.com/pub/pet_store.tar.gz or ftp://ada95.com/pub/pet_store.tgz In addition to demonstrating streams, it demonstrates the use of some of the object-oriented features of Ada95 -- e.g. derivation of concrete types from abstract parent types. ----- Original Message ----- From: "Daniel Vencler" <danielMAKNI@geofoto.hr> Newsgroups: comp.lang.ada To: <comp.lang.ada@ada-france.org> Sent: Wednesday, December 15, 2004 1:43 AM Subject: Ada streams > Hi, I want to ask you where I can get good explanation > what are and how to use (and when) ada streams. There are few > ada tutorials on net but not single one of them mentions streams. > > > Best regards, > Daniel Vencler > > _______________________________________________ > comp.lang.ada mailing list > comp.lang.ada@ada-france.org > http://www.ada-france.org/mailman/listinfo/comp.lang.ada > ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2004-12-15 19:35 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2004-12-15 7:43 Ada streams Daniel Vencler 2004-12-15 13:41 ` John B. Matthews 2004-12-15 17:26 ` Nick Roberts 2004-12-15 19:35 ` tmoran 2004-12-15 19:26 ` David C. Hoos
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox