Menu

How to register std::map with trait class?

Help
2003-09-12
2004-01-27
  • Tan Kwee Heong

    Tan Kwee Heong - 2003-09-12

    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,

     
    • Ronnie Maor

      Ronnie Maor - 2004-01-27

      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

       

Log in to post a comment.

MongoDB Logo MongoDB