From: Simon Wright <simon@pushface.org>
Subject: Re: Better way to fill Storage_IO?
Date: Mon, 17 May 2021 20:14:36 +0100 [thread overview]
Message-ID: <lymtstxjdv.fsf@pushface.org> (raw)
In-Reply-To: c6e99ba9-6455-4279-b175-343735acf2ecn@googlegroups.com
Michael Hardeman <mhardeman25@gmail.com> writes:
> So I've been messing around with the new Ada 2020 package
> Ada.Streams.Storage.Bounded/Unbounded; and if I'm understand it
> correctly it allows you to treat your program's memory like a stream
> without having to open file descriptors (which should make it
> faster?). That seems like a powerful abstraction to me and a great
> addition to the language.
This would be my version:
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Streams.Storage.Unbounded;
procedure Test is
Test : constant String := "040b2cec765b4bbbdb29d83b6dcaf776";
Test_Stream : aliased Ada.Streams.Storage.Unbounded.Stream_Type;
begin
String'Output (Test_Stream'Access, Test);
declare
S : constant String := String'Input (Test_Stream'Access);
begin
Put_Line (S);
end;
end Test;
'Output writes the discriminants of the object, if any, then the object;
'Input uses them to reconstruct the object, so in this case that means
the bounds, and hence the length.
> I was wondering if we could find a better way to fill the stream other
> than writing the variables into it? Can anyone figure out a good way
> to just stream a variable's bytes directly?
This *is* the way to just stream the variable's bytes directly. What
sort of syntax were you hoping for?
next prev parent reply other threads:[~2021-05-17 19:14 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-17 18:44 Better way to fill Storage_IO? Michael Hardeman
2021-05-17 19:14 ` Simon Wright [this message]
2021-05-17 19:23 ` Michael Hardeman
2021-05-18 20:39 ` Simon Wright
2021-05-19 6:24 ` Dmitry A. Kazakov
2021-05-19 7:17 ` J-P. Rosen
2021-05-19 8:26 ` Björn Lundin
2021-05-19 19:25 ` J-P. Rosen
2021-05-19 19:58 ` Dmitry A. Kazakov
2021-05-19 20:18 ` Björn Lundin
2021-05-20 5:38 ` Niklas Holsti
2021-05-20 6:50 ` J-P. Rosen
2021-05-20 22:24 ` Randy Brukardt
2021-05-19 15:39 ` Simon Wright
2021-05-17 20:20 ` Dmitry A. Kazakov
2021-05-17 20:48 ` Michael Hardeman
2021-05-18 14:00 ` Per Sandberg
2021-05-18 9:08 ` J-P. Rosen
2021-05-18 10:10 ` Jeffrey R. Carter
2021-05-18 16:50 ` Shark8
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox