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,577df5d4a0e88785 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2000-12-11 13:40:05 PST Path: supernews.google.com!sn-xit-02!supernews.com!216.227.56.88.MISMATCH!telocity-west!TELOCITY!fr.clara.net!NiOuZphide.fr.clara.net!wanadoo.fr!not-for-mail From: Pascal Obry Newsgroups: comp.lang.ada Subject: Re: constant string array Date: 11 Dec 2000 22:41:08 +0100 Organization: Home - http://perso.wanadoo.fr/pascal.obry Message-ID: References: <910u3p$v9j$1@nnrp1.deja.com> NNTP-Posting-Host: mix-velizy-107-2-26.abo.wanadoo.fr Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: wanadoo.fr 976570803 866 193.249.45.26 (11 Dec 2000 21:40:03 GMT) X-Complaints-To: abuse@wanadoo.fr NNTP-Posting-Date: 11 Dec 2000 21:40:03 GMT User-Agent: Gnus/5.0807 (Gnus v5.8.7) Emacs/20.7 Xref: supernews.google.com comp.lang.ada:2956 Date: 2000-12-11T21:40:03+00:00 List-Id: bjoern_h@my-deja.com writes: > Hi, > > I want to store constant strings (keywords of > Ada) of different > length in an array like that: Since you have asked for constant string and nobody have proposed a solution without Unbounded_String here is my own way to do this: (cut & past from Ada Web Server implementation) ------------------------------------------------------------------------- package body AWS.Messages is type String_Access is access constant String; subtype Status_Code_Image is String (1 .. 3); S100_Message : aliased constant String := "Continue"; S101_Message : aliased constant String := "Switching Protocols"; S200_Message : aliased constant String := "OK"; S201_Message : aliased constant String := "Create"; S202_Message : aliased constant String := "Accepted"; S203_Message : aliased constant String := "Non-Authoritative Information"; S204_Message : aliased constant String := "No Content"; S205_Message : aliased constant String := "Reset Content"; S206_Message : aliased constant String := "Partial Content"; S300_Message : aliased constant String := "Multiple Choices"; ... type Status_Data is record Code : Status_Code_Image; Reason_Phrase : String_Access; end record; Status_Messages : array (Status_Code) of Status_Data := (S100 => ("100", S100_Message'Access), S101 => ("101", S101_Message'Access), S200 => ("200", S200_Message'Access), S201 => ("201", S201_Message'Access), S202 => ("202", S202_Message'Access), S203 => ("203", S203_Message'Access), ... ------------------------------------------------------------------------- Pascal. -- --|------------------------------------------------------ --| Pascal Obry Team-Ada Member --| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE --|------------------------------------------------------ --| http://perso.wanadoo.fr/pascal.obry --| --| "The best way to travel is by means of imagination"