From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,7e490a18b9688bd9 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!x21g2000prd.googlegroups.com!not-for-mail From: Alexander Korolev Newsgroups: comp.lang.ada Subject: Re: Stream_Element_Array Date: Wed, 14 Sep 2011 01:34:42 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <4e703bcd$0$32104$a8266bb1@newsreader.readnews.com> NNTP-Posting-Host: 96.49.119.210 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1315989283 622 127.0.0.1 (14 Sep 2011 08:34:43 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 14 Sep 2011 08:34:43 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: x21g2000prd.googlegroups.com; posting-host=96.49.119.210; posting-account=9aAl4woAAACPkuvNJOQxyBXxG_5lfu_0 User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: HUARLECNK X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_5; ru-ru) AppleWebKit/533.18.1 (KHTML, like Gecko) Version/5.0.2 Safari/533.18.5,gzip(gfe) Xref: g2news2.google.com comp.lang.ada:21898 Date: 2011-09-14T01:34:42-07:00 List-Id: On Sep 14, 9:29=A0am, Per Sandberg wrote: > Why not just: > =A0 =A0Message_Header'Write(Output_Stream,My_Message_Header) > That would serialize the Data into the stream. > > If the target stream is a blocked message why not do > =A0 =A0Message_Header'Write(Buffer_Stream,My_Message_Header) > =A0 =A0Buffer_Stream'Write(Output_Stream,Buffer_Stream) > > And the Buffer_Stream is a stream of the kind found in: > =A0 =A0http://sourceforge.net/projects/ada-spread/ > =A0 =A0 =A0 =A0 =A0spread-memory_streams.* > or > > https://github.com/persan/zeromq-Ada > =A0 =A0 zmq-utilities-memory_streams.ad > > Which now is part of fedora15 > /Per > > On 09/14/2011 05:13 AM, Alexander Korolev wrote: > > > > > I have a Type > > > type Message_Header is > > =A0 =A0 =A0record > > =A0 =A0 =A0 =A0 -- Components =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0-- =A0= 8 bit > > =A0 =A0 =A0 =A0 Length =A0 =A0: Unsigned_16; =A0 =A0-- 16 bit =A0(MSB) > > =A0 =A0 =A0 =A0 -- other components =A0 =A0 =A0 =A0 =A0-- =A0 8 bit > > =A0 =A0 =A0end record; > > > How I could split the Lenght component on two subsequent > > Stream_Element ( 8-bit)? > > > Command: Stream_Element_Array (1 .. 64); > > > Thanks Thanks Per I've just tried with GNAT a similar to your suggestion aproach In_Memory_Stream:Volatile_Streams.Memory_Resident_Stream (Size =3D> 128); Message_Length:Stream_Element_Array(1..2); Last:Stream_Element_Count; Msg_Header_Instance:Message_Header; Begin Message_Header'Write(In_Memory_Stream, Msg_Header_Instance); -- writes to meomory read (In_Memory_Stream,Message_Length,Last); -- retreives Message_Length wich is Stream_Element_Array -- and the Last -- I left only one component in Message_Header - the Lengh, expected -- the Last =3D 2, and Message_Length instance filled in after read (...). -- End; Complaints on compilation: "expected access to Ada.Streams.Root_Stream_Type'Access"