Use of const arg in KConfigGroup constructors doesn't work with language bindings
Richard Dale
rdale at foton.es
Wed Mar 5 12:50:31 GMT 2008
On Wednesday 05 March 2008 12:36:27 Lubos Lunak wrote:
> > In the KConfigGroup a boolean bConst, is set in the constructor, and that
> > is used afterwards to test whether the instance is read-only or not. It
> > doesn't matter if you declare it 'const KConfigGroup * item' or
> > 'KConfigGroup * item' - there is no use made of compile time checking.
>
> You're mixing two things here. If KConfigGroup takes a const KConfigBase,
> then that KConfigBase is not to be modified, simple as that. And it works
> two ways, KConfigGroup taking const argument says that it won't be
> modified, and somebody passing const KConfigBase says that it is not to be
> modified. The compiler will do special handling to detect and enforce that
> and the fact that KConfigGroup has a special flag for that is just an
> implementation detail. KConfigGroup being read-only when it gets a const
> KConfigBase is just a logical consequence of it not being possible to be
> read-write when the data it operates on is const. I don't think anybody
> would expect QFile to be read-only or read-write depending on whether the
> QString with the filename is const or not.
But the KConfigBase 'master' arg passed to the KConfigGroup constructor isn't
modified in either the const or non-const cases. The only effect it is has to
set the internal bConst boolean in the new KConfigGroup instance. I don't
understand the need for all these booleans and enums:
In KConfigBase:
enum WriteConfigFlag
{
Persistent = 0x01,
Global = 0x02,
Localized = 0x04,
Normal=Persistent
};
enum AccessMode { NoAccess, ReadOnly, ReadWrite };
In KConfig:
enum OpenFlag {
IncludeGlobals = 0x01,
CascadeConfig = 0x02,.
SimpleConfig = 0x00,
NoCascade = IncludeGlobals,
NoGlobals = CascadeConfig,
FullConfig = IncludeGlobals|CascadeConfig
};
In KConfigGroup:
const bool bImmutable:1;
const bool bConst:1;
Can something be both KConfig.AccessMode.ReadOnly and
KConfig.WriteConfigFlag.Persistent ? I don't know.
What if a KConfig passed to the KConfigGroup constructor as a 'master' arg is
const, but has an AccessType of ReadWrite? What is the difference between
immutable, const, and not persistent? Search me..
-- Richard
More information about the kde-core-devel
mailing list