From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: Victor Porton Newsgroups: comp.lang.ada Subject: Re: Convert chars_ptr to Ada String Date: Sun, 09 Jul 2017 09:49:31 +0300 Organization: Aioe.org NNTP Server Message-ID: References: <567a23f5-a7dc-4b3d-8c16-942a8551c02f@googlegroups.com> NNTP-Posting-Host: UZPBofpaGWLolaA02L4QDw.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Complaints-To: abuse@aioe.org User-Agent: KNode/4.14.10 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:47330 Date: 2017-07-09T09:49:31+03:00 List-Id: 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