[Libreoffice] [PATCH] Add support for bool for the operator << and >> of SvStream
Norbert Thiebaud
nthiebaud at gmail.com
Mon Oct 4 10:46:45 PDT 2010
On 10/4/10, Noel Power <nopower at novell.com> wrote:
> On Mon, 2010-10-04 at 09:59 -0500, Norbert Thiebaud wrote:
>> On 10/4/10, Noel Power <nopower at novell.com> wrote:
>> > Hi Norbet
>> > On Sat, 2010-10-02 at 21:18 -0500, Norbert Thiebaud wrote:
>> >> [PATCH] Add support for bool for the operator << and >> of SvStream
>> >>
>> > I just wonder did you have a specific reason for this patch. I would
>> > assume if someone would be reading or writing a boolean value to a
>> > binary stream they probably would be packing it some how in the
>> > structure they are writing. E.g. normally in the binary filters ( where
>> > SvStream is used ) boolean values are usually read & written ( packed )
>> > into some sort of bit field in 16 or 32 bit words. Caolan what do you
>> > think?
>>
>> Today these 'boolean' value are typed as sal_Bool or BOOL, both of
>> them are unsigned char.
>>
>> This patch is to prepare the code so that I can as some time do a switch
>> from
>>
>> typedef sal_Bool BOOL
>> to
>> typedef bool BOOL
>
> I guess I don't see what this is to do with adding those >>, <<
> operators to one of the binary stream classes, there was no SvStream&
> 'operator >>( BOOL )' or SvStream& operator << (BOOL&)' unless you found
> code that does does read and write 'BOOL' types to the streams ? Have
> you?
Bingo.
and there is indeed no <<(BOOL&) , but there is a <<(unsigned char&)
and since BOOL is sal_Bool which is unsigned char you end up with code like
BOOL bFOO;
BOOL bBAR;
m_stream << bFOO << bBar;
which blow-up when I changed the typedef of BOOL to bool.
Norbert Thiebaud
>
> thanks,
> Noel
>
>
More information about the LibreOffice
mailing list