[xsd-users] Getting at the autopointers

Boris Kolpackov boris at codesynthesis.com
Wed Nov 16 08:43:47 EST 2005


James,

James Boyden <jboyden at geosci.usyd.edu.au> writes:

> I admit I haven't yet looked too closely at the XML schema polymorphism
> features used to handle things like substitution groups, but if there's
> C++ polymorphism involved, wouldn't
>
> 	auto_ptr<Foo> f (new Foo (b.foo ())); // Make a copy.
>
> be better expressed as something like
>
> 	auto_ptr<Foo> f (b.foo ().clone ()); // Make a clone.
>
> using the "virtual constructor" idiom [1]?

You are absolutely right. Nice catch, James!


> (I note that in the file "schema.hxx" generated by xsd for the
> "cxx/tree/polymorphism" example, the classes 'person_type',
> 'superman_type', 'batman_type' and 'instance_type' all have a function
> '_clone', but this function is clearly intended for internal use only,

No, _clone() is not for internal use only. The underscore in the
name is there to avoid conflicts with attribute/element names (this
is similar to CORBA IDL-to-C++ mapping's _narrow(), etc.). We refer
to such functions as "service functions".


> plus it takes two arguments which I don't understand, so I'm going to
> assume that it's not the solution to this problem.)

Here you are correct, those arguments are for internal use ;-). They
should have been default-initialized to 0, similar to copy c-tors.
We will fix this in 1.7.0.


thanks,
-boris
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 652 bytes
Desc: Digital signature
Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20051116/30af9be4/attachment.pgp


More information about the xsd-users mailing list