[xsd-users] Re: Polymorphism enhancements.

Bill Pringlemeir bpringle at sympatico.ca
Wed Jan 7 00:53:35 EST 2009


On  5 Dec 2008, boris at codesynthesis.com wrote:

> We can always add an option (e.g., --generate-explicit) for this but
> I am wondering how useful it will be.

That is a killer if you have 'operator' functionality in a wrapper
with parameter overloading.  You end up getting ambiguous definitions.
For example,

<xs:complexType name="quaterino">
  <xs:sequence>
    <xs:element name="oridinal" type="int_t"/>
  </xs:sequence>
  <xs:attribute name="i" type="int_t" default="0"/>
  <xs:attribute name="j" type="int_t" default="0"/>
  <xs:attribute name="k" type="int_t" default="0"/>
</xs:complexType>

class  quaterino: public quaterino_base
{
public:
   operator int();
}
quaterino operator+(const quaterino &, const quaterino&);
quaterino operator+(const quaterino &, const quaterino&);
quaterino operator+(const quaterino &, const quaterino&);

I ended up using '--custom-type quaterino='.  I agree that your time
might be better spent elsewhere.

>> 3. It is possible that a schema will have many similar data types with
>> the same defaults.  Would it be possible to use the same default
>> static instance in generated code.  Ie, if we have 20 "xs:int
>> default='0'" attributes, then twenty static elements are created.

> Do you mean the same private value (in order to save space) or the 
> same public accessors for these values?

I meant the same private value to reduce code size.

>> Alternatively, more control over the 'auto_ptr' mechanism that allows
>> selective generation of constructors would help.

> Not sure how this can be done. Specifying a set of c-tors to generate
> for each type sounds too burdensome.

I am not sure which variant is used underneath by XSD generated code.
However, with the 'base-ctor' option you can get four variants of
constructors.  In some cases the only difference is an
"xml_schema::string &" versus "std::auto_ptr<xml_schema::string>"
parameter.  With this condition the 'base-ctor' will generate four
versions.  The deep copy versions are useful to a user unless it is a
complexType.

It becomes more painful when customizing these classes [there are four
constructors to overload].  I was just wishing to turn off the
'auto_ptr' for a particular type (the class, not constructor
parameters).  Did I miss something?  I don't think you can do this.

Thanks again,
Bill Pringlemeir

-- 
``C Code. C code run. Run, code, run... PLEASE!!!'' 
- Barbara Tongue




More information about the xsd-users mailing list