I just started using xParam for my parameter handling.
I would like to use a std::map that uses a custom traits so that the string key comparisons
are case-insensitive. When I register the map thus,
param_map<std::string, ProductInfo, ciStringLess >();
// ProductInfo is my concrete class
// ciStringLess is my case-insensitive traits class
the compiler fails because param_map has too many template arguments.
I have a working version based on the default traits, ie
param_map<std::string, ProductInfo >();
works.
How do I register a map with a specific traits class correctly?
Thanks,
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Sorry for the long time it took to answer - Michael and I somehow missed your message.
Happily enough, another user drew this to our attention and I've just added support for this feature today.
The feature will be part of the next release, but if you want, you can get it from the CVS head on sourceforge. The relevant changes are in the file xpv_reg_map.h (and xpv_reg_set.h for same feature in std::set). Note that the CVS image shown by webCVS is always a bit old, so at the time of writing this message it didn't show the latest version - make sure you get version 1.10 of xpv_reg_map.h.
now the call
param_map<std::string, ProductInfo, ciStringLess >();
will behave as you expect. You must also register the class ciStringLess, since it's name is used to build the XParam name of the resulting map class. For example:
PARAM_CLASS(ciStringLess)
My apologies again for the long time it took to respond. I hope this helps.
Ronnie
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
compiler : vc7
os : Win2K
xparam : 1.22
I just started using xParam for my parameter handling.
I would like to use a std::map that uses a custom traits so that the string key comparisons
are case-insensitive. When I register the map thus,
param_map<std::string, ProductInfo, ciStringLess >();
// ProductInfo is my concrete class
// ciStringLess is my case-insensitive traits class
the compiler fails because param_map has too many template arguments.
I have a working version based on the default traits, ie
param_map<std::string, ProductInfo >();
works.
How do I register a map with a specific traits class correctly?
Thanks,
Sorry for the long time it took to answer - Michael and I somehow missed your message.
Happily enough, another user drew this to our attention and I've just added support for this feature today.
The feature will be part of the next release, but if you want, you can get it from the CVS head on sourceforge. The relevant changes are in the file xpv_reg_map.h (and xpv_reg_set.h for same feature in std::set). Note that the CVS image shown by webCVS is always a bit old, so at the time of writing this message it didn't show the latest version - make sure you get version 1.10 of xpv_reg_map.h.
now the call
param_map<std::string, ProductInfo, ciStringLess >();
will behave as you expect. You must also register the class ciStringLess, since it's name is used to build the XParam name of the resulting map class. For example:
PARAM_CLASS(ciStringLess)
My apologies again for the long time it took to respond. I hope this helps.
Ronnie