[sword-devel] feature request

Paul Gear sword-devel@crosswire.org
Tue, 13 Mar 2001 21:29:58 +1000

"Troy A. Griffitts" wrote:
> ...
> You may also consider that it might not be a good idea to save some
> settings to the systemwide module config files.  It might be better to
> save, say, a ~/.sword/modoptions.conf file and letting your subclass of
> SWMgr merge the contents of ~/.sword/modoptions.conf into its config
> object:
>     SWConfig localopts("~/.sword/localopts");
>     swmgr->config += localopts;
> The '+=' merge adds everything from localopts into the swmgr's config
> entries (overriding any that were already there).
> ...

A suggestion/request: make it work like java.util.Properties.  The way
they do it is that each Properties object can take another Properties
object as its default.  The above syntax could be used to do this, but
in terms of implementation, it would merely set a pointer to the default
SWConfig object.  Then the implementation of a get() function would look
something like this:

    SWConfig::get( string key )
        string result = hashtable.get( key );
        if (result == NULL) {
          // or whatever the equivalent is for C++ strings
            result = defaults.get( key );
        return result;

The put() operation would not be the same, though - it would just put
into the local hash table (so that user preferences would not be written
to the global preferences).  If the system preferences need to be
changed, just put() into the defaults object and save() that, assuming
permission to do it.

What think y'all?

"He must become greater; i must become less." - John 3:30