comp.lang.ada
 help / color / mirror / Atom feed
From: "Yannick Duchêne (Hibou57)" <yannick_duchene@yahoo.fr>
Subject: Re: for S'Image use Func??
Date: Tue, 11 May 2010 00:39:06 +0200
Date: 2010-05-11T00:39:06+02:00	[thread overview]
Message-ID: <op.vcig7go1ule2fv@garhos> (raw)
In-Reply-To: b7b2dcd9-92d4-40f3-ab85-5c0dfdecb832@b7g2000yqk.googlegroups.com

Le Mon, 10 May 2010 22:56:11 +0200, Maciej Sobczak  
<see.my.homepage@gmail.com> a écrit:
> 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 : “where are the concret  
implementation” ? The answer is “in derived types”.

Here is one, as a quick and one of the most useful example (see [ARM 2005  
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 define  
a function which returns a Stream_Access from a File_Type. This File_Type  
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 most  
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, this  
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



  parent reply	other threads:[~2010-05-10 22:39 UTC|newest]

Thread overview: 154+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-06 17:10 for S'Image use Func?? Warren
2010-05-06 17:23 ` Dmitry A. Kazakov
2010-05-06 20:05   ` Warren
2010-05-06 17:58 ` Adam Beneschan
2010-05-06 19:52   ` Warren
2010-05-07  8:12     ` stefan-lucks
2010-05-08  5:26       ` Stephen Leake
2010-05-10 15:16       ` Charmed Snark
2010-05-07  2:10   ` Randy Brukardt
2010-05-07 18:24     ` Keith Thompson
2010-05-06 18:14 ` Yannick Duchêne (Hibou57)
2010-05-06 20:04   ` Warren
2010-05-06 20:19     ` Robert A Duff
2010-05-06 20:56       ` Yannick Duchêne (Hibou57)
2010-05-06 21:11         ` Robert A Duff
2010-05-07  8:40           ` J-P. Rosen
2010-05-07 12:21             ` Robert A Duff
2010-05-07 13:37               ` Georg Bauhaus
2010-05-07 14:25                 ` Robert A Duff
2010-05-07 15:46                   ` Yannick Duchêne (Hibou57)
2010-05-07 17:38                     ` Dmitry A. Kazakov
2010-05-07 20:15                       ` Yannick Duchêne (Hibou57)
2010-05-07 20:28                         ` Jeffrey R. Carter
2010-05-07 21:16                           ` Randy Brukardt
2010-05-07 22:18                             ` Jeffrey R. Carter
2010-05-09  0:06                               ` Randy Brukardt
2010-05-09  0:31                                 ` Jeffrey R. Carter
2010-05-07 20:31                     ` Robert A Duff
2010-05-07 20:51                       ` Yannick Duchêne (Hibou57)
2010-05-07 21:07                         ` Robert A Duff
2010-05-07 21:25                       ` Randy Brukardt
2010-05-07 22:16                       ` Jeffrey R. Carter
2010-05-10 15:48                   ` Warren
2010-05-10 16:31                     ` Dmitry A. Kazakov
2010-05-10 16:52                       ` Warren
2010-05-10 17:55                         ` Dmitry A. Kazakov
2010-05-10 18:50                           ` Warren
2010-05-10 19:20                             ` Niklas Holsti
2010-05-10 20:16                               ` Warren
2010-05-10 20:38                                 ` Simon Wright
2010-05-10 20:52                                   ` Warren
2010-05-11 17:38                                     ` Jeffrey R. Carter
2010-05-11 18:19                                       ` Yannick Duchêne (Hibou57)
2010-05-11 20:36                                       ` Warren
2010-05-11  7:34                                 ` Niklas Holsti
2010-05-11  7:56                                   ` Yannick Duchêne (Hibou57)
2010-05-11 16:56                                     ` Warren
2010-05-13 18:53                                     ` Niklas Holsti
2010-05-11 16:49                                   ` Warren
2010-05-11  8:26                             ` Dmitry A. Kazakov
2010-05-11  9:49                               ` J-P. Rosen
2010-05-11 17:06                                 ` Warren
2010-05-12  5:00                                   ` J-P. Rosen
2010-05-12 14:39                                     ` Yannick Duchêne (Hibou57)
2010-05-12 16:52                                       ` Warren
2010-05-13 18:20                                     ` Niklas Holsti
2010-05-17 10:00                                       ` J-P. Rosen
2010-05-20  9:31                                         ` Niklas Holsti
2010-05-21  6:56                                           ` Niklas Holsti
2010-05-11 14:27                               ` Robert A Duff
2010-05-11 15:03                                 ` Dmitry A. Kazakov
2010-05-11 15:45                                   ` Yannick Duchêne (Hibou57)
2010-05-11 15:23                               ` Yannick Duchêne (Hibou57)
2010-05-11 16:59                                 ` Dmitry A. Kazakov
2010-05-11 17:05                               ` Warren
2010-05-11 17:54                                 ` Dmitry A. Kazakov
2010-05-11 20:50                                   ` Charmed Snark
2010-05-11 19:03                                 ` Yannick Duchêne (Hibou57)
2010-05-11 20:53                                   ` Warren
2010-05-10 20:56                           ` Maciej Sobczak
2010-05-10 20:24                             ` Georg Bauhaus
2010-05-11  7:42                               ` Maciej Sobczak
2010-05-10 21:30                             ` Ludovic Brenta
2010-05-11  8:35                               ` Dmitry A. Kazakov
2010-05-11 13:35                                 ` Maciej Sobczak
2010-05-11 14:24                                   ` Dmitry A. Kazakov
2010-05-11 20:18                                     ` Maciej Sobczak
2010-05-11 21:46                                       ` Dmitry A. Kazakov
2010-05-12 13:16                                         ` Maciej Sobczak
2010-05-12 14:33                                           ` Yannick Duchêne (Hibou57)
2010-05-12 15:58                                           ` Dmitry A. Kazakov
2010-05-12 22:14                                             ` Maciej Sobczak
2010-05-13  7:31                                               ` Dmitry A. Kazakov
2010-05-13 13:16                                                 ` Warren
2010-05-14 21:03                                                 ` Maciej Sobczak
2010-05-15  8:35                                                   ` Dmitry A. Kazakov
2010-05-15 20:50                                                     ` Maciej Sobczak
2010-05-16  7:48                                                       ` Dmitry A. Kazakov
2010-05-16 20:56                                                         ` Maciej Sobczak
2010-05-16 21:31                                                           ` Dmitry A. Kazakov
2010-05-11 15:56                                 ` Yannick Duchêne (Hibou57)
2010-05-11 17:15                                   ` Dmitry A. Kazakov
2010-05-11 18:48                                     ` Yannick Duchêne (Hibou57)
2010-05-10 22:24                             ` Yannick Duchêne (Hibou57)
2010-05-11  7:58                               ` Maciej Sobczak
2010-05-11 15:54                                 ` Yannick Duchêne (Hibou57)
2010-05-11 20:23                                   ` Maciej Sobczak
2010-05-10 22:39                             ` Yannick Duchêne (Hibou57) [this message]
2010-05-11 17:17                               ` Warren
2010-05-11 17:59                                 ` Dmitry A. Kazakov
2010-05-11 20:56                                   ` Warren
2010-05-11 22:06                                     ` Dmitry A. Kazakov
2010-05-12 13:27                                       ` Warren
2010-05-12 16:03                                         ` Dmitry A. Kazakov
2010-05-11 18:57                                 ` Yannick Duchêne (Hibou57)
2010-05-11 21:08                                   ` Warren
2010-05-11 19:56                               ` Gautier write-only
2010-05-12 13:33                                 ` Warren
2010-05-07 15:35                 ` Yannick Duchêne (Hibou57)
2010-05-07 20:33                   ` Robert A Duff
2010-05-07 21:27                     ` Randy Brukardt
2010-05-07 21:36                       ` Robert A Duff
2010-05-07 22:09                       ` Yannick Duchêne (Hibou57)
2010-05-09  0:17                         ` Randy Brukardt
2010-05-07 19:56               ` J-P. Rosen
2010-05-07 20:14                 ` Robert A Duff
2010-05-07 20:17                 ` Yannick Duchêne (Hibou57)
2010-05-07 20:41                   ` Robert A Duff
2010-05-06 21:20         ` Dmitry A. Kazakov
2010-05-10 15:26       ` Ada & gdb (was: for S'Image use Func??) Warren
2010-05-10 18:02         ` John B. Matthews
2010-05-10 19:52           ` Warren
2010-05-06 22:33     ` for S'Image use Func?? Jeffrey R. Carter
2010-05-06 23:22       ` Yannick Duchêne (Hibou57)
2010-05-07  2:17         ` Randy Brukardt
2010-05-07 12:27           ` Robert A Duff
2010-05-07 15:19             ` Yannick Duchêne (Hibou57)
2010-05-07 20:19               ` Robert A Duff
2010-05-07 21:11             ` Randy Brukardt
2010-05-10 16:05             ` Warren
2010-05-19  6:26               ` Randy Brukardt
2010-05-07 15:21           ` Yannick Duchêne (Hibou57)
2010-05-10 16:03       ` Warren
2010-05-06 18:50 ` Jeffrey R. Carter
2010-05-06 19:50   ` Warren
2010-05-06 20:22     ` Robert A Duff
2010-05-06 21:25       ` Dmitry A. Kazakov
2010-05-07  2:20         ` Randy Brukardt
2010-05-07  7:28           ` Dmitry A. Kazakov
2010-05-07 10:15         ` Stephen Leake
2010-05-07 15:07           ` Yannick Duchêne (Hibou57)
2010-05-08  5:38             ` Stephen Leake
2010-05-07 19:29           ` Simon Wright
2010-05-07 20:10             ` Robert A Duff
2010-05-07 19:44               ` Georg Bauhaus
2010-05-07 20:53                 ` Robert A Duff
2010-05-07 21:59               ` Simon Wright
2010-05-09  0:20                 ` Randy Brukardt
2010-05-07  8:53 ` Georg Bauhaus
2010-05-10 16:18   ` Warren
2010-05-10 17:54     ` Georg Bauhaus
2010-05-10 19:57       ` Warren
2010-05-10 19:09     ` Yannick Duchêne (Hibou57)
2010-05-10 20:01       ` Warren
replies disabled

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