From: Victor Porton <porton@narod.ru>
Subject: Re: Convert chars_ptr to Ada String
Date: Mon, 10 Jul 2017 12:31:53 +0300
Date: 2017-07-10T12:31:53+03:00 [thread overview]
Message-ID: <ojvhi9$3in$1@gioia.aioe.org> (raw)
In-Reply-To: c5cee585-831b-4cd1-b928-df1c32e2a4e9@googlegroups.com
Anh Vo wrote:
> On Saturday, July 8, 2017 at 11:49:34 PM UTC-7, Victor Porton wrote:
>> 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?
>
> Oops! I meant function value which is defined in Interfaces.C.Strings.
Read description of Value() carefully. It stops at first NUL.
--
Victor Porton - http://portonvictor.org
next prev parent reply other threads:[~2017-07-10 9:31 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
2017-07-10 4:58 ` Anh Vo
2017-07-10 9:31 ` Victor Porton [this message]
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