comp.lang.ada
 help / color / mirror / Atom feed
From: " "@deneb.cygnus.argh.org (Florian Weimer)
Subject: Decoding an octet stream
Date: 1999/11/28
Date: 1999-11-28T11:13:43+00:00	[thread overview]
Message-ID: <877lj2q36g.fsf@deneb.cygnus.argh.org> (raw)

What is the best way to decode an octet stream (i.e. a sequence of
unsigned eight-bit values) with Ada?  The octet stream consists of
packet markes (single octets), two-octet integers (stored with the
most significant octet first), strings (sequences of octets of a given
length) and so on.  I don't want to use Ada.Sequential_IO, because it
would mean that only one octet can be read at a time, which seems to
be quite inefficient.

Streams seem to be nice, though.  If I specify the necessary
representation clauses, I think I'll only have to write a few 'Read
and 'Write operations, and composed types will be handled correctly
almost automatically.  But is this really portable?  Are there any
targets (except supercomputers, mainframes, and embedded systems)
where Stream_Element'Size isn't equal to 8?

BTW: I'm currently reading the two-octet integers using a construct like
`First_Octet * 2**8 + Second_Octet'.  Is it possible to denote the octet
ordering using a representation clause?  For a target with a matching
octet order, more efficient code could be generated.




             reply	other threads:[~1999-11-28  0:00 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-11-28  0:00 Florian Weimer [this message]
1999-11-29  0:00 ` Decoding an octet stream David C. Hoos, Sr.
1999-11-30  0:00   ` Florian Weimer
1999-12-03  0:00     ` Robert Dewar
1999-12-01  0:00   ` Robert Dewar
1999-12-01  0:00     ` Geoff Bull
1999-12-01  0:00       ` Robert Dewar
1999-12-01  0:00     ` David C. Hoos, Sr.
1999-12-01  0:00       ` Robert Dewar
1999-12-07  0:00         ` Stefan Skoglund
1999-12-01  0:00       ` Robert Dewar
1999-12-01  0:00       ` swhalen
1999-12-01  0:00         ` Florian Weimer
1999-12-02  0:00           ` Robert Dewar
1999-12-02  0:00           ` Ted Dennison
1999-12-02  0:00             ` tmoran
1999-12-02  0:00           ` Geoff Bull
1999-12-02  0:00             ` Lutz Donnerhacke
1999-12-01  0:00         ` Larry Kilgallen
1999-12-01  0:00           ` Kenneth Almquist
1999-12-02  0:00             ` Geoff Bull
1999-12-02  0:00               ` Stupid patent tricks (was: Decoding an octet stream) Ted Dennison
1999-12-06  0:00               ` Decoding an octet stream Kenneth Almquist
1999-12-02  0:00         ` Geoff Bull
1999-12-02  0:00           ` Robert Dewar
1999-12-02  0:00           ` swhalen
1999-12-02  0:00             ` Larry Kilgallen
1999-12-03  0:00               ` swhalen
1999-12-04  0:00                 ` Robert Dewar
1999-12-04  0:00                 ` Geoff Bull
1999-12-06  0:00                   ` Robert Dewar
1999-12-03  0:00               ` Geoff Bull
1999-12-06  0:00               ` Richard D Riehle
1999-12-06  0:00                 ` Ed Falis
1999-12-07  0:00                   ` Ted Dennison
1999-12-08  0:00                 ` Robert Dewar
1999-12-08  0:00                   ` Brian Rogoff
1999-12-08  0:00         ` Numeric types Mario Amado Alves
1999-12-08  0:00           ` Tucker Taft
replies disabled

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