[xsd-users] Default values for optional elements.

Boris Kolpackov boris at codesynthesis.com
Tue Feb 14 03:09:55 EST 2006


Hi David,

Boris Kolpackov <boris at codesynthesis.com> writes:

> We will need to extend optional container with something like set_default
> which will also require an extra flag to distinguish between the normal
> value and default value cases (at the moment it's just an auto_ptr). So
> things get a bit hairy and I would like to think some more about other
> options. Maybe we should use another container, optional_with_default?

I tend to think that creating a separate container (which inherits from
the optional container) with this additional logic is the best way to go.
I also think it will make sense to use a different name for the accessor
function which has the additional, "default value" logic, something like
get_with_default. This way, when you have

return foo.bar ().get_with_default ();

and later change definition of bar not to have a default value or remove
the option that allow this behavior, you will get an error at compile-
time rather than at run-time. Any thoughts?


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/20060214/feb12fcb/attachment.pgp


More information about the xsd-users mailing list