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

📄 service.cpp

📁 一款开源的soap库
💻 CPP
📖 第 1 页 / 共 5 页
字号:
  // define xsd:anyType first, if used  if (!cflag && pflag)  { const char *s, *t;    t = types.cname(NULL, NULL, "xs:anyType");    s = types.deftypemap[t];    if (s)    { if (*s)      { if (!mflag)          fprintf(stream, "%s\n", s);      }      s = types.usetypemap[t];      if (s)      { if (mflag)          fprintf(stream, "//  xsd.h should define type: %s\n", s);        types.knames.insert(s);      }    }    else    { fprintf(stderr, "Error: no xsd__anyType defined in type map\n");      pflag = 0;    }  }  // produce built-in primitive types, limited to the ones that are used only  if (vflag)    fprintf(stderr, "\nGenerating built-in types\n");  for (SetOfString::const_iterator i = definitions.builtinTypes().begin(); i != definitions.builtinTypes().end(); ++i)  { const char *s, *t;    if (!cflag && !strcmp(*i, "xs:anyType"))      continue;    t = types.cname(NULL, NULL, *i);    s = types.deftypemap[t];    if (s)    { if (*s)      { if (**i == '"')	  fprintf(stream, "\n/// Imported type %s from typemap %s.\n", *i, mapfile?mapfile:"");        else	  fprintf(stream, "\n/// Built-in type \"%s\".\n", *i);	if (mflag)          fprintf(stream, "//  (declaration removed by option -m) ");        types.format(s);      }      s = types.usetypemap[t];      if (s && *s)      { if (mflag && **i != '"')          fprintf(stream, "\n//  xsd.h should define type: %s\n", s);        if (types.knames.find(s) == types.knames.end())          types.knames.insert(s);      }    }    else    { s = types.tname(NULL, NULL, "xsd:string");      if (!mflag)      { if (**i == '"')          fprintf(stream, "\n// Imported type %s defined by %s\n", *i, t);        else        { fprintf(stream, "\n/// Primitive built-in type \"%s\"\n", *i);          fprintf(stream, "typedef %s %s;\n", s, t);        }      }      else if (**i == '"')        fprintf(stream, "\n//  Imported type %s defined by %s\n", *i, t);      else        fprintf(stream, "\n//  xsd.h should define type: %s\n", t);      types.deftname(TYPEDEF, NULL, strchr(s, '*') != NULL, NULL, NULL, *i);    }    if (pflag && !strncmp(*i, "xs:", 3))		// only xsi types are polymorph    { s = types.aname(NULL, NULL, *i);      if (!mflag)      { fprintf(stream, "\n/// Class wrapper for built-in type \"%s\" derived from xsd__anyType\n", *i);        fprintf(stream, "class %s : public xsd__anyType\n{ public:\n", s);        fprintf(stream, elementformat, types.tname(NULL, NULL, *i), "__item;");        fprintf(stream, "\n};\n");      }      types.knames.insert(s);    }  }  // produce built-in primitive elements, limited to the ones that are used only  if (vflag)    fprintf(stderr, "\nGenerating built-in elements\n");  for (SetOfString::const_iterator j = definitions.builtinElements().begin(); j != definitions.builtinElements().end(); ++j)  { const char *s, *t;    t = types.cname("_", NULL, *j);    s = types.deftypemap[t];    if (s)    { if (*s)      { if (**j == '"')	  fprintf(stream, "\n/// Imported element %s from typemap %s.\n", *j, mapfile?mapfile:"");        else	  fprintf(stream, "\n/// Built-in element \"%s\".\n", *j);	if (mflag)          fprintf(stream, "//  (declaration removed by option -m) ");        types.format(s);      }      s = types.usetypemap[t];      if (s && *s)      { if (mflag && **j != '"')          fprintf(stream, "\n//  xsd.h should define element: %s\n", s);        if (types.knames.find(s) == types.knames.end())          types.knames.insert(s);      }    }    else    { if (!mflag)      { if (**j == '"')	  fprintf(stream, "\n// Imported element %s declared as %s\n", *j, t);        else	{ fprintf(stream, "\n/// Built-in element \"%s\".\n", *j);          fprintf(stream, "typedef _XML %s;\n", t);        }      }      else if (**j == '"')	fprintf(stream, "\n//  Imported element %s declared as %s\n", *j, t);      else        fprintf(stream, "\n//  xsd.h should define element: %s\n", t);      types.deftname(TYPEDEF, NULL, true, "_", NULL, *j);	// already pointer    }  }  // produce built-in primitive attributes, limited to the ones that are used only  if (vflag)    fprintf(stderr, "\nGenerating built-in attributes\n");  for (SetOfString::const_iterator k = definitions.builtinAttributes().begin(); k != definitions.builtinAttributes().end(); ++k)  { const char *s, *t;    t = types.cname("_", NULL, *k);    s = types.deftypemap[t];    if (s)    { if (*s)      { if (**k == '"')	  fprintf(stream, "\n/// Imported attribute %s from typemap %s.\n", *k, mapfile?mapfile:"");        else	  fprintf(stream, "\n/// Built-in attribute \"%s\".\n", *k);	if (mflag)          fprintf(stream, "//  (declaration removed by option -m) ");        types.format(s);      }      s = types.usetypemap[t];      if (s && *s)      { if (mflag && **k != '"')          fprintf(stream, "\n//  xsd.h should define attribute: %s\n", s);        if (types.knames.find(s) == types.knames.end())          types.knames.insert(s);      }    }    else    { s = types.tname(NULL, NULL, "xsd:string");      if (!mflag)      { if (**k == '"')          fprintf(stream, "\n// Imported attribute %s declared as %s\n", *k, t);        else        { fprintf(stream, "\n/// Built-in attribute \"%s\".\n", *k);          fprintf(stream, "typedef %s %s;\n", s, t);        }      }      else if (**k == '"')        fprintf(stream, "//  Imported attribute %s declared as %s\n", *k, t);      else        fprintf(stream, "//  xsd.h should define attribute: %s\n", t);      types.deftname(TYPEDEF, NULL, strchr(s, '*') != NULL, "_", NULL, *k);    }  }  // produce types  // define class/struct types first  if (definitions.types)  { comment("Definitions", defs, "types", definitions.types->documentation);    fprintf(stream, "\n");    for (vector<xs__schema*>::const_iterator schema4 = definitions.types->xs__schema_.begin(); schema4 != definitions.types->xs__schema_.end(); ++schema4)    { if (vflag)        fprintf(stderr, "\nDefining types in %s\n", (*schema4)->targetNamespace);      for (vector<xs__complexType>::const_iterator complexType = (*schema4)->complexType.begin(); complexType != (*schema4)->complexType.end(); ++complexType)        types.define((*schema4)->targetNamespace, NULL, *complexType);      if (vflag)        fprintf(stderr, "\nDefining elements in %s\n", (*schema4)->targetNamespace);      for (vector<xs__element>::const_iterator element = (*schema4)->element.begin(); element != (*schema4)->element.end(); ++element)      { if (!(*element).type && !(*element).abstract)        { if ((*element).complexTypePtr())            types.define((*schema4)->targetNamespace, (*element).name, *(*element).complexTypePtr());	  else if (!(*element).simpleTypePtr())          { fprintf(stream, "\n/// Element \"%s\":%s.\n", (*schema4)->targetNamespace, (*element).name);            if (gflag)	    { const char *t = types.deftname(TYPEDEF, NULL, false, "_", (*schema4)->targetNamespace, (*element).name);  	      fprintf(stream, "typedef _XML %s;\n", t);	    }	    else	    { const char *s = types.cname("_", (*schema4)->targetNamespace, (*element).name);              types.ptrtypemap[s] = types.usetypemap[s] = "_XML";	      fprintf(stream, "/// Note: use wsdl2h option -g to generate this global element declaration.\n");            }	  }        }      }    }      // visit types with lowest base level first    int baseLevel = 1;    bool found;    do    { found = (baseLevel == 1);      for (vector<xs__schema*>::iterator schema = definitions.types->xs__schema_.begin(); schema != definitions.types->xs__schema_.end(); ++schema)      { for (vector<xs__simpleType>::iterator simpleType = (*schema)->simpleType.begin(); simpleType != (*schema)->simpleType.end(); ++simpleType)        { if ((*simpleType).baseLevel() == baseLevel)          { found = true;            types.gen((*schema)->targetNamespace, NULL, *simpleType, false);          }        }        for (vector<xs__element>::iterator element = (*schema)->element.begin(); element != (*schema)->element.end(); ++element)        { if (!(*element).type && (*element).simpleTypePtr() && (*element).simpleTypePtr()->baseLevel() == baseLevel)          { found = true;	    if ((*element).type)	      fprintf(stream, "/// Element \"%s\":%s of simpleType %s.\n", (*schema)->targetNamespace, (*element).name, (*element).type);	    types.document((*element).annotation);            types.gen((*schema)->targetNamespace, (*element).name, *(*element).simpleTypePtr(), false);          }          if (!(*element).type && (*element).complexTypePtr() && (*element).complexTypePtr()->baseLevel() == baseLevel)            found = true;        }        for (vector<xs__attribute>::const_iterator attribute = (*schema)->attribute.begin(); attribute != (*schema)->attribute.end(); ++attribute)        { if (!(*attribute).type && (*attribute).simpleTypePtr() && (*attribute).simpleTypePtr()->baseLevel() == baseLevel)          { found = true;	    if ((*attribute).type)	      fprintf(stream, "/// Attribute \"%s\":%s of simpleType %s.\n", (*schema)->targetNamespace, (*attribute).name, (*attribute).type);	    types.document((*attribute).annotation);            types.gen((*schema)->targetNamespace, (*attribute).name, *(*attribute).simpleTypePtr(), false); // URI = NULL won't generate type in schema (type without namespace qualifier)          }        }        for (vector<xs__complexType>::iterator complexType = (*schema)->complexType.begin(); complexType != (*schema)->complexType.end(); ++complexType)        { if ((*complexType).baseLevel() == baseLevel)            found = true;        }      }      ++baseLevel;    } while (found);    // generate complex type defs. Problem: what if a simpleType restriction/extension depends on a complexType simpleContent restriction/extension?    int maxLevel = baseLevel;    for (baseLevel = 1; baseLevel < maxLevel; ++baseLevel)    { for (vector<xs__schema*>::iterator schema = definitions.types->xs__schema_.begin(); schema != definitions.types->xs__schema_.end(); ++schema)      { for (vector<xs__complexType>::iterator complexType = (*schema)->complexType.begin(); complexType != (*schema)->complexType.end(); ++complexType)        { if ((*complexType).baseLevel() == baseLevel)            types.gen((*schema)->targetNamespace, NULL, *complexType, false);        }        for (vector<xs__element>::iterator element = (*schema)->element.begin(); element != (*schema)->element.end(); ++element)        { if (!(*element).type && (*element).complexTypePtr() && (*element).complexTypePtr()->baseLevel() == baseLevel)	  { fprintf(stream, "\n\n/// Element \"%s\":%s of complexType.\n", (*schema)->targetNamespace, (*element).name);	    types.document((*element).annotation);            types.gen((*schema)->targetNamespace, (*element).name, *(*element).complexTypePtr(), false);	  }        }      }    }    // option to consider: generate local complexTypes iteratively    /*    for (MapOfStringToType::const_iterator local = types.locals.begin(); local != types.locals.end(); ++local)    { types.gen(NULL, (*local).first, *(*local).second);    }    */    for (vector<xs__schema*>::iterator schema = definitions.types->xs__schema_.begin(); schema != definitions.types->xs__schema_.end(); ++schema)    { if (vflag)        fprintf(stderr, "\nGenerating elements in %s\n", (*schema)->targetNamespace);      for (vector<xs__element>::iterator element = (*schema)->element.begin(); element != (*schema)->element.end(); ++element)      { if ((*element).name && (*element).type && !(*element).abstract)        { fprintf(stream, "\n/// Element \"%s\":%s of type %s.\n", (*schema)->targetNamespace, (*element).name, (*element).type);          types.document((*element).annotation);          if (!types.is_defined("_", (*schema)->targetNamespace, (*element).name))          { const char *s = types.tname(NULL, NULL, (*element).type);            const char *t = types.deftname(TYPEDEF, NULL, false, "_", (*schema)->targetNamespace, (*element).name);

⌨️ 快捷键说明

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