From: Victor Porton <porton@narod.ru>
Subject: Re: Convert chars_ptr to Ada String
Date: Sun, 09 Jul 2017 09:49:31 +0300
Date: 2017-07-09T09:49:31+03:00 [thread overview]
Message-ID: <ojsjlr$a4g$1@gioia.aioe.org> (raw)
In-Reply-To: eba70dac-4c1b-437d-b9f2-2941e3ba01b9@googlegroups.com
Anh Vo wrote:
> 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);
I see no such two-argument To_Ada in Interfaces.C.
Or where to import such To_Ada from?
> end;
>
> end RDF.Auxiliary.Convert;
--
Victor Porton - http://portonvictor.org
next prev parent reply other threads:[~2017-07-09 6:49 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
2017-07-09 6:49 ` Victor Porton [this message]
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