From: Anh Vo <anhvofrcaus@gmail.com>
Subject: Re: Convert chars_ptr to Ada String
Date: Fri, 7 Jul 2017 16:14:13 -0700 (PDT)
Date: 2017-07-07T16:14:13-07:00 [thread overview]
Message-ID: <eba70dac-4c1b-437d-b9f2-2941e3ba01b9@googlegroups.com> (raw)
In-Reply-To: <ojp35c$1vi8$1@gioia.aioe.org>
On Friday, July 7, 2017 at 3:49:20 PM UTC-7, Victor Porton wrote:
> Anh Vo wrote:
>
> > On Friday, July 7, 2017 at 2:03:32 PM UTC-7, Victor Porton wrote:
> >> Remind me how to convert a pair of Ptr: chars_ptr and Size: size_t to an
> >> Ada string.
> >>
> >> Ptr may contain NULs and this should not influence the length of the
> >> resulting string.
> >
> > Look at APIs defined in package Interfaces.C.Strings.
>
> I've done it:
>
> https://github.com/vporton/redland-bindings/blob/ada2012/ada/src/rdf-auxiliary-convert.adb
>
> It requires not only Interfaces.C.Strings but also Interfaces.C.Pointers
> to make things more confusing.
Why make it more confusing while it is actually simpler as shown below.
with Interfaces.C.Strings; use Interfaces.C.Strings;
package body RDF.Auxiliary.Convert is
function Value_With_Possible_NULs (Item: RDF.Auxiliary.C_Pointers.Pointer; Length: size_t) return String is
begin
return To_Ada(Item, Length);
end;
end RDF.Auxiliary.Convert;
next prev parent reply other threads:[~2017-07-07 23:14 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-07 21:03 Convert chars_ptr to Ada String Victor Porton
2017-07-07 22:23 ` Anh Vo
2017-07-07 22:48 ` Victor Porton
2017-07-07 23:14 ` Anh Vo [this message]
2017-07-09 6:49 ` Victor Porton
2017-07-10 4:58 ` Anh Vo
2017-07-10 9:31 ` Victor Porton
2017-07-10 9:48 ` Dmitry A. Kazakov
2017-07-10 12:41 ` Mark Lorenzen
2017-07-10 14:24 ` Dmitry A. Kazakov
2017-07-10 21:21 ` Victor Porton
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox