[omniORB] CORBA::Any String access
David Riddoch
djr@orl.co.uk
Wed, 9 Dec 1998 13:55:43 +0000 (GMT)
Jan,
It looks like it will work okay, but please bear in mind that the
MemBufferedStream interface is internal to omniORB, and could change
between versions, be renamed or even be removed altogether.
Changes have already been made for the next release that will cause your
code to break. Fortunately it will not even compile - so it won't just
die silently!
It is also likely that (on systems that support it) our internal
interfaces will be placed in some namespace to reduce the pollution of the
global namespace.
David Riddoch
On Wed, 9 Dec 1998, Jan Lessner wrote:
> 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
>
>