[xsde-users] XSDE Generates Different Base Class Return Value from post() after minor reductions to XSD schema file under Eclipse Linux 64-bit

Boris Kolpackov boris at codesynthesis.com
Tue Mar 16 09:32:46 EDT 2010


Hi Bob,

Bob.Oneil at l-3com.com <Bob.Oneil at l-3com.com> writes:

> I have a somewhat unexpected result from the xsde compiler that occurred
> after I modified an original version of an xsd file to simply remove
> some content.   
> 
> The return value from the template to the post() method in the parser
> implementation template (net_mdl-pimpl.hxx) has changed from a pointer
> to the C++ mapped collection 
> 
> (as ::Settings* post())  to  simply the object itself (as ::Settings).
> 
> It was my understanding that the parser dynamically allocated the mapped
> C++ class returned 

The C++/Hybrid mapping divides all generated classes into fixed-length 
and variable-length. Fixed-length types are basically types that don't
contain members that would require dynamic memory allocation in order 
to copy. For example, a type containing two elements of type int with
minOccrus == maxOccrus == 1 would be fixed-length. On the other hand,
a type containing an element of type int with maxOccrus == 'unbounded'
would be variable-length since it will require dynamically-allocated
memory to store the sequence data.

For efficiency, fixed-length types are stored and passed by value.
Variable-length types are stored and passed as pointers to dynamically-
allocated instances. For more information on this, see Section 4.2,
"Memory Management", in the C++/Hybrid Mapping Getting Started Guide:

http://www.codesynthesis.com/projects/xsde/documentation/cxx/hybrid/guide/#4.2

So in your case you probably removed some "variable-length" content
from your schema which made the Settings type fixed-length. If you
want the old behavior (i.e., dynamic allocation), then you can do:

Settings* s = new Settings (p.post());

Boris



More information about the xsde-users mailing list