From: "Jeffrey R. Carter" <spam.jrcarter.not@spam.not.acm.org>
Subject: Re: Using generic package to store and retrieve string data
Date: Fri, 7 Oct 2016 16:11:03 -0700
Date: 2016-10-07T16:11:03-07:00 [thread overview]
Message-ID: <nt9a1p$91q$1@dont-email.me> (raw)
In-Reply-To: <9cbda86b-57e3-4f9c-81bb-03a9a28a4cb6@googlegroups.com>
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
next prev parent reply other threads:[~2016-10-07 23:11 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-07 21:30 Using generic package to store and retrieve string data James Brewer
2016-10-07 23:11 ` Jeffrey R. Carter [this message]
2016-10-08 7:42 ` Dmitry A. Kazakov
2016-10-08 9:01 ` Simon Wright
2016-10-08 10:17 ` Dmitry A. Kazakov
2016-10-08 16:07 ` Jeffrey R. Carter
2016-10-08 16:21 ` Stephen Leake
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox