[bt-devel] Hierarchial Config Structures

David White bt-devel@crosswire.org
17 Sep 2002 19:58:29 +1000


Joachim,

Unfortunately I managed to lose the original email you wrote on this,
but I wanted to respond anyway.

If you want to hard-code hierarchical configuration information in C++,
the best way is using namespaces. namespaces are in C++ specifically to
allow you to organize things nicely into hierarchies.

For instance:

namespace config
{

namespace mainMenu
{

namespace fileMenu
{

const QString tooltip = "blah blah";

}

const QString tooltip = "blah";

}

}

}

etc

and then you can access things using

config::mainMenu::fileMenu::tooltip and config::mainMenu::tooltip and so
on.

As someone else suggested, you may want to consider putting everything
in a configuration file instead. You could even reuse the SWConfig code
to do that.

Let me know if that all makes sense :)

-David.