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,c689b55786a9f2bd X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,UTF8 Path: g2news2.google.com!news1.google.com!goblin2!goblin.stu.neva.ru!aioe.org!not-for-mail From: =?utf-8?Q?Yannick_Duch=C3=AAne_=28Hibou57?= =?utf-8?Q?=29?= Newsgroups: comp.lang.ada Subject: Re: for S'Image use Func?? Date: Tue, 11 May 2010 00:39:06 +0200 Organization: Ada At Home Message-ID: References: <4be417b4$0$6992$9b4e6d93@newsspool4.arcor-online.net> <1qcb6z4i20dyb.1dz2hd4c0vx69.dlg@40tude.net> NNTP-Posting-Host: ra5wLii/U0tbQP170oFAeA.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes Content-Transfer-Encoding: Quoted-Printable X-Complaints-To: abuse@aioe.org X-Notice: Filtered by postfilter v. 0.8.2 User-Agent: Opera Mail/10.53 (Win32) Xref: g2news2.google.com comp.lang.ada:11477 Date: 2010-05-11T00:39:06+02:00 List-Id: Le Mon, 10 May 2010 22:56:11 +0200, Maciej Sobczak = a =C3=A9crit: > Coming back to I/O - what I miss in Ada is the equivalent of fread in > C - that is, an operation that reads *up to* the given number of > bytes. Or maybe there is something that I didn't notice? It's there : look at [ARM 2005 13.13.1] which defines the package = Ada.Streams, which in turn contains the following : type Root_Stream_Type is abstract tagged limited private; ... type Stream_Element is mod implementation-defined; ... procedure Read (Stream : in out Root_Stream_Type; Item : out Stream_Element_Array; Last : out Stream_Element_Offset) is abstract; procedure Write (Stream : in out Root_Stream_Type; Item : in Stream_Element_Array) is abstract; So, these are abstract. Now the question is : =E2=80=9Cwhere are the con= cret = implementation=E2=80=9D ? The answer is =E2=80=9Cin derived types=E2=80=9D= . Here is one, as a quick and one of the most useful example (see [ARM 200= 5 = 1.12.2]) : with Ada.Streams; package Ada.Text_IO.Text_Streams is type Stream_Access is access all Streams.Root_Stream_Type'Class; function Stream (File : in File_Type) return Stream_Access; end Ada.Text_IO.Text_Streams; This re-define Stream_Access (why this access type is redefined here, is= = another story previously discussed with an answer from Randy), and defin= e = a function which returns a Stream_Access from a File_Type. This File_Typ= e = is the one defined in the parent package, that is, Ada.Text_IO. In Ada.Text_IO, you have (see [ARM 2005 A.10.1]) some other interesting = = definitions, which will close the list of required stuff : function Standard_Input return File_Access; function Standard_Output return File_Access; function Standard_Error return File_Access; Summary : in Ada.Text_IO, you have Standard_XXXX or other File_Type. You= = can use this (using an XXX.all to get a File_Type from a File_Access) as= = an argument to the Ada.Text_IO.Text_Streams.Stream function, which will = = return you a Stream_Access which will dispatch to an implementation of = = Ada.Streams.Read and Ada.Streams.Write. Well, to be honest, this is not exactly the same as with C, as = Ada.Streams.Stream_Element is implementation defined (which is good, = because this is indeed platform dependent), so you will need an Assert = pragma somewhere is your application, which ensures = Ada.Streams.Stream_Element is 8 bits or at least 8 bits (this is, in mos= t = of case), and then convert from Ada.Streams.Stream_Element to your = Byte_Type or anything your application defined as such. Sorry for being long, I just wanted to give all the details. However, th= is = is not so much complicated as all those explanations seems to suggest. -- = No-no, this isn't an oops ...or I hope (TM) - Don't blame me... I'm just= = not lucky