souchaud wrote:
I am using mico 2.3.12, and I have got a problem with extracting an object from an Any, the problem occurs if the structure of the object contains a string. If I do the same exemple with a long inside the structure instead of a string, it works. If I use omniORB, there is no problem, the object can be extracted.

Here is the source code that explain the problem :


echo.idl:

struct MyStruct {
  string data;
};

interface Echo {
  any test();
};


server.cc:

CORBA::Any * Echo_impl::test()
{
  CORBA::Any * any = new CORBA::Any();
  MyStruct * s = new MyStruct();
s->data = "hep"; // I don't know if it need to use "CORBA::string_dup", anyway it does not work with it as well.
  *any <<= s;
  return any;
}


client.cc:

  ...
  CORBA::Any * any = echo->test();
  const MyStruct * seq;
  bool ok = (*any) >>= seq; // <----- ok == false
  ...


Thanks for your help,

  Mathieu Souchaud
_______________________________________________
Mico-devel mailing list
Mico-devel@mico.org
http://www.mico.org/mailman/listinfo/mico-devel


Hello,

I have seen the MICO exemple in the directory mico2.3.12/test/idl/14/ that is 
quite similar to my code;
So, I have changed a little bit my source code and it's work :

client.cc:
---------
  ...
  CORBA::Any * any = echo->test();
  MyStruct seq; // instead of : const MyStruct * seq;
  bool ok = (*any) >>= seq; // <----- ok == true
  ...

But the problem remains still, because I would like that my program can use 
MICO or OmniORB without putting #ifdef everywhere..
Furthermore, I suppose the first solution (const MyStruct * seq) is better 
cause it should avoid a copy.

I took a look at the echo.hh file generated from the echo.idl. Why there are differences between MICO and OmniORB? CORBA do not propose a standard interface for the idl to c++ mapping?

echo.hh (MICO):
--------------
CORBA::Boolean operator>>=( const CORBA::Any &_a, ::MyStruct &_s );
CORBA::Boolean operator>>=( const CORBA::Any &_a, const ::MyStruct *&_s );

echo.hh (OmniORB):
-----------------
CORBA::Boolean operator>>=(const CORBA::Any& _a, MyStruct*& _sp);
CORBA::Boolean operator>>=(const CORBA::Any& _a, const MyStruct*& _sp);

Sorry for my poor english..

Thanks in advance for your help,
  Mathieu Souchaud

_______________________________________________
Mico-devel mailing list
Mico-devel@mico.org
http://www.mico.org/mailman/listinfo/mico-devel

Reply via email to