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,FREEMAIL_FROM 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 16:02:02 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!hammer.uoregon.edu!newsfeed.direct.ca!look.ca!newsfeed1.earthlink.net!newsfeed.earthlink.net!newsmaster1.prod.itd.earthlink.net!newsread2.prod.itd.earthlink.net.POSTED!not-for-mail Newsgroups: comp.lang.ada Subject: Re: Looping over a tagged record? From: Charles Hixson References: Organization: Mandala Fluteworks Message-ID: User-Agent: Xnews/4.06.11 Date: Thu, 21 Jun 2001 23:02:01 GMT NNTP-Posting-Host: 198.94.156.19 X-Complaints-To: abuse@earthlink.net X-Trace: newsread2.prod.itd.earthlink.net 993164521 198.94.156.19 (Thu, 21 Jun 2001 16:02:01 PDT) NNTP-Posting-Date: Thu, 21 Jun 2001 16:02:01 PDT X-Received-Date: Thu, 21 Jun 2001 15:59:53 PDT (newsmaster1.prod.itd.earthlink.net) Xref: archiver1.google.com comp.lang.ada:9012 Date: 2001-06-21T23:02:01+00:00 List-Id: tmoran@acm.org wrote in news:ltrY6.111132$%i7.79731461@news1.rdc1.sfba.home.com: >> basically need to do is examine the incoming data and >... > 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. > That looks quite interesting. I would definitely need to supply my own read, and probably my own write too, since the objects will likely need to be stored in non-contiguous areas of the file. (If freed space can't be reused, the process would be unacceptably inefficient. And when dealing with small chunks of data I would also need to be able to pack then into blocks.) If I can make that work it will certainly be better than the alternatives that had occurred to me. (Address mapped storage, e.g., with arbitrary mappings needing to be defined. Ugh! Or tagged types, with all of the basic types defined for every possible offset into the block. Ugh! again.) ... After looking at the package: Perhaps I need to rethink things to use arbitrary sized blocks rather than fixed size blocks. Otherwise it looks like just what I was looking for! -- Charles Hixson Copy software legally, the GNU way! Use GNU software, and legally make and share copies of software. See http://www.gnu.org http://www.redhat.com http://www.linux-mandrake.com http://www.calderasystems.com/ http://www.linuxapps.com/