* Reading sequential data from Ada.Text_Io.Standard_Input?
@ 1996-07-09 0:00 David J. Fiander
1996-07-09 0:00 ` Robert Dewar
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: David J. Fiander @ 1996-07-09 0:00 UTC (permalink / raw)
So, I want to read from standard input, using Ada.Sequential_Io.
I've got
declare
type Byte is mod 256; for Byte'Size use 8;
package Byte_Io is new package Ada.Sequential_Io(Byte);
Ch: Byte;
begin
Byte_Io.Read(Text_Io.Standard_Input, Ch);
-- process the byte;
end;
which clearly doesn't work, since Text_Io.Standard_Input is most
definitely not a Byte_Io.File_Type. So I try
Byte_Io.Read(Byte_Io.File_Type(Text_Io.Standard_Input), Ch);
at which Gnat reports "ambiguous operand", since Standard_Input
is either a Text_Io.File_Type or a Text_Io.File_Access and Gnat
can't figure out which I want. So I try
Byte_Io.Read(Byte_Io.File_Type(Text_Io.File_Type'(Text_Io.Standard_Input)), Ch);
which is certainly a mouthful, but also doesn't work. Gnat
reports
invalid conversion, not compatible with private type
"Ada.Text_Io.File_Type"
thereby informing me that, now that it knows what I want to do,
it's decided that I can't get there from here.
So, what, if anything, is the magic incantation to read raw data
from standard input?
- David
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Reading sequential data from Ada.Text_Io.Standard_Input?
1996-07-09 0:00 Reading sequential data from Ada.Text_Io.Standard_Input? David J. Fiander
@ 1996-07-09 0:00 ` Robert Dewar
1996-07-09 0:00 ` Michael Paus
1996-07-09 0:00 ` Robert A Duff
2 siblings, 0 replies; 4+ messages in thread
From: Robert Dewar @ 1996-07-09 0:00 UTC (permalink / raw)
David asks how to read raw data from standard input. The answer is to
use Stream_IO, it's all setup for that.
You could also create an appropriate sequential_io descriptor, have a look
at package
package Ada.Sequential_IO.C_Streams is
in file s-siocst.ads, which permits opening a sequent file given a C
stream identifier (there are analogous packages for all the I/O packages
in GNAT).
You certainly cannot expect success following the line you were trying.
File types are completely different for different I/O packages, and here
there is no reason to think you could convert one to another. GNAT does
not "know what you want to do", as far as it is concerned you are trying
a totally junk type conversion from one type to a completely unrelated
type that makes no sense at all.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Reading sequential data from Ada.Text_Io.Standard_Input?
1996-07-09 0:00 Reading sequential data from Ada.Text_Io.Standard_Input? David J. Fiander
1996-07-09 0:00 ` Robert Dewar
@ 1996-07-09 0:00 ` Michael Paus
1996-07-09 0:00 ` Robert A Duff
2 siblings, 0 replies; 4+ messages in thread
From: Michael Paus @ 1996-07-09 0:00 UTC (permalink / raw)
davidf@worf.mks.com (David J. Fiander) wrote:
> So, I want to read from standard input, using Ada.Sequential_Io.
>
[...]
> So, what, if anything, is the magic incantation to read raw data
> from standard input?
The key to this kind of problem is to use the new Ada 95 streams
facility. Have a look at "A.12 Stream Input-Output". You can get
a stream access value which is associated with Standard_Input with
a declaration like this:
S : Ada.Text_IO.Text_Streams.Stream_Access
:= Ada.Text_IO.Text_Streams.Stream(Ada.Text_IO.Standard_Input);
You will need to with
Ada.Text_IO, Ada.Text_IO.Text_Streams and Ada.Streams.Stream_IO
in order to get that working.
Have fun
Michael
PS: If you are interested I can send you a little example with a writer
application which writes a data structure to a stream which is
associated with standard output and a reader application which recreates
this data structure from a stream which is connected to standard input.
On UNIX you might then execute these apps like
> writer | reader
which means that the data produced by writer is piped into reader.
--
------------------------------------------------------------------------
--Dipl.-Ing. Michael Paus (Member: Team Ada)
--University of Stuttgart, Inst. of Flight Mechanics and Flight Control
--Forststrasse 86, 70176 Stuttgart, Germany
--Phone: (+49) 711-121-1434 FAX: (+49) 711-634856
--Email: Michael.Paus@ifr.luftfahrt.uni-stuttgart.de (NeXT-Mail welcome)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Reading sequential data from Ada.Text_Io.Standard_Input?
1996-07-09 0:00 Reading sequential data from Ada.Text_Io.Standard_Input? David J. Fiander
1996-07-09 0:00 ` Robert Dewar
1996-07-09 0:00 ` Michael Paus
@ 1996-07-09 0:00 ` Robert A Duff
2 siblings, 0 replies; 4+ messages in thread
From: Robert A Duff @ 1996-07-09 0:00 UTC (permalink / raw)
In article <4rsibv$2mo@ia.mks.com>,
David J. Fiander <davidf@worf.mks.com> wrote:
>So, what, if anything, is the magic incantation to read raw data
>from standard input?
Try Ada.Text_IO.Text_Streams (or whatever it's called).
- Bob
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~1996-07-09 0:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-07-09 0:00 Reading sequential data from Ada.Text_Io.Standard_Input? David J. Fiander
1996-07-09 0:00 ` Robert Dewar
1996-07-09 0:00 ` Michael Paus
1996-07-09 0:00 ` Robert A Duff
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox