[omniORB] about STL used in omniORB (sorry for last same subject email)

zhang ji zsfunl@yahoo.com
Fri Aug 23 21:28:01 2002


Hi Bruce,

Thanks for your help. To change the "const char*" to
"std::string" really corrects the problem. 

I test the example before in one single thread program
(non omniORB environment) and it works ok. But in
omniORB multithread environment to use std::stirng is
needed.

Thanks,
Shifeng
--- "Visscher, Bruce" <VISSCHB@RJRT.com> wrote:
> > This question may be not suitble here(sorry for
> > that),but I am confused on the results.
> 
> Yes, it is somewhat off topic.
> 
> > I use std::map in one omniORB servlet: below is
> its
> > definition in .h file:
> > "
> >   struct eqstr
> >     {
> >         bool operator()(const char* s1, const
> char* 
> > s2) const
> >         {
> >                 return strcmp(s1, s2) == 0;
> >         }
> >     };
> > 
> >     //Rule is one struct defined in IDL file
> >     typedef map<const char*, Rule, eqstr >
> Rules_Map;
> >     Rules_Map rule_map;
> 
> The third template argument of map should provide an
> ordering relation. You have supplied an equivalence
> relation.  This will not work.
> 
> I would recommend using std::string rather than
> pointer
> to const char.  That way you can use the default
> (std::less)
> for the comparitor.  You also won't have to worry
> about
> allocation issues.  You may need to convert between
> std::string and CORBA::String_var (to make it more
> on topic)
> and/or pointer to char but I think it would be well
> worth it.
> 
> Technically, you could rename eqstr to ltstr and
> "return strcmp(s1, s2) < 0;" but you would be left
> with the
> allocation issues which I think could get tricky in
> a multithreaded environment.
> 
> HTH,
> 
> Bruce
> > CONFIDENTIALITY NOTE:  This e-mail message,
> including any attachment(s), contains information
> that may be confidential, protected by the
> attorney-client or other legal privileges, and/or
> proprietary non-public information.  If you are not
> an intended recipient of this message or an
> authorized assistant to an intended recipient,
> please notify the sender by replying to this message
> and then delete it from your system.  Use,
> dissemination, distribution, or reproduction of this
> message and/or any of its attachments (if any) by
> unintended recipients is not authorized and may be
> unlawful.
> 
> 


__________________________________________________
Do You Yahoo!?
Yahoo! Finance - Get real-time stock quotes
http://finance.yahoo.com