[omniORB] sequence<string>::operator[]

Sai-Lai Lo S.Lo@uk.research.att.com
13 Apr 2000 10:59:41 +0100


>>>>> Bruce Visscher writes:

> Sorry to reply to my own post, but I have another question about this.
> Apparently, the operator[] for sequences of strings worked under 2.7.1 on Compaq
> C++ 5.6/OpenVMS VAX.  I am having to work around this for 2.8.0 by using the
> getbuf/freebuf interface (ick).

> Under 2.7.1, sequences of strings were a typedef as CORBA::String_member.  Also,
> the implementation of CORBA::String_member was much simpler (just a pointer, no
> reference, no flag).  What problems or enhancements was the new implementation
> intended to address?

Bruce,

I'll try your test program on other platforms later.

The change in the representation of the sequence of strings (and the sequence of
object references) is to cope with the (moronic) changes in the mapping.
The revised mapping requires the ORB to support the operations sequence::get_buffer()
and its friends and *mandated* that the returned buffer must be 
of type pointer to the element type. In other words, get_buffer() for a
sequence of string has to return char**. Therefore we can no longer use a
sequence of String_member as the internal representation and instead has to
revert to a sequence of char*. (The application can modify any element via
the char** it gets from get_buffer() or via the [] operator. This rules out
the option of "externalising" a sequence only when get_buffer() is called.)

This is all fair enough except that the mapping also requires the sequence
to auto manage the storage for its element, i.e. the [] operator has to do
the right thing for assignment of char* and const char*! The way this is
supported at the moment is for the [] operator to return a temporary
String_member and let it do the right thing in terms of storage management.

Sounds complicated? Won't life be much simpler if one just map CORBA string
to a C++ string!

Sai-Lai


-- 
Sai-Lai Lo                                   S.Lo@uk.research.att.com
AT&T Laboratories Cambridge           WWW:   http://www.uk.research.att.com 
24a Trumpington Street                Tel:   +44 1223 343000
Cambridge CB2 1QA                     Fax:   +44 1223 313542
ENGLAND