[xsd-users] default contructor issue

Boris Kolpackov boris at codesynthesis.com
Thu Jun 26 13:29:36 EDT 2008


Hi Ray,

Rizzuto, Raymond <Raymond.Rizzuto at sig.com> writes:

> I had been using the default constructor (via -generate-default-ctor),
> and forgot to initializing a DateTime mandatory element.  When I went
> to serialize the object, I got an access violation.  Is that a bug? 
> Should I have instead gotten an xml_schema::Exception?

No this is not a bug. By default the generated code makes sure that you
initialize all required attributes and elements by forcing you to
initialize them at construction. By specifying --generate-default-ctor
you choose to take the risk of forgetting to initialize some required
members. This is clearly specifying in this option's documentation.
Adding extra checks in the serialization code (as well as in accessors
for consistency) will penalize people who use the strict interface by
hurting performance and increasing object code size.

Boris




More information about the xsd-users mailing list