comp.lang.ada
 help / color / mirror / Atom feed
From: Michael Hardeman <mhardeman25@gmail.com>
Subject: Better way to fill Storage_IO?
Date: Mon, 17 May 2021 11:44:04 -0700 (PDT)	[thread overview]
Message-ID: <c6e99ba9-6455-4279-b175-343735acf2ecn@googlegroups.com> (raw)

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.

with Ada.Text_IO; use Ada.Text_IO;
with Ada.Streams; use Ada.Streams;
with Ada.Streams.Storage.Unbounded; use Ada.Streams.Storage.Unbounded;

procedure Test is
  Test : String := "040b2cec765b4bbbdb29d83b6dcaf776";
  Test_Stream : aliased Stream_Type;
begin
  String'Write(Test_Stream'Access, Test);
  for I in 1 .. Element_Count (Test_Stream) loop
    declare
      C : Character;
    begin
      Character'Read (Test_Stream'Access, C);
      Put (C);
    end;
  end loop;
end Test;

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?

             reply	other threads:[~2021-05-17 18:44 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-17 18:44 Michael Hardeman [this message]
2021-05-17 19:14 ` Better way to fill Storage_IO? Simon Wright
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