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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: "Jeffrey R. Carter" Newsgroups: comp.lang.ada Subject: Re: Using generic package to store and retrieve string data Date: Fri, 7 Oct 2016 16:11:03 -0700 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: <9cbda86b-57e3-4f9c-81bb-03a9a28a4cb6@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Fri, 7 Oct 2016 23:10:51 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="6df4b173985f7c5c043cea362c370ff7"; logging-data="9274"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19DNalQ02IleqQmfaindKycErI/i8ysV9Y=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 In-Reply-To: <9cbda86b-57e3-4f9c-81bb-03a9a28a4cb6@googlegroups.com> Cancel-Lock: sha1:ACznDEfMy/5Iq6gg0Ow8kGpQ9KM= Xref: news.eternal-september.org comp.lang.ada:32045 Date: 2016-10-07T16:11:03-07:00 List-Id: On 10/07/2016 02:30 PM, James Brewer wrote: > Hey guys, I am trying to create a generic package that will take strings of a > fixed length store them in an array one at a time and later remove them one > at a time. I was using a generic stack example I found on the net to get > started but I can't seem to get it to work for string data. > > Is there something that needs to be imported into the main program for string > handling? If your Strings are all the same length, then you need to instantiate the generic with a subtype of that length: subtype Stored_String is String (1 .. Length); package Stored_String_Stack is new Generic_Stack (Size => Max_Stack_Size, Item => Stored_String); If your Strings may have differing lengths, then you should either use Unbounded_String or one of the indefinite containers. > Also, this is just a starting point for getting a generic to function with > string data, ideally this will be converted into a queue. I suggest you familiarize yourself with the standard container library in Annex A.18. One of them will probably do what you want. http://www.ada-auth.org/standards/rm12_w_tc1/html/RM-A-18.html -- Jeff Carter "It's symbolic of his struggle against reality." Monty Python's Life of Brian 78