comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: Binary and XML serialization of types
Date: Fri, 24 Jan 2014 17:13:59 +0000
Date: 2014-01-24T17:13:59+00:00	[thread overview]
Message-ID: <lyr47xxpyg.fsf@pushface.org> (raw)
In-Reply-To: 52e227f4$0$6553$9b4e6d93@newsspool4.arcor-online.net

Georg Bauhaus <rm.dash-bauhaus@futureapps.de> writes:

> On 23.01.14 20:58, hanslad@gmail.com wrote:
>> Thanks Adam,
>>
>> Ok,that makes sense.
>> One more question: Am I on the right path here, or is there a better
>> way to do binary encoding into streams? I want this to perform as
>> fast as possible.
>
> If speed is paramount and the setup permits the same representation
> of data at either end of the line, then using the Read and Write
> procedures for Stream_Element_Array is likely to be unbeatable
> (Streams.Stream_IO).
> This suggests conversion of objects of type Guid into objects of
> type Stream_Element_Array with the help of an 'Address clause or
> through an instance of Unchecked_Conversion. (And some careful
> commenting might be a good idea.)

As long as there's no awkward implementation detail in there .. for
example, GNAT's Ada.Containers.Vectors has

   type Vector is new Controlled with record
      Elements : Elements_Access;
      Last     : Extended_Index := No_Index;
      Busy     : Natural := 0;
      Lock     : Natural := 0;
   end record;

but

   procedure Write
     (Stream    : not null access Root_Stream_Type'Class;
      Container : Vector)
   is
   begin
      Count_Type'Base'Write (Stream, Length (Container));

      for J in Index_Type'First .. Container.Last loop
         Element_Type'Write (Stream, Container.Elements.EA (J));
      end loop;
   end Write;

Also, see the loop at the end of Write; Element_Type might have its own
complicated structure.

I'd say that the fact you're probably going to send the streamed data
over the wire means that speed won't be paramount. On the other hand,
you might want to minimise the number of OS interactions ...


  reply	other threads:[~2014-01-24 17:13 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-23 18:53 Binary and XML serialization of types hanslad
2014-01-23 19:15 ` adambeneschan
2014-01-23 19:17   ` adambeneschan
2014-01-23 19:58     ` hanslad
2014-01-23 20:03       ` adambeneschan
2014-01-23 21:00       ` Dmitry A. Kazakov
2014-01-24  8:54         ` hanslad
2014-01-24 10:01           ` Dmitry A. Kazakov
2014-01-24 14:44             ` hanslad
2014-01-24 15:22               ` Dmitry A. Kazakov
2014-01-31  9:51                 ` hanslad
2014-01-31 10:49                   ` Dmitry A. Kazakov
2014-02-04 10:33                     ` AdaMagica
2014-02-04 11:14                       ` Dmitry A. Kazakov
2014-02-04 11:20                         ` AdaMagica
2014-02-04 13:04                           ` Dmitry A. Kazakov
2014-02-04 17:16                             ` AdaMagica
2014-02-04 17:57                               ` Dmitry A. Kazakov
2014-02-04 22:34                               ` Simon Wright
2014-02-05  9:02                                 ` AdaMagica
2014-02-05  9:39                                   ` Simon Wright
2014-02-05 10:35                                   ` Dmitry A. Kazakov
2014-02-05 13:03                                     ` AdaMagica
2014-02-05 13:44                                       ` G.B.
2014-02-05 15:34                                       ` Niklas Holsti
2014-02-06  1:32                                       ` adambeneschan
2014-01-24 17:36             ` Simon Wright
2014-01-24  8:44       ` Georg Bauhaus
2014-01-24 17:13         ` Simon Wright [this message]
2014-01-23 22:44   ` Simon Wright
2014-01-23 23:43     ` adambeneschan
2014-01-24  0:58       ` Randy Brukardt
2014-01-24  8:29       ` Oliver Kleinke
2014-01-24 16:22         ` adambeneschan
replies disabled

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