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=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=unavailable autolearn_force=no version=3.4.4 X-Google-Thread: 103376,28a24746aa07c732 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!newsfeed.freenet.de!solnet.ch!solnet.ch!proxad.net!cleanfeed3-a.proxad.net!nnrp16-2.free.fr!not-for-mail Return-Path: X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: Design help Date: Mon, 12 Mar 2007 19:50:11 -0500 X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Design help Thread-Index: AcdlCY21fvFhGPvxSf6e8ZfllWJAmg== From: "Carroll, Andrew" To: X-Virus-Scanned: amavisd-new at ada-france.org X-BeenThere: comp.lang.ada@ada-france.org X-Mailman-Version: 2.1.9rc1 Precedence: list List-Id: "Gateway to the comp.lang.ada Usenet newsgroup" List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.ada Message-ID: X-Leafnode-NNTP-Posting-Host: 88.191.17.134 Organization: Guest of ProXad - France NNTP-Posting-Date: 13 Mar 2007 01:55:02 MET NNTP-Posting-Host: 88.191.14.223 X-Trace: 1173747302 news-1.free.fr 28799 88.191.14.223:51239 X-Complaints-To: abuse@proxad.net Xref: g2news1.google.com comp.lang.ada:14501 Date: 2007-03-13T01:55:02+01:00 I hope to have the database records be variable length however it may make my life easier if they are fixed length due to the fact that some of the record structures contain pointers. I guess that would be access type instead of pointer, anyway... Here are the record structures I have defined: type attribute is tagged record name : string_ptr; domain : string_ptr; isprimarykey : boolean :=3D false; byte_start : integer; byte_end : integer; size : integer; end record; ----------------------------------- -- Extended Attribute Types -- ----------------------------------- type booleanattribute is new attribute with record value : boolean :=3D false; end record; type booleanattribute_ptr is access all booleanattribute'class; type integerattribute is new attribute with record value : integer :=3D 0; end record; type integerattribute_ptr is access all integerattribute'class; type stringattribute is new attribute with record value : string_ptr; end record; type stringattribute_ptr is access all stringattribute'class; type dateattribute is new attribute with record year : ada.calendar.year_number; month : ada.calendar.month_number; day : ada.calendar.day_number; value : ada.calendar.time; end record; type dateattribute_ptr is access all dateattribute'class; Obviously a database tuple could have any combination of these in it but luckily I only have to worry about 5 attributes in a database table schema. So, I want to read a whole database tuple in as a bit string (or something like that) and then be able to convert small sections of it into the appropriate record structures above for each of the attributes defined on the table. =20 I can get rid of the string_ptr and set a default string size. If I did that I would be pretty close to a fixed-width database record and could use something like Ludovic mentioned. I think the drawback to this is that I would have to have an I/O package for each type of attribute right? Like this: package Attribute_IO is new Ada.Sequential_IO (Element_Type =3D> Attribute);=20 package BooleanAttribute_IO is new Ada.Sequential_IO (Element_Type =3D> BooleanAttribute);=20 package IntegerAttribute_IO is new Ada.Sequential_IO (Element_Type =3D> IntegerAttribute);=20 package StringAttribute_IO is new Ada.Sequential_IO (Element_Type =3D> StringAttribute);=20 package DateAttribute_IO is new Ada.Sequential_IO (Element_Type =3D> DateAttribute);=20 It seems like the second method that Ludovic mentioned might be better in my case even if there is a fixed-width database record. For each type I have I could define a constructor function. Like this: function To_BooleanAttribute (Raw_Bytes : in Ada.Streams.Stream_Element_Array) return T Is Begin --but I don't know what to do here. --I'm assuming that because it's an array of stream_elements (bytes?)=20 --that I can grab any number of them from the array. --something like Raw_Bytes(offset_byte..size); --where offset_byte index could be calculated ??? --and the size would be taken from the size of the attribute type. -- --this is where I need help.=20 --even if I knew that I could do the above, I wouldn't know how to make --it officially a BooleanAttribute (in this case). Would I use a=20 --Qualified expression like: return BooleanAttribute'(Raw_Bytes(offset_byte..size)); End to_t; HTHYHM Andrew Carroll Software Services 405-744-4943 andrew.carroll@okstate.edu