[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    macro for enum operations
From:       Simon Hausmann <hausmann () kde ! org>
Date:       2003-09-10 10:32:05
[Download RAW message or body]

Hi,

seeing that KFileDialog::setMode( KFile::Mode ) is deprecated in favour of
KFileDialog::setMode( int ) makes me wonder about adding a a macro to
kdecore/kdemacros.h that does that nifty trick of defining operations for
combining enum values to get a nicer API but keep type safety (like we've see
in the Qt4 presentation in n7y) :

#define K_DEFINE_ENUM_OPERATIONS( EnumType ) \
    inline EnumType operator^( EnumType first, EnumType second ) \
    { return EnumType( int( first ) ^ int( second ) ); } \
    inline EnumType operator&( EnumType first, EnumType second ) \
    { return EnumType( int( first ) ^ int( second ) ); } \
    inline EnumType operator|( EnumType first, EnumType second ) \
    { return EnumType( int( first ) ^ int( second ) ); }


Then we could mark the KFileDialog::setMode( int ) method deprecated :)

Thoughts/Opinions?

Simon
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic