comp.lang.ada
 help / color / mirror / Atom feed
From: mheaney@ni.net (Matthew Heaney)
Subject: Re: Associating strings with buffers?
Date: 1997/04/11
Date: 1997-04-11T00:00:00+00:00	[thread overview]
Message-ID: <mheaney-ya023680001104972227110001@news.ni.net> (raw)
In-Reply-To: 5im1cs$kap@basement.replay.com


In article <5im1cs$kap@basement.replay.com>, Harold Hoes
<hhoes@nym.alias.net> wrote:

>Is there a predefined package to associate strings with buffers?
>Thanks in advance.

I don't know what you mean.

There are some string buffer packages, though:

Ada.Strings.Fixed
Ada.Strings.Bounded
Ada.Strings.Unbounded

Is that what you want?

Here's a lower-level way of associating a string with a buffer:

subtype Length_Range is Natural range 0 .. 132;

type String_Buffer (Length : Length_Range := 0) is
   record
      Text : String (1 .. Length);
   end record;

function "+" (R : String) return String_Buffer is
begin
   return (R'Length, R);
end;

So you can do this:

Send_Pete_To_Town:
declare
   The_String : String_Buffer;
begin
   The_String := +"how now brown cow";
   The_String := +"Goodbye Sister Disco";
   The_String := +"don't cry, don't say goodbye, it's only teenage wasteland";
   Text_IO.Put_Line (The_String.Text);
end Send_Pete_To_Town;

Of course, type Ada.Strings.Bounded is prefered for this sort of thing.  I
show this technique because it's sometimes useful for other kinds of
arrays.

--------------------------------------------------------------------
Matthew Heaney
Software Development Consultant
<mailto:matthew_heaney@acm.org>
(818) 985-1271




      reply	other threads:[~1997-04-11  0:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-04-11  0:00 Associating strings with buffers? Harold Hoes
1997-04-11  0:00 ` Matthew Heaney [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