Hi Stephan,
On Thursday, 2007-05-31 17:49:24 +0200, Stephan Bergmann wrote:
> >>Why -1 instead of 0?
> >
> >I thought of -1 signalling an end condition in reverse iteration, as
> >does 'length' in forward iteration, both point "outside" the string and
> >would follow the general [...[ inclusive/exclusive approach.
>
> But what should
>
> sal_Int32 i = -1;
> s.iterateCodePoints(&i, 1);
>
> mean then? Pseudo-iterate forward to i == 0?
Yes, analogous to reverse-iterating with i=s.getLength(). However, that
case may be a bit pathological.. it also needs to return SAL_MAX_UINT32
again. So, if we preincremented on reverse-iteration like mentioned
below, what would this situation give? The same?
> But you are right, reverse-iterating code does look more awkward. Would
> it help if postIncrementCodePoints actually acted as
> preIncrementCodePoints if it is negative? Is not that what we want?
It is.
> Or is it to confusing?
I don't think so. Well, maybe at the beginning, but it does what we want :-)
it just reverses the entire behavior.
> sal_Int32 i = s.getLength();
> while (i != 0) {
> sal_uInt32 c = s.iterateCodePoints(&i, -1);
> }
>
> would then neatly reverse-iterate through any string, and we would get
> rid of the ugly SAL_MAX_UINT32 special-case return value.
What if 'i' is 0, and maybe 's' also an empty string? This wouldn't
happen in a proper loop, but a call to iterateCodePoints() in these
cases would result in what?
s.iterateCodePoints(&i, +1) => i== 0 ? because getLength()==0
s.iterateCodePoints(&i, 0) => i== 0 ? because not iterating
s.iterateCodePoints(&i, -1) => i==-1 ? because preincremented past the
beginning
And the return value?
Eike
--
OOo/SO Calc core developer. Number formatter stricken i18n transpositionizer.
OpenOffice.org Engineering at Sun: http://blogs.sun.com/GullFOSS
Please don't send personal mail to this [EMAIL PROTECTED] account, which I use
for
mailing lists only and don't read from outside Sun. Thanks.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]