[xsd-users] Assignment of optional boolean attribute does not
survive on the heap; possibly a bug?
Boris Kolpackov
boris at codesynthesis.com
Wed Jun 26 08:07:05 EDT 2013
Hi Andreas,
Andreas.Hackeloeer at bmw.de <Andreas.Hackeloeer at bmw.de> writes:
> <xs:attribute name="SelectedSourceMap" type="xs:boolean" use="optional" />
>
> [...]
>
> myMap.selectedSourceMap(true);
> bool problem = myMap.selectedSourceMap();
Because SelectedSourceMap is optional, what you get from selectedSourceMap()
is not the value, but the optional container (see the part of the
documentation that discusses cardinalities). So the above code should
be something along these lines:
if (myMap.selectedSourceMap().preset ())
{
// Attribute is present, get its value.
//
bool val = myMap.selectedSourceMap().get ();
}
Or, using the pointer notation:
if (myMap.selectedSourceMap())
{
// Attribute is present, get its value.
//
bool val = *myMap.selectedSourceMap();
}
Boris
More information about the xsd-users
mailing list