⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 types.cpp

📁 linux下简单对象应用协议的开发库
💻 CPP
📖 第 1 页 / 共 5 页
字号:
          else if (p->simpleContent->extension)          { if (p->simpleContent->extension->complexTypePtr())              p = p->simpleContent->extension->complexTypePtr();            else            { base = p->simpleContent->extension->base;                 if (p->simpleContent->extension->simpleTypePtr() && p->simpleContent->extension->simpleTypePtr()->schemaPtr())                baseURI = p->simpleContent->extension->simpleTypePtr()->schemaPtr()->targetNamespace;              break;            }          }          else            break;        }        while (p);        fprintf(stream, "/// __item wraps '%s' simpleContent.\n", base);        fprintf(stream, elementformat, tname(NULL, baseURI, base), "__item");        fprintf(stream, ";\n");        p = &complexType;         bool flag = true;        do        { if (!p->simpleContent)            break;          if (p->simpleContent->restriction)          { gen(URI, p->simpleContent->restriction->attribute);            if (p->simpleContent->restriction->anyAttribute && flag)              gen(URI, *p->simpleContent->restriction->anyAttribute);            break;          }          else if (p->simpleContent->extension)          { gen(URI, p->simpleContent->extension->attribute);            gen(URI, p->simpleContent->extension->attributeGroup);            if (p->simpleContent->extension->anyAttribute && flag)            { gen(URI, *p->simpleContent->extension->anyAttribute);              flag = false;            }            if (p->simpleContent->extension->complexTypePtr())              p = p->simpleContent->extension->complexTypePtr();            else              break;          }          else            break;        }        while (p);      }      else      { base = complexType.simpleContent->extension->base;        if (        /* TODO: in future, may want to add check here for base type == class          complexType.simpleContent->extension->simpleTypePtr()          ||        */          complexType.simpleContent->extension->complexTypePtr())        { if (complexType.simpleContent->extension->complexTypePtr()->schemaPtr())            baseURI = complexType.simpleContent->extension->complexTypePtr()->schemaPtr()->targetNamespace;          fprintf(stream, "class %s : public %s\n{ public:\n", t, cname(NULL, baseURI, base));          soapflag = true;        }        else        { if (complexType.simpleContent->extension->simpleTypePtr() && complexType.simpleContent->extension->simpleTypePtr()->schemaPtr())            baseURI = complexType.simpleContent->extension->simpleTypePtr()->schemaPtr()->targetNamespace;          else if (complexType.simpleContent->extension->complexTypePtr() && complexType.simpleContent->extension->complexTypePtr()->schemaPtr())            baseURI = complexType.simpleContent->extension->complexTypePtr()->schemaPtr()->targetNamespace;          if (pflag && complexType.name)            fprintf(stream, "class %s : public xsd__anyType\n{ public:\n", t);          else            fprintf(stream, "class %s\n{ public:\n", t);          fprintf(stream, "/// __item wraps '%s' simpleContent.\n", base);          fprintf(stream, elementformat, tname(NULL, baseURI, base), "__item");          fprintf(stream, ";\n");        }        gen(URI, complexType.simpleContent->extension->attribute);        gen(URI, complexType.simpleContent->extension->attributeGroup);        if (complexType.simpleContent->extension->anyAttribute)          gen(URI, *complexType.simpleContent->extension->anyAttribute);      }    }    else      fprintf(stream, "//\tunrecognized\n");  }  else if (complexType.complexContent)  { if (complexType.complexContent->restriction)    { if (!anonymous)        fprintf(stream, "\n/// \"%s\":%s is a%s complexType with complexContent restriction of %s.\n", URI?URI:"", name, complexType.abstract?"n abstract":"", complexType.complexContent->restriction->base);      document(complexType.annotation);      if (!strcmp(complexType.complexContent->restriction->base, "SOAP-ENC:Array"))      { char *item = NULL, *type = NULL;        if (!complexType.complexContent->restriction->attribute.empty())        { xs__attribute& attribute = complexType.complexContent->restriction->attribute.front();          if (attribute.wsdl__arrayType)            type = attribute.wsdl__arrayType;        }        if (complexType.complexContent->restriction->sequence && !complexType.complexContent->restriction->sequence->element.empty())        { xs__element& element = complexType.complexContent->restriction->sequence->element.front();          if (!type)          { if (element.type)              type = element.type;            else if (element.simpleTypePtr())            { if (element.simpleTypePtr()->name)                type = element.simpleTypePtr()->name;              else if (element.simpleTypePtr()->restriction)                type = element.simpleTypePtr()->restriction->base;            }            else if (element.complexTypePtr())            { if (element.complexTypePtr()->name)                type = element.complexTypePtr()->name;              else if (element.complexTypePtr()->complexContent && element.complexTypePtr()->complexContent->restriction)                type = element.complexTypePtr()->complexContent->restriction->base;            }          }          item = element.name;        }        gen_soap_array(name, t, item, type);      }      else      { if (anonymous)        { if (cflag)            fprintf(stream, "    struct %s\n    {\n", t);          else            fprintf(stream, "    class %s\n    {\n", t);        }        else if (cflag)          fprintf(stream, "struct %s\n{\n", t);        else if (pflag && complexType.name)          fprintf(stream, "class %s : public xsd__anyType\n{ public:\n", t);        else          fprintf(stream, "class %s\n{ public:\n", t);        if (complexType.complexContent->restriction->group)          gen(URI, *complexType.complexContent->restriction->group);        if (complexType.complexContent->restriction->all)          gen(URI, *complexType.complexContent->restriction->all);        if (complexType.complexContent->restriction->sequence)          gen(URI, *complexType.complexContent->restriction->sequence);        if (complexType.complexContent->restriction->choice)           gen(URI, name, *complexType.complexContent->restriction->choice);        const xs__complexType *p = &complexType;         bool flag = true;        do        { if (p->complexContent && p->complexContent->restriction)          { // TODO: to avoid problems should only generate attribute when name is different	    gen(URI, p->complexContent->restriction->attribute);            if (p->complexContent->restriction->anyAttribute && flag)            { gen(URI, *p->complexContent->restriction->anyAttribute);	      flag = false;	    }            if (p->complexContent->restriction->complexTypePtr())              p = p->complexContent->restriction->complexTypePtr();            else              break;          }          else if (p->complexContent && p->complexContent->extension)          { gen(URI, p->complexContent->extension->attribute);            gen(URI, p->complexContent->extension->attributeGroup);            if (p->complexContent->extension->anyAttribute && flag)            { gen(URI, *p->complexContent->extension->anyAttribute);              flag = false;            }            if (p->complexContent->extension->complexTypePtr())              p = p->complexContent->extension->complexTypePtr();            else              break;          }          else          { gen(URI, p->attribute);            gen(URI, p->attributeGroup);            if (p->anyAttribute && flag)              gen(URI, *p->anyAttribute);            break;          }        }        while (p);      }    }    else if (complexType.complexContent->extension)    { const char *base = complexType.complexContent->extension->base;      xs__complexType *p = complexType.complexContent->extension->complexTypePtr();      if (!anonymous)        fprintf(stream, "\n/// \"%s\":%s is a%s complexType with complexContent extension of %s.\n", URI?URI:"", name, complexType.abstract?"n abstract":"", base);      document(complexType.annotation);      if (anonymous)      { if (cflag)          fprintf(stream, "    struct %s\n    {\n", t);        else          fprintf(stream, "    class %s\n    {\n", t);      }      else if (cflag)        fprintf(stream, "struct %s\n{\n", t);      else if (fflag)        fprintf(stream, "class %s\n{ public:\n", t);      else // TODO: what to do if base class is in another namespace and elements must be qualified in XML payload?      { const char *baseURI = NULL;        if (p && p->schemaPtr())          baseURI = p->schemaPtr()->targetNamespace;        fprintf(stream, "class %s : public %s\n{ public:\n", t, cname(NULL, baseURI, base));        soapflag = true;      }      while (p)      { const char *pURI;        if (p->schemaPtr())          pURI = p->schemaPtr()->targetNamespace;        else          pURI = URI;        const char *b = cname(NULL, pURI, p->name);        static int nesting = 0;        if (cflag || fflag || anonymous)          fprintf(stream, "/// INHERITED FROM %s:\n", b);        else if (nesting == 0)          fprintf(stream, "/*  INHERITED FROM %s:\n", b);        else          fprintf(stream, "    INHERITED FROM %s:\n", b);        nesting++;        if (p->complexContent && p->complexContent->extension)        { if (p->complexContent->extension->group)            gen(pURI, *p->complexContent->extension->group); // schema URI?          if (p->complexContent->extension->all)            gen(pURI, *p->complexContent->extension->all);          if (p->complexContent->extension->sequence)            gen(pURI, *p->complexContent->extension->sequence);          if (p->complexContent->extension->choice)            gen(pURI, p->name, *p->complexContent->extension->choice);          gen(pURI, p->complexContent->extension->attribute);          gen(pURI, p->complexContent->extension->attributeGroup);          if (p->complexContent->extension->anyAttribute)            gen(pURI, *p->complexContent->extension->anyAttribute);          p = p->complexContent->extension->complexTypePtr();          modify(b);          nesting--;          if (cflag || fflag || anonymous)            fprintf(stream, "//  END OF INHERITED\n");          else if (nesting == 0)            fprintf(stream, "    END OF INHERITED */\n");          else            fprintf(stream, "    END OF INHERITED\n");        }        else        { if (p->all)            gen(pURI, p->all->element); // what about schema URI?          else if (p->all)            gen(pURI, *p->all);          else if (p->sequence)            gen(pURI, *p->sequence);          else if (p->choice)            gen(pURI, p->name, *p->choice);          else if (p->any)            gen(pURI, *p->any);          gen(pURI, p->attribute);          gen(pURI, p->attributeGroup);          if (p->anyAttribute)            gen(pURI, *p->anyAttribute);          modify(b);          nesting--;          if (cflag || fflag || anonymous)            fprintf(stream, "//  END OF INHERITED\n");          else if (nesting == 0)            fprintf(stream, "    END OF INHERITED */\n");          else            fprintf(stream, "    END OF INHERITED\n");          break;        }      }      if (complexType.complexContent->extension->group)        gen(URI, *complexType.complexContent->extension->group);      if (complexType.complexContent->extension->all)        gen(URI, *complexType.complexContent->extension->all);      if (complexType.complexContent->extension->sequence)        gen(URI, *complexType.complexContent->extension->sequence);      if (complexType.complexContent->extension->choice)        gen(URI, name, *complexType.complexContent->extension->choice);      gen(URI, complexType.complexContent->extension->attribute);      gen(URI, complexType.complexContent->extension->attributeGroup);      if (complexType.complexContent->extension->anyAttribute)        gen(URI, *complexType.complexContent->extension->anyAttribute);    }    else      fprintf(stream, "//\tunrecognized\n");  }  else  { if (!anonymous)      fprintf(stream, "\n/// \"%s\":%s is a%s complexType.\n", URI?URI:"", name, complexType.abstract?"n abstract":"");    document(complexType.annotation);    if (anonymous)    { if (cflag)        fprintf(stream, "    struct %s\n    {\n", t);      else        fprintf(stream, "    class %s\n    {\n", t);    }    else if (cflag)      fprintf(stream, "struct %s\n{\n", t);    else if (pflag && complexType.name)      fprintf(stream, "class %s : public xsd__anyType\n{ public:\n", t);    else      fprintf(stream, "class %s\n{ public:\n", t);    if (complexType.all)      gen(URI, *complexType.all);    else if (complexType.sequence)      gen(URI, *complexType.sequence);    else if (complexType.choice)      gen(URI, name, *complexType.choice);    else if (complexType.any)      gen(URI, *complexType.any);  }  gen(URI, complexType.attribute);  gen(URI, complexType.attributeGroup);  if (complexType.anyAttribute)    gen(URI, *complexType.anyAttribute);  if (complexType.mixed   || (complexType.complexContent && complexType.complexContent->extension && complexType.complexContent->extension->complexTypePtr() && complexType.complexContent->extension->complexTypePtr()->mixed))  { fprintf(stream, "/// TODO: this mixed complexType is user-definable.\n///       Consult the protocol documentation to change or insert declarations.\n///       Use wsdl2h option -d for xsd__anyType DOM (soap_dom_element).\n");    if (dflag)    { fprintf(stream, pointerformat, "xsd__anyType", "__mixed");      fprintf(stream, ";\t///< Catch mixed content in DOM soap_dom_element linked node structure.\n");    }    else    { fprintf(stream, elementformat, "_XML", "__mixed");      fprintf(stream, ";\t///< Catch mixed content in XML string\n");    }  }  if (!anonymous)  { if (!cflag && !(pflag && complexType.name) && !soapflag)    { if (!complexType.complexContent || !complexType.complexContent->extension || !complexType.complexContent->extension->complexTypePtr())      { fprintf(stream, "/// A handle to the soap struct that manages this instance (automatically set)\n");        fprintf(stream, pointerformat, "struct soap", "soap");        fprintf(stream, ";\n");      }    }    modify(t);    fprintf(stream, "};\n");  }  scope.pop_back();}void Types::gen(const char *URI, const vector<xs__attribute>& attributes){ for (vector<xs__attribute>::const_iterator attribute = attributes.begin(); attribute != attributes.end(); ++attribute)    gen(URI, *attribute);}void Types::gen(const char *URI, const xs__attribute& attribute){ const char *name, *type, *nameURI = NULL, *typeURI = NULL;  name = attribute.name;  type = attribute.type;  bool is_optional = attribute.use != required && attribute.use != default_ && attribute.use != fixed_ && !attribute.default_;  document(attribute.annotation);  if (!URI || strcmp(URI, attribute.schemaPtr()->targetNamespace))    nameURI = attribute.schemaPtr()->targetNamespace;  if (!URI)    URI = attribute.schemaPtr()->targetNamespace;  if (attribute.attributePtr()) // attribute ref  { char *prefix = NULL;    name = attribute.attributePtr()->name;    if (attribute.attributePtr()->schemaPtr())    { nameURI = typeURI = attribute.attributePtr()->schemaPtr()->targetNamespace;    }    if (attribute.attributePtr()->type)    { type = attribute.attributePtr()->type;  

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -