change bool to enum : KUrl
Frans Englich
englich at kde.org
Tue May 2 15:33:41 BST 2006
On Tuesday 02 May 2006 13:49, David Faure wrote:
> On Tuesday 02 May 2006 00:44, Olivier Goffart wrote:
> > + enum CleanPathOption
> > + {
> > + /**
> > + * if set, occurences of consecutive directory separators
> > + * (e.g. /foo//bar) are cleaned up as well. (set by default)
> > + */
> > + CleanDirSeparator = 0x01,
> > +
> > + /**
> > + * The opposite of CleanDirSeparator.
> > + */
> > + LeaveDirSeparator = 0x00
> > + };
> > +
> > + Q_DECLARE_FLAGS(CleanPathOptions,CleanPathOption)
>
> This one is not really a "flag" (as in "one or the other or both"), is it?
> It seems to be a standard enum instead; except that the type safety that
> QFlag gives is nice, of course. Does Qt provide a way to declare a
> "typesafe enum"?
To me that is a QFlags instantiation, but without the
Q_DECLARE_OPERATORS_FOR_FLAGS. Not perfect, but the best on can get, as I see
it.
However, QFlags doesn't prevent you from or'ing or and'ing an enum whose
values aren't tailored for it, but otoh neither does a regular enum.
In some cases it have appeared as if people add Q_DECLARE_OPERATORS_FOR_FLAGS
out of habit, as if every enum should have it. But of course, that's not the
case.
Cheers,
Frans
More information about the kde-core-devel
mailing list