Questions about bool or sal_Bool in Any::setValue, makeAny

Michael Stahl mstahl at redhat.com
Mon Nov 17 13:39:54 PST 2014


On 16.11.2014 19:57, Matteo Casalin wrote:
> Hi all,
>      I was converting all sw call-places to Any::setValue that pass 
> sal_Bool to use bool instead. I wonder if this is a good choice or not, 
> is there any guideline?

it looks like the Any has specific support for C++ bool so it should
work fine.

> Also some of these call places look like:
> 
>      sal_Bool bTrue = sal_True;
>      uno::Any aVal(&bTrue, ::getBooleanCppuType());
>      some_function_call( aVal );
> 
> or
> 
>      uno::Any aAny;
>      sal_Bool bFalse = sal_False;
>      aTmp.setValue(&bFalse, ::getBooleanCppuType()  );
>      some_function_call( aTmp );
> 
> could these be changed to use makeAny(bool)? Does this hold also if the 
> same Any object is used multiple times (each time calling setValue on it)?

it's much better to use a type-safe method like makeAny() or operator<<=
and not the Any::setValue()/getValue() methods that operate on unsafe void*.




More information about the LibreOffice mailing list