comp.lang.ada
 help / color / mirror / Atom feed
* Ada Strings Libraries for the clueless.
@ 2002-11-05 21:40 Caffeine Junky
  2002-11-05 22:07 ` Mark Biggar
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Caffeine Junky @ 2002-11-05 21:40 UTC (permalink / raw)


Recently I've actually taken the time to peruse the Ada.Strings section
of the Ada LRM. Lot's of nifty functions there, although I'm somewhat
fuzzy on what exactly they do. Probably because I havent bothered to play
with Strings at all until recently. Example..

Ada.Strings.Fixed

	function Index (Source : in String; Pattern : in String;
				 Going : in Direction := Forward;
				 Mapping : in Maps.Character_Mapping := Maps.Identity)
	return Natural;


Now, the gist of this function is pretty clear. It looks at a String and
returns the number of how many Characters are in the string(I'm
assuming.) But what's this "Pattern" string I'm supposed to pass to it? 
Does it only count the characters in the String that match the Pattern given
in the Pattern variable?

Now, to be fair, %95 of this section of the LRM is self-explanatory and
pretty simple to understand. I'm just running into a few things here and
there that are somewhat ambiguous. Or maybe I'm just dim-witted or low on
Caffiene at the moment.

Note: I'm focusing on the Strings libraries at the moment cause I'm
teaching myself to write very stable and fast buffers/pipes specifically
for text. "But Junky, why not make them generic buffers for everything?"
Because that's not what I'm doing right now. Heh.

I dont really need a tutorial on this, just a quick run down on what
these functions are really asking for.

Any pointers would be appreciated.

Caffiene Junky
Caffinated Corps.



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

* Re: Ada Strings Libraries for the clueless.
  2002-11-05 21:40 Ada Strings Libraries for the clueless Caffeine Junky
@ 2002-11-05 22:07 ` Mark Biggar
  2002-11-05 22:17 ` Simon Wright
  2002-11-06  0:41 ` Jeffrey Creem
  2 siblings, 0 replies; 4+ messages in thread
From: Mark Biggar @ 2002-11-05 22:07 UTC (permalink / raw)


Caffeine Junky wrote:
> Recently I've actually taken the time to peruse the Ada.Strings section
> of the Ada LRM. Lot's of nifty functions there, although I'm somewhat
> fuzzy on what exactly they do. Probably because I havent bothered to play
> with Strings at all until recently. Example..
> 
> Ada.Strings.Fixed
> 
> 	function Index (Source : in String; Pattern : in String;
> 				 Going : in Direction := Forward;
> 				 Mapping : in Maps.Character_Mapping := Maps.Identity)
> 	return Natural;
> 
> 
> Now, the gist of this function is pretty clear. It looks at a String and
> returns the number of how many Characters are in the string(I'm
> assuming.) But what's this "Pattern" string I'm supposed to pass to it? 
> Does it only count the characters in the String that match the Pattern given
> in the Pattern variable?

No, it searchs the string Source for the leftmost occurence of a
substring that is equal to Pattern and returns the index of the
start of that substring.

-- 
Mark Biggar
mark.a.biggar@attbi.com




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

* Re: Ada Strings Libraries for the clueless.
  2002-11-05 21:40 Ada Strings Libraries for the clueless Caffeine Junky
  2002-11-05 22:07 ` Mark Biggar
@ 2002-11-05 22:17 ` Simon Wright
  2002-11-06  0:41 ` Jeffrey Creem
  2 siblings, 0 replies; 4+ messages in thread
From: Simon Wright @ 2002-11-05 22:17 UTC (permalink / raw)


Caffeine Junky <nospam@hotmail.com> writes:

> Ada.Strings.Fixed
> 
> 	function Index (Source : in String; Pattern : in String;
> 				 Going : in Direction := Forward;
> 				 Mapping : in Maps.Character_Mapping := Maps.Identity)
> 	return Natural;
> 
> 
> Now, the gist of this function is pretty clear. It looks at a String
> and returns the number of how many Characters are in the string(I'm
> assuming.) But what's this "Pattern" string I'm supposed to pass to
> it?  Does it only count the characters in the String that match the
> Pattern given in the Pattern variable?

If you read on to (58) you find

    Each Index function searches for a slice of Source, with length
    Pattern'Length, that matches Pattern with respect to Mapping; the
    parameter Going indicates the direction of the lookup. If Going =
    Forward, then Index returns the smallest index I such that the
    slice of Source starting at I matches Pattern. If Going =
    Backward, then Index returns the largest index I such that the
    slice of Source starting at I matches Pattern. If there is no such
    slice, then 0 is returned. If Pattern is the null string then
    Pattern_Error is propagated.

which seems pretty clear :-)   (except perhaps the Mapping part)



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

* Re: Ada Strings Libraries for the clueless.
  2002-11-05 21:40 Ada Strings Libraries for the clueless Caffeine Junky
  2002-11-05 22:07 ` Mark Biggar
  2002-11-05 22:17 ` Simon Wright
@ 2002-11-06  0:41 ` Jeffrey Creem
  2 siblings, 0 replies; 4+ messages in thread
From: Jeffrey Creem @ 2002-11-06  0:41 UTC (permalink / raw)



"Caffeine Junky" <nospam@hotmail.com> wrote in message
news:eVWx9.26421$Lu1.39570@sccrnsc01...


stuff deleted

> Ada.Strings.Fixed
>
> function Index (Source : in String; Pattern : in String;
> Going : in Direction := Forward;
> Mapping : in Maps.Character_Mapping := Maps.Identity)
> return Natural;
>
>
> Now, the gist of this function is pretty clear. It looks at a String and
> returns the number of how many Characters are in the string(I'm
> assuming.) But what's this "Pattern" string I'm supposed to pass to it?


Number of characters in the string is just the 'length of the string.
(Others have explained what this function actually does so I won't repeat
it)





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

end of thread, other threads:[~2002-11-06  0:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-05 21:40 Ada Strings Libraries for the clueless Caffeine Junky
2002-11-05 22:07 ` Mark Biggar
2002-11-05 22:17 ` Simon Wright
2002-11-06  0:41 ` Jeffrey Creem

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