[Ace-users] Re: [ciao-users] (no subject)

Gan Deng gan.deng at vanderbilt.edu
Thu Sep 20 15:26:57 CDT 2007


Hi Santos,

> I have a Hash Map declared as:
> 
> struct Info {
>        string id;
>        string type;
> };
> 
> typedef ACE_Hash_Map_Manager_Ex<ACE_CString,
>                                     Info,
>                                     ACE_Hash<ACE_CString>,
>                                     ACE_Equal_To<ACE_CString>,
>                                     ACE_Null_Mutex> InfoMap; ///
> Connections information
> InfoMap map;
> 
> How can I inform a std::string as parameter of the find method? I have
> an function that returns a value of std::string and I need to use this
> value to find an record in the Hash Map but the find method doesn't
> accept as parameter a std::string.

You can use the c_str() method of the std::string, which returns const 
char *, and use it to construct a ACE_CString object, then pass it into 
the find method of ACE_Hash_Map_Manager_Ex.

ACE_CString foo = bar.c_str();

take care,
Gan



More information about the Ace-users mailing list