[xsde-users] enumeration type support

Thomas Frenzel (TomSun) tftomsun at streamteam.de
Fri Aug 7 20:16:51 EDT 2009


Hello xsde developers,

i am very new in the c++ embedded world. In the past i just coded in .NET languages. So i was searching for a possibility to parse/serialize xml streams/files. So i found xsd/e and was suprised how simple the code generation and usage of the generated code is. 

There's one thing that i am missing. Why do i have to implement the enum parse/serialization by myself? I would like to get an generated enum for each simple type that derives from string and contains only enumerations. Additionally i would like to have generated serializer/parser classes that does the validation for me

(Enum declaration in the schema)


<xsd:simpleType name="gender">
  <xsd:restriction base="xsd:string">
    <xsd:enumeration value="male"/>
    <xsd:enumeration value="female"/>
  </xsd:restriction>
</xsd:simpleType>

(Example snipped of the generated code that i would like to have)


enum gender
{
  male,
  female
};

...


virtual ::gender post_gender ()
  {
    std::string s = post_string ();
    if(s == "male")
     return gender::male;
    else if(s == "female")
     return gender::female;
    else
     // TODO throw exception
  }
Did you already plan something like that?

Regards, Tom


More information about the xsde-users mailing list