📄 service.cpp
字号:
for (vector<xs__schema*>::const_iterator schema1 = definitions.types->xs__schema_.begin(); schema1 != definitions.types->xs__schema_.end(); ++schema1) if (!definitions.targetNamespace || strcmp((*schema1)->targetNamespace, definitions.targetNamespace)) fprintf(stream, "%s = \"%s\"\n", types.nsprefix(NULL, (*schema1)->targetNamespace), (*schema1)->targetNamespace); fprintf(stream, "\n*/\n\n"); for (vector<xs__schema*>::const_iterator schema2 = definitions.types->xs__schema_.begin(); schema2 != definitions.types->xs__schema_.end(); ++schema2) fprintf(stream, schemaformat, types.nsprefix(NULL, (*schema2)->targetNamespace), "namespace", (*schema2)->targetNamespace); for (vector<xs__schema*>::const_iterator schema3 = definitions.types->xs__schema_.begin(); schema3 != definitions.types->xs__schema_.end(); ++schema3) { if ((*schema3)->elementFormDefault == (*schema3)->attributeFormDefault) fprintf(stream, schemaformat, types.nsprefix(NULL, (*schema3)->targetNamespace), "form", (*schema3)->elementFormDefault == qualified ? "qualified" : "unqualified"); else { fprintf(stream, schemaformat, types.nsprefix(NULL, (*schema3)->targetNamespace), "elementForm", (*schema3)->elementFormDefault == qualified ? "qualified" : "unqualified"); fprintf(stream, schemaformat, types.nsprefix(NULL, (*schema3)->targetNamespace), "attributeForm", (*schema3)->attributeFormDefault == qualified ? "qualified" : "unqualified"); } } } banner("Schema Types"); // generate the prototypes first: these should allow use before def, e.g. class names then generate the defs // check if xsd:anyType is used if (!cflag && !pflag) { for (SetOfString::const_iterator i = definitions.builtinTypes().begin(); i != definitions.builtinTypes().end(); ++i) { if (!cflag && !strcmp(*i, "xs:anyType")) { pflag = 1; break; } } } if (dflag && pflag) { fprintf(stderr, "\nWarning -d option: -p option disabled and xsd__anyType base class removed.\nUse run-time SOAP_DOM_NODE flag to deserialize class instances into DOM nodes.\n"); fprintf(stream, "\n/*\nWarning -d option used: -p option disabled and xsd:anyType base class removed.\nUse run-time SOAP_DOM_NODE flag to deserialize class instances into DOM nodes.\nA DOM node is represented by the xsd__anyType object implemented in dom.cpp.\n*/\n\n"); pflag = 0; } // 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 of %s removed by option -m)\n", t); else types.format(s); } s = types.usetypemap[t]; if (s && *s) { if (mflag && **i != '"') fprintf(stream, "\n// xsd.h: typemap override of type %s with %s\n", t, s); if (types.knames.find(s) == types.knames.end()) types.knames.insert(s); } } else { if (!mflag) { if (**i == '"') fprintf(stream, "\n// Imported type %s defined by %s\n", *i, t); else { s = types.tname(NULL, NULL, "xsd:string"); fprintf(stream, "\n/// Primitive built-in type \"%s\"\n", *i); fprintf(stream, "typedef %s %s;\n", s, t); types.deftname(TYPEDEF, NULL, strchr(s, '*') != NULL, NULL, NULL, *i); } } 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, false, 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 of %s removed by option -m)\n", t); else types.format(s); } s = types.usetypemap[t]; if (s && *s) { if (mflag && **j != '"') fprintf(stream, "\n// xsd.h: typemap override of element %s with %s\n", t, 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); types.deftname(TYPEDEF, NULL, true, "_", NULL, *j); // already pointer } } 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, false, "_", NULL, *j); } } // 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 of %s removed by option -m)\n", t); else types.format(s); } s = types.usetypemap[t]; if (s && *s) { if (mflag && **k != '"') fprintf(stream, "\n// xsd.h: typemap override of attribute %s with %s\n", t, 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); if (t) fprintf(stream, "typedef _XML %s;\n", t); else fprintf(stream, "// Element definition intentionally left blank.\n"); } 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);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -