From: "Thomas Løcke" <thomas.granvej6@gmail.com>
Subject: Re: Load an object from a file
Date: Fri, 03 Apr 2009 15:41:04 +0200
Date: 2009-04-03T15:41:04+02:00 [thread overview]
Message-ID: <49d611f1$0$90264$14726298@news.sunsite.dk> (raw)
In-Reply-To: <49d5fa88$0$2862$ba620e4c@news.skynet.be>
Olivier Scalbert wrote:
> But I do not know what is the best (Ada) way of representing the array
> of info constant_pool as the size is only known at run time.(=
> constant_pool_cout).
> Also how can I fill this array ?
>
> Thanks to help me and have a nice day.
Hey Olivier,
I don't know if it's the "best" way, but I would use
Ada.Containers.Vector in your case. Here's a small example:
-----
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Containers.Vectors; use Ada.Containers;
procedure Vec is
type CP_Info_Type is new String (1 .. 3);
package Constant_Pool_Container is new Vectors (Natural, CP_Info_Type);
Constant_Pool : Constant_Pool_Container.Vector;
CP_Info : CP_Info_Type;
begin
CP_Info := "Foo";
Constant_Pool.Append (New_Item => CP_Info);
CP_Info := "Bar";
Constant_Pool.Append (New_Item => CP_Info);
CP_Info := "42!";
Constant_Pool.Append (New_Item => CP_Info);
for i in 0 .. Constant_Pool.Last_Index loop
Put_Line (String (Constant_Pool.Element (Index => i)));
end loop;
end Vec;
-----
If all goes well, output should be:
Foo
Bar
42!
You can read more about Ada.Containers.Vectors here:
http://adaic.org/standards/05rm/html/RM-A-18-2.html
:o)
/Thomas
prev parent reply other threads:[~2009-04-03 13:41 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-03 12:01 Load an object from a file Olivier Scalbert
2009-04-03 13:07 ` Niklas Holsti
2009-04-03 13:37 ` Ludovic Brenta
2009-04-03 15:19 ` Olivier Scalbert
2009-04-03 16:08 ` Georg Bauhaus
2009-04-03 16:22 ` Ludovic Brenta
2009-04-03 16:41 ` Olivier Scalbert
2009-04-03 16:46 ` Adam Beneschan
2009-04-03 20:22 ` Ludovic Brenta
2009-04-09 20:32 ` Olivier Scalbert
2009-04-09 21:22 ` Ludovic Brenta
2009-04-09 22:22 ` Olivier Scalbert
2009-04-19 13:08 ` Olivier Scalbert
2009-04-19 19:52 ` Ludovic Brenta
2009-04-19 20:27 ` Gautier
2009-04-03 13:41 ` Thomas Løcke [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox