[xsde-users] Problem with large enumerators

Jones Chris Chris.Jones at helvar.com
Fri Jan 8 11:53:41 EST 2016


Taking a enumerator ...

    <xs:simpleType name="SubFamily">
        <xs:restriction base="xs:string">
            <xs:enumeration value="Workgroup" />
            <xs:enumeration value="Cluster" />
            <xs:enumeration value="Root" />
                ....


Generates the code
  ::Entity::SubFamily SubFamily_pimpl::
  post_SubFamily ()
  {
    ::Entity::SubFamily::value_type v =
    static_cast< ::Entity::SubFamily::value_type > (0);
    const char* s = this->SubFamily_pimpl_state_.str_.c_str ();

    if (strcmp (s, "Workgroup") == 0)
      v = ::Entity::SubFamily::Workgroup;
    else if (strcmp (s, "Cluster") == 0)
      v = ::Entity::SubFamily::Cluster;
    else if (strcmp (s, "Root") == 0)
...

However on certain compilers - well the Microsoft one - there is a compiler limit on 128 nesting level.
No honestly. Generates the error
fatal error C1061: compiler limit : blocks nested too deeply
https://msdn.microsoft.com/en-us/library/dcda4f64.aspx

So as the enumerator grows over that 128 item limit suddenly generated code no longer compiles.

I know this really isn't your problem, and its trivial to fix by altering the code after its generated, however that's exactly what we don't want to do (Alter the generated code).

Would it be possible to change this to a new form? some form of looped lookup perhaps seeing as you already have an array of the string form in the <file>.cpp and the associated enumerator in the <file>.h
In fact wouldn't that even remove some memory requirement?

Just a suggestion, I'll understand if you ignore it, but it would make life a little easier for some of us.

Thanks for taking the time.

Chris J





More information about the xsde-users mailing list