[xsd-users] comparison question

Rizzuto, Raymond Raymond.Rizzuto at sig.com
Thu Jun 26 16:56:07 EDT 2008


Hi!

I have an object/element containing a polymorphic type.  I enabled comparison code generation, but it looks like it gives up on deciding how to compare the contained polymorphic types.  Here is the generated code for the polymorphic type's base:

    bool
    operator== (const MessageType&, const MessageType&)
    {
      return true;
    }

    bool
    operator!= (const MessageType& x, const MessageType& y)
    {
      return !(x == y);
    }

I was hoping to use this to serialize then deserialize to compare the round trip on some XML I am creating, but this comparison always succeeds.  I would think the comparison for equal might be done by using rtti to check if x and y are of the same type and equal.  I.e.

    operator== (const MessageType& x, const MessageType& y)
    {
      if (typeid(x) != typeid(y))
            return false;
      return x.operator==(y);
    }

operator== would have to e a virtual member function - I'm not sure if that is allowed or not.

In the case I was trying, I believe the compare would fail.  The derived class, NewRequest, has an element called changed that is a NMTOKENS.  I do this to fill it:

    changes.push_back("state of the union");
    request.changed(changes);

This should be invalid in that space isn't allowed in a NMTOKEN, but it is accepted.  In the original object, the NMTOKENS list is of size 1, but when it is parsed back in, it is of size 4.

Ray


________________________________
Ray Rizzuto
raymond.rizzuto at sig.com
Susquehanna International Group
(610)747-2336 (W)
(215)776-3780 (C)



________________________________
IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses.



More information about the xsd-users mailing list