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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,2e8cf506f89b5d0a X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-06-21 12:00:14 PST Path: archiver1.google.com!news2.google.com!newsfeed.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!newshub2.rdc1.sfba.home.com!news.home.com!news1.rdc1.sfba.home.com.POSTED!not-for-mail From: tmoran@acm.org Newsgroups: comp.lang.ada Subject: Re: Looping over a tagged record? References: X-Newsreader: Tom's custom newsreader Message-ID: Date: Thu, 21 Jun 2001 18:58:25 GMT NNTP-Posting-Host: 24.7.82.199 X-Complaints-To: abuse@home.net X-Trace: news1.rdc1.sfba.home.com 993149905 24.7.82.199 (Thu, 21 Jun 2001 11:58:25 PDT) NNTP-Posting-Date: Thu, 21 Jun 2001 11:58:25 PDT Organization: Excite@Home - The Leader in Broadband http://home.com/faster Xref: archiver1.google.com comp.lang.ada:8997 Date: 2001-06-21T18:58:25+00:00 List-Id: > basically need to do is examine the incoming data and figure out > how long it is, and then read it into an appropriate Ada > ... > This part would be relatively straight-forward in C, but so far > I haven't figured out how to do it in Ada. Look at packages Ada.Streams and Ada.Stream_IO Stream_IO lets you read an arbitrary number of bytes into a Stream_Element_Array, and Streams lets you conveniently convert those raw bytes into an object of type whatever. Suppose your data stream has a series of objects. Each object is preceded by a single character identifying code. Then you could Character'Read((Stream, ID_Code); case ID_Code is when 'A' => An_Object_Type'Read(Stream, An_Object); when 'B' => A_Different_Type'Read(Stream, A_Different_Object); ... If An_Object_Type is a record, Ada will automatically read it by a series of 'Read, of the correct type, on each component - or you could override that and instead supply your own 'Read.