Re: [orbitcpp-list] Strings and sequences
Status: Beta
Brought to you by:
philipd
|
From: Andreas K. <ak...@ix...> - 2000-04-19 07:10:13
|
On Tue, Apr 18, 2000 at 05:34:47PM +0000, Phil Dawes wrote: > CORBA 2.3 requires that strings in structs and sequences be > initialised to "". This is solved for structs by using the String_mgr > class, whose constructor allocates an empty string. However, > sequences present problems for the current implementation because we > use the ORBit C alloc functions for allocating sequences, and there is > no such 'empty string' requirement in the latest C spec. I do not yet have the 2.3 spec. Arrays have no such requirement, right? Whereas every other aggregate (e.g., union, exception) falls under the struct'n'sequence rule? In that case, arrays is the special case and I think we'd like to name the new _mgr types you mention below like _mgr and _arraymgr. > Candidate solution: > > We redefine operator new[] each time we create a sequence, which > invokes the underlying C allocation function. We then use the operator > new[] in allocbuf() instead of calling the C allocation function > direct. This should insure that the String_mgr constructor gets called > appropriately. why not use the c allocation func in _allocbuf and do a placement new afterwards? > Note that this approach must be used with any variable length type > containing a string. e.g.: I can already see a needsConstructorInAggregates() method materialize in front of my eyes :[ > Any comments, suggestions? Andreas - you're doing arrays; can you > forsee any problems with this approach? On first sight, no. But wait till I sleep over it :) cya andy |