[Libreoffice] Easy Hack String replacement: SearchAndReplace
Caolán McNamara
caolanm at redhat.com
Mon Sep 26 05:15:38 PDT 2011
On Mon, 2011-09-26 at 09:43 +0200, Stephan Bergmann wrote:
> On 09/26/2011 01:30 AM, Neil Leathers wrote: > I was looking into the
> Easy Hacks: "Removal/Replacement of the String/UniString/ByteString
> with OUString/OString once and for all" and ran into needing to
> translate a SearchAndReplaceAscii. Before launching into this set I
> wanted to confirm that instead of moving the SearchAndReplace
> functions to OUString and OString they should be moved to
> OUStringBuffer and OStringBuffer?
>
> It would probably be better placed at OUString (where it returns a
> new OUString instance, leaving the original intact) than at
> OUStringBuffer (where it modifies this instance).
See if comphelper::string::replace fits your needs, i.e. include
comphelper/string.hxx, it takes string to operate on, search string,
replace string and returns a new string. Where string is an OUString or
OString.
comphelper/qa/string/test_string.cxx is the unit test for it, i.e.
TestString::testReplace if anyone wants to put any potential gotchas
through it.
C.
More information about the LibreOffice
mailing list