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 X-Received: by 10.107.183.9 with SMTP id h9mr9880707iof.36.1499662708934; Sun, 09 Jul 2017 21:58:28 -0700 (PDT) X-Received: by 10.36.34.209 with SMTP id o200mr380379ito.0.1499662708906; Sun, 09 Jul 2017 21:58:28 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.glorb.com!188no1761719itx.0!news-out.google.com!f200ni3892itc.0!nntp.google.com!188no1761709itx.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sun, 9 Jul 2017 21:58:28 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=24.6.20.197; posting-account=Qh2kiQoAAADpCLlhT_KTYoGO8dU3n4I6 NNTP-Posting-Host: 24.6.20.197 References: <567a23f5-a7dc-4b3d-8c16-942a8551c02f@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Convert chars_ptr to Ada String From: Anh Vo Injection-Date: Mon, 10 Jul 2017 04:58:28 +0000 Content-Type: text/plain; charset="UTF-8" Xref: news.eternal-september.org comp.lang.ada:47336 Date: 2017-07-09T21:58:28-07:00 List-Id: 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.