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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,6c383a046f41e91 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!feeder1-2.proxad.net!proxad.net!feeder2-2.proxad.net!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Text_IO from a stream Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <0465edf8-7272-43c8-82fd-fcae7cf0ef11@y21g2000hsf.googlegroups.com> <1y2oi69ev939v.1xugoel9fadnb$.dlg@40tude.net> <0c9ab8b7-a666-4fd2-a876-dca818ad5461@c65g2000hsa.googlegroups.com> <17unr8ffxzcm.1ee1ucd0fwd1q$.dlg@40tude.net> <47f138b6$1_5@news.bluewin.ch> Date: Mon, 31 Mar 2008 21:47:37 +0200 Message-ID: <1rmypswe6uyhs.10fy5p7ytb4os$.dlg@40tude.net> NNTP-Posting-Date: 31 Mar 2008 21:47:37 CEST NNTP-Posting-Host: 913c92a3.newsspool1.arcor-online.net X-Trace: DXC=;Sbg760P>KHgj[ZPFj7ehOic==]BZ:afN4Fo<]lROoRA8kFJ2Z@_EWRXZ37ga[7JjTA67ckJ=XEOd1Fn4;H7:C9cK5;kAhh=B X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:20685 Date: 2008-03-31T21:47:37+02:00 List-Id: On Mon, 31 Mar 2008 21:17:10 +0200, Gautier wrote: > Dmitry A. Kazakov: >> But a stream has no defined formatting and is unrelated to ASCII. > > Still, you can read the stream through Character'Read(s,c). Yes, but will that be ASCII-encoded? And it has somehow invent lines and pages. >> Then the idea of parsing stream looks problematic. If you have in the stream a >> sequence " + -", what Get should do after discovering '-'? > > Exactly the same behaviour as when parsing an ill-formatted text. Ah, yes. I cannot find the place in ARM, but it seems that Text_IO would swallow syntactically incorrect input before propagating Data_Error. > Reading a text file (or supposedly so) indirectly via a stream and Stream_IO > would have the same result that via Ada.Text_IO. > >> Anyway, it is quite simple to do. You can do >> >> type Formatted_Stream (Source : access Root_Stream_Type'Class) is >> tagged limited private; >> function Get (Stream : access Formatted_Stream) return Integer; >> ... >> >> The implementation of Formatted_Stream will use Source for all its I/O. So >> you could hang it on any existing stream. > > Fine, seems I need to rewrite a Text_IO for streams. I hoped for a ready-made > solution... But Text_IO also defines all Get procedures on String. So if you knew where line ends are in your stream you could cache the current line in Formatted_Stream and then simply route all its Gets to Ada.Text_IO Gets. > Well, I think I'll switch to a binary format... I would do that too. Also I would override 'Read and 'Write in order to make it platform-independent. (Stream_Element should be replaced by octets.) -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de