comp.lang.ada
 help / color / mirror / Atom feed
From: Lucretia <laguest9000@googlemail.com>
Subject: Re: Interface Ada string with C++ std::string
Date: Wed, 4 Jul 2018 04:23:22 -0700 (PDT)
Date: 2018-07-04T04:23:22-07:00	[thread overview]
Message-ID: <6294202b-73d0-4c8c-af6f-e3435b4432c3@googlegroups.com> (raw)
In-Reply-To: <3199b658-cc7d-47be-bc4d-a8346c0d765a@googlegroups.com>

On Wednesday, 4 July 2018 04:33:59 UTC+1, Roger  wrote:
> On Wednesday, July 4, 2018 at 2:56:15 AM UTC+10, Lucretia wrote:
> > On Tuesday, 3 July 2018 13:59:56 UTC+1, Roger  wrote:
> > > I am need to interface an Ada procedure to a C++ function that takes a  std::string as an input parameter.
> > > Can someone advise me how to do this?
> > 
> > See https://github.com/Lucretia/test_binding
> 
> Thanks for this, it looks promising.
> I have cloned test_binding, built and run it and am now using it as a basis for my own situation.

All you probably need is a C function which returns the string c_str() to Ada which Ada can then use, wrap that in Ada. Just define a private type for the string class which is an address and pass that to the C function.

package CPP_Strings is
   type CPP_String is private;

   function Get (S : in CPP_String) return String; -- Wrap the C->Ada stuff inside here.
private
   type CPP_String is System.Address;
end CPP_Strings;

  parent reply	other threads:[~2018-07-04 11:23 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-03 12:59 Interface Ada string with C++ std::string Roger
2018-07-03 13:13 ` Dan'l Miller
2018-07-03 13:16   ` Roger
2018-07-03 16:34     ` Jacob Sparre Andersen
2018-07-03 16:52       ` Roger
2018-07-03 16:56 ` Lucretia
2018-07-04  3:33   ` Roger
2018-07-04  4:13     ` Roger
2018-07-04 11:23     ` Lucretia [this message]
2018-07-04 11:45       ` Roger
2018-07-04 11:52         ` Lucretia
2018-07-05  1:08           ` Roger
2018-07-05 23:32 ` Roger
replies disabled

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