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

📄 types.cpp

📁 一款开源的soap库
💻 CPP
📖 第 1 页 / 共 5 页
字号:
          { const char *s = aname(prefix, URI, name);	    knames.insert(s);            s = aname(prefix, URI, name);            fprintf(stream, "\n/// Class wrapper\n");            fprintf(stream, "class %s : public xsd__anyType\n{ public:\n", s);            fprintf(stream, elementformat, tname(prefix, URI, name), "__item;");	    modify(s);            fprintf(stream, "\n};\n");          }        }        else          fprintf(stream, "}\n");      }    }    else if (simpleType.list->itemType)    { const xs__simpleType *p = simpleType.list->itemTypePtr();      if (p && p->restriction && p->restriction->base && !p->restriction->enumeration.empty() && p->restriction->enumeration.size() <= 64)      { if (!anonymous)        { fprintf(stream, "\n/// \"%s\":%s is a simpleType list of %s.\n", URI?URI:"", name, simpleType.list->itemType);          fprintf(stream, "/// Note: this enumeration is a bitmask, so a set of values is supported (using | and & bit-ops on the bit vector).\n");	}        document(simpleType.annotation);        if (!anonymous)        { t = deftname(ENUM, NULL, false, prefix, URI, name);	  if (t)	    fprintf(stream, "enum * %s\n{\n", t);        }        else        { t = "";	  fprintf(stream, "enum *\n{\n");        }        if (t)	{ for (vector<xs__enumeration>::const_iterator enumeration = p->restriction->enumeration.begin(); enumeration != p->restriction->enumeration.end(); ++enumeration)          { if ((*enumeration).value)              fprintf(stream, "\t%s,\t///< %s value=\"%s\"\n", ename(t, (*enumeration).value), p->restriction->base, (*enumeration).value);            else              fprintf(stream, "//\tunrecognized: bitmask enumeration '%s' has no value\n", t);          }          if (!anonymous)          { fprintf(stream, "};\n");            if (yflag)	      fprintf(stream, "/// Typedef synonym for enum %s.\ntypedef enum %s %s;\n", t, t, t);            if (pflag && simpleType.name)            { const char *s = aname(prefix, URI, name);	      knames.insert(s);              s = aname(prefix, URI, name);              fprintf(stream, "\n/// Class wrapper.\n");              fprintf(stream, "class %s : public xsd__anyType\n{ public:\n", s);              fprintf(stream, elementformat, tname(prefix, URI, name), "__item;");	      modify(s);              fprintf(stream, "\n};\n");            }          }          else            fprintf(stream, "}\n");        }      }      else      { const char *s = tname(NULL, NULL, "xsd:string");        if (!anonymous)        { fprintf(stream, "\n/// \"%s\":%s is a simpleType containing a whitespace separated list of %s.\n", URI?URI:"", name, simpleType.list->itemType);          t = deftname(TYPEDEF, NULL, strchr(s, '*') != NULL, prefix, URI, name);	}        document(simpleType.annotation);        if (t)          fprintf(stream, "typedef %s %s;\n", s, t);        else        { fprintf(stream, elementformat, s, "");          fprintf(stream, "\n");        }      }    }    else    { if (!anonymous)      { fprintf(stream, "\n/// \"%s\":%s is a simpleType list.\n", URI?URI:"", name);        fprintf(stream, "/// Note: this enumeration is a bitmask, so a set of values is supported (using | and & bit-ops on the bit vector).\n");      }      document(simpleType.annotation);      if (!anonymous)      { t = deftname(ENUM, NULL, false, prefix, URI, name);        if (t && !eflag)          fprintf(stream, "/// Note: enum values are prefixed with '%s' to avoid name clashes, please use wsdl2h option -e to omit this prefix\n", t);      }      else        t = "";      if (t)      { fprintf(stream, "enum * %s\n{\n", t);        for (vector<xs__simpleType>::const_iterator simple = simpleType.list->simpleType.begin(); simple != simpleType.list->simpleType.end(); ++simple)        { if ((*simple).restriction && (*simple).restriction->base)          { for (vector<xs__enumeration>::const_iterator enumeration = (*simple).restriction->enumeration.begin(); enumeration != (*simple).restriction->enumeration.end(); ++enumeration)            { if ((*enumeration).value)                fprintf(stream, "\t%s,\t///< %s value=\"%s\"\n", ename(t, (*enumeration).value), (*simple).restriction->base, (*enumeration).value);              else                fprintf(stream, "//\tunrecognized: bitmask enumeration '%s' has no value\n", t);            }          }        }        if (!anonymous)        { fprintf(stream, "};\n");          if (yflag)	    fprintf(stream, "/// Typedef synonym for enum %s.\ntypedef enum %s %s;\n", t, t, t);          if (pflag && simpleType.name)          { const char *s = aname(prefix, URI, name);	    knames.insert(s);            s = aname(prefix, URI, name);            fprintf(stream, "\n/// Class wrapper.\n");            fprintf(stream, "class %s : public xsd__anyType\n{ public:\n", s);            fprintf(stream, elementformat, tname(prefix, URI, name), "__item;");	    modify(s);            fprintf(stream, "\n};\n");          }        }        else          fprintf(stream, "}\n");      }    }  }  else if (simpleType.union_)  { if (simpleType.union_->memberTypes)    { const char *s = tname(NULL, NULL, "xsd:string");      if (!anonymous)        t = deftname(TYPEDEF, NULL, strchr(s, '*') != NULL, prefix, URI, name);      fprintf(stream, "\n/// union of values \"%s\"\n", simpleType.union_->memberTypes);      if (t)        fprintf(stream, "typedef %s %s;\n", s, t);      else      { fprintf(stream, elementformat, s, "");        fprintf(stream, "\n");      }    }    else if (!simpleType.union_->simpleType.empty())    { const char *s = tname(NULL, NULL, "xsd:string");      fprintf(stream, "\n");      if (!anonymous)        t = deftname(TYPEDEF, NULL, strchr(s, '*') != NULL, prefix, URI, name);      for (vector<xs__simpleType>::const_iterator simpleType1 = simpleType.union_->simpleType.begin(); simpleType1 != simpleType.union_->simpleType.end(); ++simpleType1)        if ((*simpleType1).restriction)	{ fprintf(stream, "/// union of values from \"%s\"\n", (*simpleType1).restriction->base);          // TODO: are there any other types we should report here?        }      if (t)        fprintf(stream, "typedef %s %s;\n", s, t);      else      { fprintf(stream, elementformat, s, "");        fprintf(stream, "\n");      }    }    else      fprintf(stream, "//\tunrecognized\n");  }  else    fprintf(stream, "//\tunrecognized simpleType\n");}void Types::gen(const char *URI, const char *name, const xs__complexType& complexType, bool anonymous){ const char *t = NULL;  const char *prefix = NULL;  bool soapflag = false;  if (complexType.name)    name = complexType.name;  else    prefix = "_";  if (anonymous && name)    t = sname(URI, name);  else if (name)  { t = cname(prefix, URI, name);    if (deftypemap[t])      return;  }  if (name)    scope.push_back(name);  if (complexType.simpleContent)  { if (!anonymous)      fprintf(stream, "\n/// \"%s\":%s is a%s complexType with simpleContent.\n", URI?URI:"", name, complexType.abstract?"n abstract":"");    document(complexType.annotation);    if (complexType.simpleContent->restriction)    { if (anonymous)        fprintf(stream, "    struct %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);      const char *base = "xs:string";      const xs__complexType *p = &complexType;       do      { if (!p->simpleContent)          break;        if (p->simpleContent->restriction)        { if (p->simpleContent->restriction->complexTypePtr())	    p = p->simpleContent->restriction->complexTypePtr();	  else          { base = p->simpleContent->restriction->base;   	    break;	  }	}        else if (p->simpleContent->extension)        { if (p->simpleContent->extension->complexTypePtr())	    p = p->simpleContent->extension->complexTypePtr();          else          { base = p->simpleContent->extension->base;   	    break;          }	}	else	  break;      }      while (p);      fprintf(stream, "/// __item wraps '%s' simpleContent.\n", base);      fprintf(stream, elementformat, tname(NULL, NULL, 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);          if (p->simpleContent->restriction->complexTypePtr())            p = p->simpleContent->restriction->complexTypePtr();          else            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 if (complexType.simpleContent->extension)    { if (cflag || fflag || anonymous)      { if (anonymous)          fprintf(stream, "    struct %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);        const char *base = "xs:string";        const xs__complexType *p = &complexType;         do        { if (!p->simpleContent)            break;          if (p->simpleContent->restriction)          { if (p->simpleContent->restriction->complexTypePtr())	      p = p->simpleContent->restriction->complexTypePtr();	    else            { base = p->simpleContent->restriction->base;   	      break;	    }	  }          else if (p->simpleContent->extension)          { if (p->simpleContent->extension->complexTypePtr())	      p = p->simpleContent->extension->complexTypePtr();            else            { base = p->simpleContent->extension->base;   	      break;            }	  }	  else	    break;        }        while (p);        fprintf(stream, "/// __item wraps '%s' simpleContent.\n", base);        fprintf(stream, elementformat, tname(NULL, NULL, 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      { if (        /* TODO: should add check for base type == class	  complexType.simpleContent->extension->simpleTypePtr()	  ||	*/	  complexType.simpleContent->extension->complexTypePtr())	{ fprintf(stream, "class %s : public %s\n{ public:\n", t, cname(NULL, NULL, complexType.simpleContent->extension->base));	  soapflag = true;	}        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);          fprintf(stream, "/// __item wraps '%s' simpleContent.\n", complexType.simpleContent->extension->base);          fprintf(stream, elementformat, tname(NULL, NULL, complexType.simpleContent->extension->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 = (char*)malloc(strlen(attribute.wsdl__arrayType)+1);	    strcpy(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)	  { type = (char*)malloc(strlen(element.type)+1);	    strcpy(type, element.type);	  }	  item = element.name;	}	gen_soap_array(name, t, item, type);	if (type)	  free(type);      }      else      { if (anonymous)          fprintf(stream, "    struct %s\n    {\n", t);        else if (cflag)          fprintf(stream, "struct %s\n{\n", t);

⌨️ 快捷键说明

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