[omniORB] CORBA::Any String access
Jan Lessner
jan@c-lab.de
Wed, 09 Dec 1998 13:31:27 +0100
Hi Omnis,
I just started using omniORB's Any implementation in our software. In
case an Any holds a string value, I found out that the access function
operator>>=(char *&) makes a copy of the Any's value. For a more
efficient access to huge string values, I added a (non-standard!) member
function as follows, which just returns the Any's string value without
copying it:
const char *
CORBA::Any::strvalue() const {
MemBufferedStream tmp_mbuf(pd_mbuf,1);
CORBA::ULong _len;
_len <<= tmp_mbuf;
if (tmp_mbuf.overrun(_len)) throw
CORBA::MARSHAL(0,CORBA::COMPLETED_NO);
return (char *)tmp_mbuf.align_and_get_bytes(omni::ALIGN_1,_len);
}
It works, but to be honest, I'm not sure if this is reliable for all
systems and interoperability. As far as I know things like character
representation and alignment I think it should, but I'd be glad if any
of the experts could have a look on that.
Cheers,
Jan Lessner, C-LAB