Hi all,
As has recently been discussed on #libreoffice-dev, its probably a good
idea to remove the rather unhelpful conversion operators
rtl::OString::operator sal_Char const * ()
rtl::OStringBuffer::operator sal_Char const * ()
rtl::OUString::operator sal_Unicode const * ()
rtl::OUStringBuffer::operator sal_Unicode const * ()
(The reason why this came up on IRC this time was that the expression
"aStr = aStr + cSep" with aStr of type rtl::OString and cSep of type
sal_Char had a rather non-intuitive meaning, implicitly converting aStr
into a sal_Char const *, adding the integral value of cSep to that
pointer, and then converting that modified sal_Char const * back into an
rtl::OString via the rtl::OString(sal_Char const *) constructor.)
The change will be source-code incompatible, but that is probably
acceptable:
- The change is ABI compatible (involving only inline C++ functions).
- The ~only legitimate use case for those conversion operators was in
indexing expressions like aStr[n]. To continue those expressions to
work, appropriate operator [](sal_Int) member functions will be added to
the four classes.
- All other uses of the conversion operators should use the getStr()
member functions. (Also note that there might be cases where translation
between, say, rtl::OString and char const * via naive application of
rtl::OString::getStr() is not appropriate as it potentially looses
information, when the given rtl::OString instance contains NUL
characters. Having the calls to getStr explicitly in the code helps
auditing in this case.)
My plan is as follows:
- I just pushed
<http://cgit.freedesktop.org/libreoffice/core/commit/?id=6671fa81db0ecea4ada005bb79f55f08fb440ad4>
"Removed uses of rtl::O[U]String[Buffer]::operator sal_{char|Unicode}
const *()." and
<http://cgit.freedesktop.org/libreoffice/binfilter/commit/?id=34c2ec87db4b6962ded661157056c58163e39821>
"Removed uses of rtl::O[U]String[Buffer]::operator sal_{char|Unicode}
const *()." That clears the current master of all dubious (i.e., non-[])
uses of the conversion operators for a Linux x86_64 --enable-binfilter
--enable-dbgutil "make check" build.
- A few more builds (e.g., Windows, Mac OS X) should be done with the
below patch to ensure that as many dubious uses in
platform-/configuration-switch-specific code as possible have been
fixed. If someone wants to give me a hand here, that would be great.
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.