List Info

Thread: Re: rtl::OUString searchAndReplace




Re: rtl::OUString searchAndReplace
user name
2007-10-01 11:38:12
Hi Frank, Stephan

> Hi Bjoern,
> 
>> BTW, replacing strings in resources usually means
using the tools String 
>> rather than OUString, anyway.
> 
> http://api.openoffice.o
rg/docs/common/ref/com/sun/star/resource/OfficeResourceLoade
r.html
> 
> Welcome to the modern world ;)

Nice to have this, however I never used it, and still I have
similar 
code to yours just using the tools string rather than
OUString. (Can the 
OfficeResourceLoader using UNO API be used to fill an
SfxTabDialog? And 
if so, how?)


If OUString::replaceString is const (as suggested), there is
no real 
difference in usage compared to an external function (only
difference 
would be passing the string in question as parameter, right?
Or did I 
miss something?). I would vote for using an external
function.

I second Stephan's concerns, that creating a new method at
OUString and 
later changing it is not a good idea. Having a separate
function is the 
better approach, because this way you can make clear that
the function 
is only for resource-string replacement. (You won't want to
add a method 
to OUString called replaceResourceStringVariable or the
like).

I suppose we are not the only people in the world wanting to
replace a 
string in another string. If we want a well-designed
full-featured 
facility to robustly replace strings in any situation, I
reckon we could 
evaluate using some existing library. Of course the library
would have 
to be flexible enough to adapt it to our somewhat
proprietary string 
implementations. But I think such a solution might be worth
giving a try.

So: either make a simple feasible solution like "just
replace a string", 
or use an existing library that has already fixed "all
the" bugs that 
might appear when creating a flexible fail-safe token-based
replacement 
tool, and write a wrapper around it to offer the same simple
usage than 
with the other solution.

(Because we want to replace repeated multiple lines of code
by simple 
one-line code and not make it more fail-safe and add more
lines).

-Bjoern

------------------------------------------------------------
---------
To unsubscribe, e-mail: interface-discuss-unsubscribeopenoffice.org
For additional commands, e-mail: interface-discuss-helpopenoffice.org


[1]

about | contact  Other archives ( Real Estate discussion Medical topics )