comp.lang.ada
 help / color / mirror / Atom feed
From: "J-P. Rosen" <rosen@adalog.fr>
Subject: Re: General circular buffer example not tied to any specific type
Date: Thu, 24 Sep 2020 06:39:43 +0200	[thread overview]
Message-ID: <rkh7ue$opf$1@dont-email.me> (raw)
In-Reply-To: <b78b92f1-a34e-42aa-a0e8-30635bf632bao@googlegroups.com>

Le 24/09/2020 à 06:10, nimaopatel121@gmail.com a écrit :
> On Saturday, 4 July 2020 22:30:28 UTC+5:30, Daniel  wrote:
>> Hello, any theoric 
>>  example of buffer i can find is always tied to an specific type.
>>
>> I'm looking for any example of ravenscar buffer able for using any type of data at the same time.
>>
>> I suppose it will need to serialize all  data and manipulate it as a group of bytes.
>>
>> Does any body knows any example of this written in Ada?
> 
Hmmm, you know, Ada is a strongly typed language, therefore what you put
in a buffer must have a well defined type.

There are two possibilities:
1) If you can accept several buffers, one for each type, make it generic
and instantiate it as many times as you need

2) Make a buffer of Stream_Elements, and use the streaming attributes
('Read, 'Write) to turn any type into stream elements.

Ada.Streams.Stream_IO can also be handy in some cases.

-- 
J-P. Rosen
Adalog
2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX
Tel: +33 1 45 29 21 52, Fax: +33 1 45 29 25 00
http://www.adalog.fr

  reply	other threads:[~2020-09-24  4:39 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-04 17:00 General circular buffer example not tied to any specific type Daniel
2020-07-04 17:25 ` Dmitry A. Kazakov
2020-07-05  9:37   ` Simon Wright
2020-07-05  9:52     ` Simon Wright
2020-07-05 13:25       ` Jeffrey R. Carter
2020-07-05 15:36         ` Simon Wright
2020-07-05 18:46           ` Dmitry A. Kazakov
2020-07-05 19:51             ` Simon Wright
2020-07-06  8:11         ` Simon Wright
2020-07-06  8:58           ` Jeffrey R. Carter
2020-07-06 10:34             ` Simon Wright
2020-07-06 11:07               ` Dmitry A. Kazakov
2020-09-03 10:31 ` riya patel
2020-09-24  4:10 ` nimaopatel121
2020-09-24  4:39   ` J-P. Rosen [this message]
2020-09-25 14:32 ` Simon Wright
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox