replacing OUString::valueOf(static_cast<sal_Int32>) ??

Lubos Lunak l.lunak at suse.cz
Thu Jan 10 05:55:55 PST 2013


On Thursday 10 of January 2013, Noel Grandin wrote:
> On 2013-01-09 19:58, Michael Meeks wrote:
> > At least in my mind :-) but we're starting to bike-shed here... I
> > didn't see anyone volunteering to do the actual batch cleanup there
> > ;-) Regards, Michael.
>
> Created a proof-of-concept patch along with some unit tests and pushed
> to gerrit:
>
> https://gerrit.libreoffice.org/#/c/1625/

 Can we please keep the discussion still here? Gerrit may be fine for pointing 
out technical details in the code, but it's not very suitable for discussions 
about anything beyond that.

- There's no need for valueOfChar(). There is already OUString ctor from 
sal_Unicode, so the valueOf() overload for it is just making an obvious thing 
complicated. Code using it can be converted to use the ctor instead.

- It's a question if we really need 'OUString::valueOfBool( foo )' instead of 
simply 'foo ? OUString( "true" ) : OUString( "false" )' (such a pity the 
string literals handling doesn't allow "foo ? "true" : "false"' ). I wonder 
how many places in the code really need to convert a boolean to the hardcoded 
english string representation.

- When more or less deprecating valueOf() this way, it has also float 
overloads, so something should be created for those too.

- I'm still not sold on the naming, OUString::valueInt() doesn't say much and 
OUString::valueOfInt() feels cryptic. Can we please use something obvious 
that doesn't need decyphering, such as OUString::number() or 
OUString::fromInt() (as much as I still don't like the idea of harcoding the 
irrelevant type information in the name)?

On Thursday 10 of January 2013, Noel Grandin wrote:
> On Wed, Jan 9, 2013 at 7:58 PM, Michael Meeks <michael.meeks at suse.com>wrote:
> >         At least in my mind :-) but we're starting to bike-shed here... I
> >  didn't see anyone volunteering to do the actual batch cleanup there ;-)
>
> Doesn't sound that hard - some regular expression magic will do most of the
> work.

 I expect it won't, regular expressions can't tell what foo is in "valueOf( 
foo )". Unless all you want to convert is only places which do the explicit 
cast, this will need a (fairly simple) Clang plugin.

-- 
 Lubos Lunak
 l.lunak at suse.cz


More information about the LibreOffice mailing list