[xsd-users] question on optional elements/attributes syntax
Ballentine, Casey
crballentine at essvote.com
Tue Nov 17 11:59:54 EST 2015
Hi Bruno,
That makes perfect sense. Thanks for helping out!
Casey
-----Original Message-----
From: Boris Kolpackov [mailto:boris at codesynthesis.com]
Sent: Tuesday, November 17, 2015 10:34 AM
To: Ballentine, Casey
Cc: xsd-users at codesynthesis.com
Subject: Re: [xsd-users] question on optional elements/attributes syntax
Hi Casey,
Ballentine, Casey <crballentine at essvote.com> writes:
> The returned values for optional elements are ThisIsMyElement_optional
> types. One thing I did discover is that complex elements that have
> sub-elements do require the .present() and .get() calls, but simple
> elements like Booleans can be accessed using the direct method. Does that make sense?
I don't think it is "like Booleans" but rather "only Booleans". optional<> has a smart pointer-like interface which allows you to write:
if (x.member ())
{
cerr << *x.member () << endl;
}
To achieve this, optional<> provides conversion to bool, which is why boolean optional members appear to be directly accessible (though the returned value is of course wrong).
Boris
More information about the xsd-users
mailing list