comp.lang.ada
 help / color / mirror / Atom feed
* Ada.Strings.Unbounded vs Ada.Containers.Indefinite_Holders
@ 2017-09-21 18:14 Victor Porton
  2017-09-21 21:30 ` AdaMagica
  0 siblings, 1 reply; 8+ messages in thread
From: Victor Porton @ 2017-09-21 18:14 UTC (permalink / raw)


I am writing an interface to a C library. Some C functions accept either a C 
string pointer or NULL.

I need some way to define an Ada object which could hold values equivalent 
to C strings with possible NULL.

I consider two approaches:

1. Ada.Strings.Unbounded (remind that it can be Null_Unbounded_String which 
is equivalent to NULL C string).

2. Ada.Containers.Indefinite_Holders holding a String.

The first way seems more natural, as a more specialized package is used.

The second way may have the advantage that there is Is_Empty function while 
for unbounded strings I would need to compare with Null_Unbounded_String 
using "=" operator. This may be a little slower. Or does it matter with 
modern compilers?

Hm well, do I understand Null_Unbounded_String correctly? Is 
Null_Unbounded_String really "no string"? or is it just empty string ("")? 
RM2012 should be made more clear on this topic!

-- 
Victor Porton - http://portonvictor.org


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2017-10-03  0:15 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-21 18:14 Ada.Strings.Unbounded vs Ada.Containers.Indefinite_Holders Victor Porton
2017-09-21 21:30 ` AdaMagica
2017-09-22 12:16   ` Victor Porton
2017-09-22 19:25     ` Simon Wright
2017-09-22 22:15       ` Victor Porton
2017-09-23  8:09         ` Dmitry A. Kazakov
2017-09-23  9:16           ` Jeffrey R. Carter
2017-10-03  0:15             ` Randy Brukardt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox