From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.5-pre1 X-Received: by 2002:ac8:5fd5:: with SMTP id k21mr3726673qta.231.1623416831591; Fri, 11 Jun 2021 06:07:11 -0700 (PDT) X-Received: by 2002:a25:fc1c:: with SMTP id v28mr5602123ybd.277.1623416831228; Fri, 11 Jun 2021 06:07:11 -0700 (PDT) Path: eternal-september.org!reader02.eternal-september.org!news.mixmin.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 11 Jun 2021 06:07:11 -0700 (PDT) In-Reply-To: Injection-Info: google-groups.googlegroups.com; posting-host=5.51.16.193; posting-account=lzjH_AoAAABq5H4FTxZ1AkonVQLbXoxB NNTP-Posting-Host: 5.51.16.193 References: <331aa8fb-271a-4a3a-b95e-d10733cbc404n@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <9d0e2e43-a4a5-421c-843f-e03f4fd800e4n@googlegroups.com> Subject: Re: Is it possible to redirect text output to a String or Unbounded_String? From: Stephane Carrez Injection-Date: Fri, 11 Jun 2021 13:07:11 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader02.eternal-september.org comp.lang.ada:62174 List-Id: Hi! Le jeudi 10 juin 2021 =C3=A0 09:00:31 UTC+2, Dmitry A. Kazakov a =C3=A9crit= =C2=A0: > On 2021-06-10 04:17, Jerry wrote:=20 > > Is it possible to redirect text output to a String or Unbounded_String = rather than to a file? > From Ada.Text_IO? No you cannot, File_Type is not tagged. For a stream=20 > you could. Tero Koskinen has made an interesting implementation in Ahven for that. Basically he redirects the standard output to a file for the execution of t= he unit test method. The unit test method executes and can use the Ada.Text_IO without change. After the unit test completion, it reads the file. If I'm not wrong, have a look at the Ahven.Temporary_Output package: https://hg.sr.ht/~tkoskine/ahven/browse/src/ahven-temporary_output.ads?rev= =3Dtip https://hg.sr.ht/~tkoskine/ahven/browse/src/ahven-temporary_output.adb?rev= =3Dtip Best regards, Stephane