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

📄 types.cpp

📁 linux下简单对象应用协议的开发库
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    usetypemap["SOAP_ENC__base64Binary"] = "SOAP_ENC__base64Binary";    deftypemap["SOAP_ENC__base64"] = "class SOAP_ENC__base64 { unsigned char *__ptr; int __size; };";    usetypemap["SOAP_ENC__base64"] = "SOAP_ENC__base64";  }  if (cflag)  { deftypemap["SOAP_ENC__boolean"] = "enum SOAP_ENC__boolean { false_, true_ };";    usetypemap["SOAP_ENC__boolean"] = "enum SOAP_ENC__boolean";  }  else  { deftypemap["SOAP_ENC__boolean"] = "";    usetypemap["SOAP_ENC__boolean"] = "bool";  }  deftypemap["SOAP_ENC__byte"] = "";  usetypemap["SOAP_ENC__byte"] = "char";  deftypemap["SOAP_ENC__dateTime"] = "";  usetypemap["SOAP_ENC__dateTime"] = "time_t";  deftypemap["SOAP_ENC__double"] = "";  usetypemap["SOAP_ENC__double"] = "double";  deftypemap["SOAP_ENC__float"] = "";  usetypemap["SOAP_ENC__float"] = "float";  if (cflag)  { deftypemap["SOAP_ENC__hexBinary"] = "struct SOAP_ENC__hexBinary { unsigned char *__ptr; int __size; };";    usetypemap["SOAP_ENC__hexBinary"] = "struct SOAP_ENC__hexBinary";  }  else  { deftypemap["SOAP_ENC__hexBinary"] = "class SOAP_ENC__hexBinary { unsigned char *__ptr; int __size; };";    usetypemap["SOAP_ENC__hexBinary"] = "SOAP_ENC__hexBinary";  }  deftypemap["SOAP_ENC__int"] = "";  usetypemap["SOAP_ENC__int"] = "int";  deftypemap["SOAP_ENC__long"] = "";  usetypemap["SOAP_ENC__long"] = "LONG64";  deftypemap["SOAP_ENC__short"] = "";  usetypemap["SOAP_ENC__short"] = "short";  ptrtypemap["SOAP_ENC__short"] = "int*";  if (cflag || sflag)  { deftypemap["SOAP_ENC__string"] = "";    usetypemap["SOAP_ENC__string"] = "char*";  }  else  { deftypemap["SOAP_ENC__string"] = "";    usetypemap["SOAP_ENC__string"] = "std::string";  }  deftypemap["SOAP_ENC__unsignedByte"] = "";  usetypemap["SOAP_ENC__unsignedByte"] = "unsigned char";  ptrtypemap["SOAP_ENC__unsignedByte"] = "unsigned short*";  deftypemap["SOAP_ENC__unsignedInt"] = "";  usetypemap["SOAP_ENC__unsignedInt"] = "unsigned long";  deftypemap["SOAP_ENC__unsignedLong"] = "";  usetypemap["SOAP_ENC__unsignedLong"] = "ULONG64";  deftypemap["SOAP_ENC__unsignedShort"] = "";  usetypemap["SOAP_ENC__unsignedShort"] = "unsigned short";  deftypemap["SOAP_ENC__Array"] = "";  usetypemap["SOAP_ENC__Array"] = "struct { _XML *__ptr; int __size; }";  deftypemap["_SOAP_ENC__arrayType"] = "";  deftypemap["SOAP_ENV__Header"] = "";  usetypemap["SOAP_ENV__Header"] = "struct SOAP_ENV__Header";  deftypemap["SOAP_ENV__Fault"] = "";  usetypemap["SOAP_ENV__Fault"] = "struct SOAP_ENV__Fault";  deftypemap["SOAP_ENV__detail"] = "";  usetypemap["SOAP_ENV__detail"] = "struct SOAP_ENV__Detail";  deftypemap["SOAP_ENV__Detail"] = "";  usetypemap["SOAP_ENV__Detail"] = "struct SOAP_ENV__Detail";  deftypemap["SOAP_ENV__Code"] = "";  usetypemap["SOAP_ENV__Code"] = "struct SOAP_ENV__Code";  deftypemap["SOAP_ENV__Reason"] = "";  usetypemap["SOAP_ENV__Reason"] = "struct SOAP_ENV__Reason";  if (read(mapfile))    fprintf(stderr, "Problem reading type map file %s.\nUsing internal type definitions for %s instead.\n\n", mapfile, cflag?"C":"C++");}const char *Types::nsprefix(const char *prefix, const char *URI){ if (URI)  { const char *s = uris[URI];    if (!s)    { size_t n;      if (!prefix || !*prefix || *prefix == '_')        s = schema_prefix;      else        s = estrdup(prefix);      if (!syms[s])        n = syms[s] = 1;      else        n = ++syms[s];      if (n != 1 || !prefix || !*prefix || *prefix == '_')      { char *t = (char*)emalloc(strlen(s) + 16);        sprintf(t, "%s%lu", s, (unsigned long)n);        s = t;      }      uris[URI] = s;      if (vflag)        fprintf(stderr, "namespace prefix %s = \"%s\"\n", s, URI);    }    // if *prefix == '_', then add prefix string to s    if (prefix && *prefix == '_')    { char *t = (char*)emalloc(strlen(s) + 2);      *t = '_';      strcpy(t + 1, s);      s = t;    }    return s;  }  return NULL;}// Find a C name for a QName. If the name has no qualifier, use URI. Suggest prefix for URIconst char *Types::fname(const char *prefix, const char *URI, const char *qname, SetOfString *reserved, enum Lookup lookup){ char buf[1024], *t;  const char *p, *s, *name;  if (!qname)  { fprintf(stream, "// Warning: internal error, no QName in fname()\n");    if (vflag)      fprintf(stderr, "Internal error, no QName in fname()\n");    qname = "?";  }  s = strrchr(qname, ':');  if (s)  { name = s + 1;    if (qname[0] == '"' && qname[1] == '"')      s = NULL;    else if (*qname == '"')    { t = (char*)emalloc(s - qname - 1);      strncpy(t, qname + 1, s - qname - 2);      t[s - qname - 2] = '\0';      URI = t;    }    else if (!strncmp(qname, "xs:", 3))	// this hack is necessary since the nsmap table defines "xs" for "xsd"    { s = "xsd";      URI = NULL;    }    else    { t = (char*)emalloc(s - qname + 1);      strncpy(t, qname, s - qname);      t[s - qname] = '\0';      s = t;      URI = NULL;    }  }  else    name = qname;  if (URI)    p = nsprefix(prefix, URI);  else if (s)    p = s;  else    p = "";  if (lookup == LOOKUP)  { s = qnames[Pair(p,name)];    if (s)      return s;  }  t = buf;  if (!prefix || *prefix)  { s = p;    // no longer add '_' when URI != NULL, since nsprefix() will do this    if (prefix && *prefix == '_')    { if (!URI)        *t++ = '_';      if (prefix[1] == '_') // ensures ns prefix starts with __      { strcpy(t, prefix + 1);        t += strlen(prefix + 1);      }    }    if (s && *s)    { for (; *s; s++)      { if (isalnum(*s))          *t++ = *s;        else if (*s == '-' && s != p)          *t++ = '_';        else if (*s == '_')        { if (s == p)            *t++ = '_';          else if (!_flag)          { strcpy(t, "_USCORE");            t += 7;          }          else          { s = utf8(t, s);            t += 6;          }        }        else        { s = utf8(t, s);          t += 6;        }      }      if (!prefix || *prefix != '*')      { *t++ = '_';        *t++ = '_';      }    }    else if (isdigit(*name))      *t++ = '_';  }  for (s = name; *s; s++)  { if (isalnum(*s))      *t++ = *s;    else if (*s == '-' && s != name)      *t++ = '_';    else if (!_flag && *s == '_')    { strcpy(t, "_USCORE");      t += 7;    }    else    { s = utf8(t, s);      t += 6;    }  }  *t = '\0';  while (knames.find(buf) != knames.end() || (reserved && reserved->find(buf) != reserved->end()))  { *t++ = '_';    *t = '\0';  }  if (isalpha(*buf) || *buf == '_')  { t = (char*)emalloc(strlen(buf) + 1);    strcpy(t, buf);  }  else  { t = (char*)emalloc(strlen(buf) + 2);    *t = '_';    strcpy(t + 1, buf);  }  if (lookup == LOOKUP)  { qnames[Pair(p,name)] = t;    if (vflag)      cerr << "Mapping " << p << ":" << name << " to " << t << endl;    /*    for (MapOfPairToString::const_iterator i = qnames.begin(); i != qnames.end(); ++i)      cerr << "(" << (*i).first.first << "," << (*i).first.second << ") = " << (*i).second << endl;    */  }  return t;}bool Types::is_defined(const char *prefix, const char *URI, const char *qname){ const char *t = fname(prefix, URI, qname, NULL, LOOKUP);  return usetypemap.find(t) != usetypemap.end();}const char *Types::aname(const char *prefix, const char *URI, const char *qname){ return fname(prefix, URI, qname, NULL, NOLOOKUP);}const char *Types::cname(const char *prefix, const char *URI, const char *qname){ return fname(prefix, URI, qname, NULL, LOOKUP);}const char *Types::tname(const char *prefix, const char *URI, const char *qname){ const char *s, *t;  t = cname(prefix, URI, qname);  if (usetypemap.find(t) != usetypemap.end())    s = usetypemap[t];  else  { s = t;    fprintf(stream, "\n// Warning: undefined QName '%s' for type '%s' (FIXME: check WSDL and schema definitions)\n", qname?qname:"", t);    if (vflag)      fprintf(stderr, "Warning: undefined QName '%s' for type '%s' in namespace '%s'\n", qname?qname:"", t, URI?URI:"?");  }  return s;}const char *Types::tnameptr(bool flag, const char *prefix, const char *URI, const char *qname){ const char *s = pname(flag, prefix, URI, qname);  if (flag)  { if (!strncmp(s, "char*", 5))      return "char**";    if (!strchr(s, '*'))    { char *r = (char*)emalloc(strlen(s) + 2);      strcpy(r, s);      strcat(r, "*");      return r;    }  }  return s;}const char *Types::pname(bool flag, const char *prefix, const char *URI, const char *qname){ const char *r, *s = NULL, *t;  t = cname(prefix, URI, qname);  if (flag)  { if (ptrtypemap.find(t) != ptrtypemap.end())      s = ptrtypemap[t];    else    { if (usetypemap.find(t) != usetypemap.end())        s = usetypemap[t];      if (!s)      { s = t;        fprintf(stream, "\n// Warning: undefined QName '%s' for pointer to type '%s' (FIXME: check WSDL and schema definitions)\n", qname, t);        if (vflag)          fprintf(stderr, "Warning: undefined QName '%s' for pointer to type '%s' in namespace '%s'\n", qname, t, URI?URI:"?");      }      r = s;      while (r && *r)      { r = strchr(r + 1, '*');        if (r && *(r-1) != '/' && *(r+1) != '/')          break;      }      if (!r)	// already pointer?      { char *p = (char*)emalloc(strlen(s) + 2);        strcpy(p, s);        strcat(p, "*");        s = p;      }      if (vflag)        fprintf(stderr, "Mapping pointer to %s to %s\n", t, s);      ptrtypemap[t] = s;    }  }  else if (usetypemap.find(t) != usetypemap.end())    s = usetypemap[t];  else  { s = t;    fprintf(stream, "\n// Warning: undefined QName '%s' for type '%s' (FIXME: check WSDL and schema definitions)\n", qname, t);    if (vflag)      fprintf(stderr, "Warning: undefined QName '%s' for type '%s' in namespace '%s'\n", qname, t, URI?URI:"?");  }  return s;}const char *Types::deftname(enum Type type, const char *pointer, bool is_pointer, const char *prefix, const char *URI, const char *qname){ char buf[1024];  char *s;  const char *q = NULL, *t;  t = fname(prefix, URI, qname, NULL, LOOKUP);  if (deftypemap[t])  { if (vflag)      fprintf(stderr, "Name %s already defined (probably in %s file)\n", qname, mapfile);    return NULL;  }  switch (type)  { case ENUM:      q = "enum";      if (yflag)        knames.insert(t);      break;    case STRUCT:      q = "struct";      if (yflag)        knames.insert(t);      break;    case CLASS:    case TYPEDEF:      knames.insert(t);    default:      break;  }  if (q)  { strcpy(buf, q);    strcat(buf, " ");  }  else    buf[0] = '\0';  strcat(buf, t);  if (pointer)    strcat(buf, pointer);  s = (char*)emalloc(strlen(buf) + 1);

⌨️ 快捷键说明

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