From: "Björn Lundin" <b.f.lundin@gmail.com>
Subject: Re: Question on bounded / unbounded strings
Date: Fri, 30 Sep 2016 09:59:22 +0200
Date: 2016-09-30T09:59:22+02:00 [thread overview]
Message-ID: <nsl60g$urn$1@dont-email.me> (raw)
In-Reply-To: <nshbhr$5m0$1@franka.jacob-sparre.dk>
On 2016-09-28 23:09, Randy Brukardt wrote:
> "John Smith" <yoursurrogategod@gmail.com> wrote in message
> news:e60176b6-4c61-474a-a191-b31821816004@googlegroups.com...
> On Saturday, September 24, 2016 at 3:52:54 AM UTC-4, Dmitry A. Kazakov
> wrote:
> ...
>> However, if I ever need string functionality that I'm used to in Python or
>> C++,
>
> Ada doesn't have it (sadly).
>
> I used to tell people to use Unbounded_Strings, but that was before I tried
> to build an application that way. (I discussed that further in a different
> message in this thread). You have to revert to String in many places (which
> is aggrevating [Ada 2005 did eliminate a couple of them, but it doesn't help
> much], one has to look up the names of the operations beyond the most basic,
> and if you are sensible use-adverse person (:-)), the names you have to use
> are nasty (Ada.Strings.Unbounded.To_Unbounded_String ("Foo") -- gack!!!)
>
Recently I needed to process xml files, and do a bit of string
manipulation with the results. I agree that Unbounded_String is clumpsy
(name-wise) and that Ada.Strings.Fixed has useful operations.
I ended up wrapping what I need in a new object - String_Object -
with naming I know will trigger people here :-)
with Ada.Strings; use Ada.Strings;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
package Repository_Types is
type String_Object is tagged private;
procedure Set(Self : in out String_Object; What : String);
procedure Reset(Self : in out String_Object);
function Fix_String( Self : String_Object) return String;
function UBString( Self : String_Object) return Unbounded_String;
function Lower_Case( Self : String_Object) return String;
function Upper_Case( Self : String_Object) return String ;
function Empty_String_Object return String_Object;
procedure Append(Self : in out String_Object; What : String);
function Camel_Case(Self : String_Object) return String ;
procedure Delete_Last_Char(Self : in out String_Object);
function "<"( Left, Right : String_Object) return Boolean;
function "="( Left, Right : String_Object) return Boolean;
function ">"( Left, Right : String_Object) return Boolean;
private
type String_Object is tagged record
Value ,
Camel_Case_Cache,
Lower_Case_Cache,
Upper_Case_Cache: Unbounded_String := Null_Unbounded_String;
end record;
end Repository_Types;
To me, it turned out to be quite useful
--
--
Björn
next prev parent reply other threads:[~2016-09-30 7:59 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-13 8:46 Question on bounded / unbounded strings Arie van Wingerden
2016-09-13 9:04 ` Dmitry A. Kazakov
2016-09-22 2:10 ` John Smith
2016-09-22 7:24 ` Dmitry A. Kazakov
2016-09-22 9:01 ` J-P. Rosen
2016-09-22 9:53 ` Dmitry A. Kazakov
2016-09-22 10:58 ` G.B.
2016-09-22 12:05 ` Dmitry A. Kazakov
2016-09-22 14:14 ` G.B.
2016-09-22 17:18 ` Dmitry A. Kazakov
2016-09-22 11:08 ` J-P. Rosen
2016-09-22 12:05 ` Dmitry A. Kazakov
2016-09-22 13:18 ` Maciej Sobczak
2016-09-22 13:52 ` Dmitry A. Kazakov
2016-09-22 14:51 ` Maciej Sobczak
2016-09-22 17:13 ` Dmitry A. Kazakov
2016-09-23 5:50 ` Maciej Sobczak
2016-09-23 6:36 ` Simon Wright
2016-09-23 7:48 ` Dmitry A. Kazakov
2016-09-28 20:55 ` Randy Brukardt
2016-09-23 23:58 ` John Smith
2016-09-24 7:52 ` Dmitry A. Kazakov
2016-09-24 16:25 ` John Smith
2016-09-24 17:44 ` Dmitry A. Kazakov
2016-09-24 18:33 ` John Smith
2016-09-24 18:37 ` John Smith
2016-09-24 18:59 ` John Smith
2016-09-25 8:50 ` Dmitry A. Kazakov
2016-09-25 23:35 ` brbarkstrom
2016-09-26 7:28 ` Dmitry A. Kazakov
2016-09-26 12:39 ` brbarkstrom
2016-09-28 21:09 ` Randy Brukardt
2016-09-30 7:59 ` Björn Lundin [this message]
2016-09-13 9:35 ` gautier_niouzes
2016-09-13 10:41 ` Alejandro R. Mosteo
2016-09-13 17:41 ` Jeffrey R. Carter
2016-09-13 17:59 ` Björn Lundin
2016-09-14 11:23 ` Arie van Wingerden
2016-09-14 12:26 ` Arie van Wingerden
2016-09-14 12:28 ` Arie van Wingerden
2016-09-14 12:57 ` Arie van Wingerden
2016-09-14 19:39 ` Jeffrey R. Carter
2016-09-17 16:35 ` Arie van Wingerden
2016-09-16 14:43 ` Olivier Henley
2016-09-17 16:35 ` Arie van Wingerden
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox