[xsd-users] Question on XSD generated code
Boris Kolpackov
boris at codesynthesis.com
Fri Feb 6 15:14:21 EST 2009
Hi,
Homer J S <js.homer at yahoo.com> writes:
> I could set the attr uom for an object by
>
> myObject.uom("aString");
>
> but I could not find a way to set the float value for an object
> without wiping out the existing uom attr of the object, e.g.,
>
> myObject = 3.1416; //this will wipe the current value of uom attr
What happens is the double value gets implicitly converted to the
depth object using the depth(const ::xml_schema::double_&) c-tor
and that is assigned to myObject. This is actually quite counter-
intuitive and we will try to fix this for the next release.
Meantime, you can do something like this:
double& d = myObject;
d = 3.1416;
Or:
static_cast<double&> (myObject) = 3.1416;
Both are unfortunately quite ugly.
Also, if you are customizing depth then you can either make that c-tor
explicit or add operator=(double). Then the original assignment should
work as expected. We will most likely use the latter approach in the
next release.
Boris
More information about the xsd-users
mailing list