comp.lang.ada
 help / color / mirror / Atom feed
From: mcc@tyrolia.cs.princeton.edu (Martin C. Carlisle)
Subject: Re: ObjectAda: LPCSTR -> STRING ?
Date: 1998/01/06
Date: 1998-01-06T00:00:00+00:00	[thread overview]
Message-ID: <68tgdg$c7c$1@cnn.Princeton.EDU> (raw)
In-Reply-To: 884055877.1213464581@dejanews.com


In article <884055877.1213464581@dejanews.com>,
 <matthew_snyder@hotmail.com> wrote:
>I'm working with Aonix ObjectAda 7.1 and I need to figure
>out a way to convert a LPCSTR to an Ada STRING.  I'd appreciate
>any help.  Thanks.

One must assume your question is a Win32Ada question, not specific
to Object Ada.

LPCSTR is equivalent to C's (const char *).

I'd suggest something along the following:

function To_String(c_pointer : in Win32.LPCSTR) return String is
   length       : natural;
   Ignore_lpstr : Win32.LPSTR;
begin
   length := Natural(Win32.Winbase.lstrlen(c_pointer));
   declare
      result : String(1..length+1);
   begin
      Ignore_lpstr := Win32.Winbase.lstrcpy(result'address,
         c_pointer);
      return result(1..length); -- omit null terminating character
   end;
end To_String;

--Martin
-- 
Martin C. Carlisle, Computer Science, US Air Force Academy
mcc@cs.usafa.af.mil, http://www.usafa.af.mil/dfcs/bios/carlisle.html
DISCLAIMER:  This content in no way reflects the opinions, standard or 
policy of the US Air Force Academy or the United States Government.




  reply	other threads:[~1998-01-06  0:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-01-05  0:00 ObjectAda: LPCSTR -> STRING ? matthew_snyder
1998-01-06  0:00 ` Martin C. Carlisle [this message]
1998-01-11  0:00   ` Jerry van Dijk
1998-01-12  0:00   ` Pascal Obry
1998-01-06  0:00 ` Robin Stephe Nora
1998-01-06  0:00   ` Robert Dewar
1998-01-07  0:00     ` Stephen Leake
  -- strict thread matches above, loose matches on Subject: below --
1998-01-20  0:00 matthew_snyder
1998-01-21  0:00 ` Pascal Obry
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox