I have implemented a structure for containing configuration data using the stl::map back end. I have implemented the [] operator as:
string& config:operator[] ( const string theKey )
{
ParamMapIter iter;
iter = _configMap.find ( theKey );
if ( iter == _configMap.end() )
{
_configMap[theKey] = ""; // Create a new blank key/value when missing key
}
return _configMap[theKey];
}
so I can do things like
Conf["key"] = "value";
Now I'd like to make this semi-two dimensional to match old style Windows config files with separate sections. e.g. so I can write
Conf["section"] ["key"] = "value";
Any suggestions on how to implement this efficiently?
I guess the real question is how to implement the double subscript. The underlying implementation would take care of the actual detail - though suggestions on that also appreciated.