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:ad4:5613:: with SMTP id ca19mr1394362qvb.3.1621279433381; Mon, 17 May 2021 12:23:53 -0700 (PDT) X-Received: by 2002:a25:c588:: with SMTP id v130mr1924073ybe.504.1621279433123; Mon, 17 May 2021 12:23:53 -0700 (PDT) Path: eternal-september.org!reader02.eternal-september.org!news.uzoreto.com!news-out.netnews.com!news.alt.net!fdc2.netnews.com!peer01.ams1!peer.ams1.xlned.com!news.xlned.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 17 May 2021 12:23:52 -0700 (PDT) In-Reply-To: Injection-Info: google-groups.googlegroups.com; posting-host=99.10.228.144; posting-account=AgomvAoAAAAj6rtZlNDUf1S1XVXbXDpg NNTP-Posting-Host: 99.10.228.144 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <3cfe02b8-18d3-4673-b808-48ad29092517n@googlegroups.com> Subject: Re: Better way to fill Storage_IO? From: Michael Hardeman Injection-Date: Mon, 17 May 2021 19:23:53 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Received-Bytes: 2806 Xref: reader02.eternal-september.org comp.lang.ada:62000 List-Id: On Monday, May 17, 2021 at 3:14:43 PM UTC-4, Simon Wright wrote: >=20 > 'Output writes the discriminants of the object, if any, then the object;= =20 > 'Input uses them to reconstruct the object, so in this case that means=20 > the bounds, and hence the length. > > I was wondering if we could find a better way to fill the stream other= =20 > > than writing the variables into it? Can anyone figure out a good way=20 > > to just stream a variable's bytes directly? > This *is* the way to just stream the variable's bytes directly. What=20 > sort of syntax were you hoping for? I was kind of hoping there would be an interface like Ada.Text_IO.Text_Stre= ams, where you could just directly stream from the variable's address or ac= cess without having to write the variable into the stream first. I'm not su= re, but the writing part seems a bit like an extra step. This would be my version:=20 >=20 > with Ada.Text_IO; use Ada.Text_IO;=20 > with Ada.Streams.Storage.Unbounded;=20 >=20 > procedure Test is=20 > Test : constant String :=3D "040b2cec765b4bbbdb29d83b6dcaf776";=20 > Test_Stream : aliased Ada.Streams.Storage.Unbounded.Stream_Type;=20 > begin=20 > String'Output (Test_Stream'Access, Test);=20 > declare=20 > S : constant String :=3D String'Input (Test_Stream'Access);=20 > begin=20 > Put_Line (S);=20 > end;=20 > end Test;=20 I was kind of trying to show you could move through the stream like a parse= r instead of just consuming the whole thing. i.e. like if you wanted to par= se the hex into an array of Unsigned_32 or Unsigned_64 for some algorithm.