From: "Steve" <nospam_steved94@comcast.net>
Subject: Re: Design help
Date: Fri, 9 Mar 2007 20:40:47 -0800
Date: 2007-03-09T20:40:47-08:00 [thread overview]
Message-ID: <a_WdnTLNitz7q2_YnZ2dnUVZ_umlnZ2d@comcast.com> (raw)
In-Reply-To: mailman.116.1173480208.18371.comp.lang.ada@ada-france.org
>"Carroll, Andrew" <andrew.carroll@okstate.edu> wrote in message
>news:mailman.116.1173480208.18371.comp.lang.ada@ada-france.org...
>I am trying to design (what I guess is) a database table adapter. Yes,
>it is a master's course assignment. The current design is to use a file
>and have one record per line. My goal is to get each line to be
>"serialized" so I can read the whole line in bytes and then take chunks
>of it and "cast" those into objects.
>
>On this list from a previous poster I found:
>
> type Byte is range 0..255;
> for Byte'Size use 8;
> package Byte_IO is new Sequential_IO(Byte);
>
This defines a scalar data type for bytes. Ok so far.
>Does that mean I could define the record like:
>
> type dbrecord is range 0..sum_of_sizes_of_attributes;
> for dbrecord'size use sum_of_sizes_of_attributes;
> package DBRecord_IO is new Sequential_IO(dbrecord);
>
This looks a bit odd. Here a scalar range is called "dbrecord" is defined
that may contain the values in the range of 0 to
sum_of_sizes_of_attributes.
So, for example, if sum_of_sizes_of_attributes is 32, values of type
dbrecord may be assigned values in the range of 0 to 32. The representation
clause for dbrecord'size use sum_of size_attributes indicates that the
storage size for those values is 32 bits... So values in the range of 0 to
32 are being stored in 32 bits... no problem with that, but I don't think it
is what was intended.
>My next big question....
>
>If I had
> myrec: dbrecord;
> ...
> Dbrecord := <some data>...
> ...
>
> X := dbrecord(33..70); --what type is x here?
> attribute := cast(X); --how do I cast x to an 'class?
>
>
>Am I making any sense?
>
Not really.
I would suggest that you pick up a book on Ada. It is a language worth
learning.
Regards,
Steve
(The Duck)
>
>Andrew Carroll
>Software Services
>405-744-4943
>andrew.carroll@okstate.edu
>
next prev parent reply other threads:[~2007-03-10 4:40 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-09 22:43 Design help Carroll, Andrew
2007-03-09 23:07 ` Simon Wright
2007-03-10 1:00 ` Jeffrey R. Carter
2007-03-10 4:40 ` Steve [this message]
2007-03-10 13:38 ` Ludovic Brenta
2007-03-17 20:34 ` Michael Erdmann
-- strict thread matches above, loose matches on Subject: below --
2007-03-13 0:50 Carroll, Andrew
2007-03-13 2:48 ` Randy Brukardt
2007-03-13 8:52 ` Stuart
2007-03-13 9:40 ` Dmitry A. Kazakov
2007-03-13 20:18 ` Simon Wright
2007-03-13 22:22 ` Randy Brukardt
2007-03-26 14:56 Carroll, Andrew
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox