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

List:       kde-core-devel
Subject:    Re: RFC: KConfig changes for 3.0
From:       "Aaron J. Seigo" <aseigo () mountlinux ! com>
Date:       2001-07-25 19:41:28
[Download RAW message or body]

hi..

> (*(*config)["Some Group Name])["Some Key"];

no, because operator[] returns a reference, not a pointer.

> And frequently, you need the default value for readEntry, which can't be
> done with the operator[]  Unless you want a KConfigEntryMoniker object with
> a operator QString() member.  (Am I going too far?)

sure it can be done:

   config["Some Group Name"]["Some Key", "Default Value"];

the question is whether it is pretty or not =)

i've used this style in other projects before with great success, using both 
exceptions-based and "return a dummy object if it fails on find" approaches  
(depending on the specific situation). and as you can see, you can even get 
fancy and allow multiple terms in each [..] to allow key/value matching or 
key/default for return on failure.

i think it comes down to whether or not it offers anything over the current 
approach, and given that KConfig is just group/key/value i don't think it 
does, besides make the code look a little more ugly when a KConfig* is used 
as David pointed out. besides, consistency is nice so there should be one and 
only one way of getting to the config data, and if KDE moved to using 
operator[] then there would be a whole lotta porting going on just to change 
the cosmetics.

0.02

-- 
Aaron Seigo

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

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