当前位置: 首页>>代码示例>>C++>>正文


C++ NewStringWithSize函数代码示例

本文整理汇总了C++中NewStringWithSize函数的典型用法代码示例。如果您正苦于以下问题:C++ NewStringWithSize函数的具体用法?C++ NewStringWithSize怎么用?C++ NewStringWithSize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了NewStringWithSize函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: split_regex_pattern_subst

static int split_regex_pattern_subst(String *s, String **pattern, String **subst, const char **input)
{
  const char *pats, *pate;
  const char *subs, *sube;

  /* Locate the search pattern */
  const char *p = Char(s);
  if (*p++ != '/') goto err_out;
  pats = p;
  p = strchr(p, '/');
  if (!p) goto err_out;
  pate = p;

  /* Locate the substitution string */
  subs = ++p;
  p = strchr(p, '/');
  if (!p) goto err_out;
  sube = p;

  *pattern = NewStringWithSize(pats, (int)(pate - pats));
  *subst   = NewStringWithSize(subs, (int)(sube - subs));
  *input   = p + 1;
  return 1;

err_out:
  Swig_error("SWIG", Getline(s), "Invalid regex substitution: '%s'.\n", s);
  exit(1);
}
开发者ID:EemeliSyynimaa,项目名称:yam2d,代码行数:28,代码来源:misc.c

示例2: Swig_scopename_split

void Swig_scopename_split(const String *s, String **rprefix, String **rlast) {
  char *tmp = Char(s);
  char *c = tmp;
  char *cc = c;
  char *co = 0;
  if (!strstr(c, "::")) {
    *rprefix = 0;
    *rlast = Copy(s);
  }

  co = strstr(cc, "operator ");
  if (co) {
    if (co == cc) {
      *rprefix = 0;
      *rlast = Copy(s);
      return;
    } else {
      *rprefix = NewStringWithSize(cc, (int)(co - cc - 2));
      *rlast = NewString(co);
      return;
    }
  }
  while (*c) {
    if ((*c == ':') && (*(c + 1) == ':')) {
      cc = c;
      c += 2;
    } else {
      if (*c == '<') {
	int level = 1;
	c++;
	while (*c && level) {
	  if (*c == '<')
	    level++;
	  if (*c == '>')
	    level--;
	  c++;
	}
      } else {
	c++;
      }
    }
  }

  if (cc != tmp) {
    *rprefix = NewStringWithSize(tmp, (int)(cc - tmp));
    *rlast = NewString(cc + 2);
    return;
  } else {
    *rprefix = 0;
    *rlast = Copy(s);
  }
}
开发者ID:EemeliSyynimaa,项目名称:yam2d,代码行数:52,代码来源:misc.c

示例3: assert

List *SwigType_parmlist(const String *p) {
  String *item = 0;
  List *list;
  char *c;
  char *itemstart;
  int size;

  assert(p);
  c = Char(p);
  while (*c && (*c != '(') && (*c != '.'))
    c++;
  if (!*c)
    return 0;
  assert(*c != '.'); /* p is expected to contain sub elements of a type */
  c++;
  list = NewList();
  itemstart = c;
  while (*c) {
    if (*c == ',') {
      size = (int) (c - itemstart);
      item = NewStringWithSize(itemstart, size);
      Append(list, item);
      Delete(item);
      itemstart = c + 1;
    } else if (*c == '(') {
      int nparens = 1;
      c++;
      while (*c) {
	if (*c == '(')
	  nparens++;
	if (*c == ')') {
	  nparens--;
	  if (nparens == 0)
	    break;
	}
	c++;
      }
    } else if (*c == ')') {
      break;
    }
    if (*c)
      c++;
  }
  size = (int) (c - itemstart);
  if (size > 0) {
    item = NewStringWithSize(itemstart, size);
    Append(list, item);
  }
  Delete(item);
  return list;
}
开发者ID:charlie5,项目名称:swig4ada,代码行数:51,代码来源:typeobj.c

示例4: Char

String *Swig_scopename_prefix(const String *s) {
  char *tmp = Char(s);
  char *c = tmp;
  char *cc = c;
  char *co = 0;
  if (!strstr(c, "::"))
    return 0;
  co = strstr(cc, "operator ");

  if (co) {
    if (co == cc) {
      return 0;
    } else {
      String *prefix = NewStringWithSize(cc, (int)(co - cc - 2));
      return prefix;
    }
  }
  while (*c) {
    if ((*c == ':') && (*(c + 1) == ':')) {
      cc = c;
      c += 2;
    } else {
      if (*c == '<') {
	int level = 1;
	c++;
	while (*c && level) {
	  if (*c == '<')
	    level++;
	  if (*c == '>')
	    level--;
	  c++;
	}
      } else {
	c++;
      }
    }
  }

  if (cc != tmp) {
    return NewStringWithSize(tmp, (int)(cc - tmp));
  } else {
    return 0;
  }
}
开发者ID:EemeliSyynimaa,项目名称:yam2d,代码行数:44,代码来源:misc.c

示例5: Len

String *SwigType_istemplate_only_templateprefix(const SwigType *t) {
  int len = Len(t);
  const char *s = Char(t);
  if (len >= 4 && strcmp(s + len - 2, ")>") == 0) {
    const char *c = strstr(s, "<(");
    return c ? NewStringWithSize(s, c - s) : 0;
  } else {
    return 0;
  }
}
开发者ID:0xb1dd1e,项目名称:swig,代码行数:10,代码来源:typeobj.c

示例6: SwigType_templateprefix

String *
SwigType_templateprefix(SwigType *t) {
  char *c,*s;

  s = Char(t);
  c = s;
  while (*c) {
    if (*c == '<') {
      return NewStringWithSize(s,c-s);
    }
    c++;
  }
  return NewString(s);
}
开发者ID:jumpinjackie,项目名称:node-mapguide,代码行数:14,代码来源:typeobj.c

示例7: Char

List *SwigType_split(SwigType *t) {
  DOH     *item;
  List    *list;
  char    *c;
  int      len;

  c = Char(t);
  list = NewList();
  while (*c) {
    len = element_size(c);
    item = NewStringWithSize(c,len);
    Append(list,item);
    Delete(item);
    c = c + len;
    if (*c == '.') c++;
  }
  return list;
}
开发者ID:jumpinjackie,项目名称:node-mapguide,代码行数:18,代码来源:typeobj.c

示例8: Char

SwigType *SwigType_pop(SwigType *t) {
  SwigType *result;
  char *c;
  int sz;

  c = Char(t);
  if (!*c)
    return 0;

  sz = element_size(c);
  result = NewStringWithSize(c, sz);
  Delslice(t, 0, sz);
  c = Char(t);
  if (*c == '.') {
    Delitem(t, 0);
  }
  return result;
}
开发者ID:charlie5,项目名称:swig4ada,代码行数:18,代码来源:typeobj.c

示例9: Char

static
String *partial_arg(String *s, String *p) {
  char *c;
  char *cp = Char(p);
  String *prefix;
  String *newarg;

  /* Find the prefix on the partial argument */

  c = strchr(cp, '$');
  if (!c) {
    return Copy(s);
  }
  prefix = NewStringWithSize(cp, c - cp);
  newarg = Copy(s);
  Replace(newarg, prefix, "", DOH_REPLACE_ANY | DOH_REPLACE_FIRST);
  Delete(prefix);
  return newarg;
}
开发者ID:veeramarni,项目名称:xuggle-swig,代码行数:19,代码来源:templ.c

示例10: Char

String *SwigType_namestr(const SwigType *t) {
  String *r;
  String *suffix;
  List *p;
  int i, sz;
  char *d = Char(t);
  char *c = strstr(d, "<(");

  if (!c || !strstr(c + 2, ")>"))
    return NewString(t);

  r = NewStringWithSize(d, c - d);
  if (*(c - 1) == '<')
    Putc(' ', r);
  Putc('<', r);

  p = SwigType_parmlist(c + 1);
  sz = Len(p);
  for (i = 0; i < sz; i++) {
    String *str = SwigType_str(Getitem(p, i), 0);
    /* Avoid creating a <: token, which is the same as [ in C++ - put a space after '<'. */
    if (i == 0 && Len(str))
      Putc(' ', r);
    Append(r, str);
    if ((i + 1) < sz)
      Putc(',', r);
    Delete(str);
  }
  Putc(' ', r);
  Putc('>', r);
  suffix = SwigType_templatesuffix(t);
  if (Len(suffix) > 0) {
    String *suffix_namestr = SwigType_namestr(suffix);
    Append(r, suffix_namestr);
    Delete(suffix_namestr);
  } else {
    Append(r, suffix);
  }
  Delete(suffix);
  Delete(p);
  return r;
}
开发者ID:Distrotech,项目名称:swig,代码行数:42,代码来源:stype.c

示例11: SwigType_parm

String *
SwigType_parm(SwigType *t) {
  char *start, *c;
  int  nparens = 0;

  c = Char(t);
  while (*c && (*c != '(') && (*c != '.')) c++;
  if (!*c || (*c == '.')) return 0;
  c++;
  start = c;
  while (*c) {
    if (*c == ')') {
      if (nparens == 0) break;
      nparens--;
    } else if (*c == '(') {
      nparens++;
    }
    c++;
  }
  return NewStringWithSize(start, (int) (c-start));
}
开发者ID:jumpinjackie,项目名称:node-mapguide,代码行数:21,代码来源:typeobj.c

示例12: SwigType_templateargs

String *
SwigType_templateargs(SwigType *t) {
  char *c;
  char *start;
  c = Char(t);
  while (*c) {
    if ((*c == '<') && (*(c+1) == '(')) {
      int nest = 1;
      start = c;
      c++;
      while (*c && nest) {
	if (*c == '<') nest++;
	if (*c == '>') nest--;
	c++;
      }
      return NewStringWithSize(start,c-start);
    }
    c++;
  }
  return 0;
}
开发者ID:jumpinjackie,项目名称:node-mapguide,代码行数:21,代码来源:typeobj.c

示例13: NewList

static List *Swig_make_attrlist(const char *ckey) {
  List *list = NewList();
  const char *cattr = strchr(ckey, '$');
  if (cattr) {
    String *nattr;
    const char *rattr = strchr(++cattr, '$');
    while (rattr) {
      nattr = NewStringWithSize(cattr, rattr - cattr);
      Append(list, nattr);
      Delete(nattr);
      cattr = rattr + 1;
      rattr = strchr(cattr, '$');
    }
    nattr = NewString(cattr);
    Append(list, nattr);
    Delete(nattr);
  } else {
    Append(list, "nodeType");
  }
  return list;
}
开发者ID:progranism,项目名称:Allegro-5-SWIG-Wrapper,代码行数:21,代码来源:naming.c

示例14: Swig_file_extension

String *Swig_file_basename(const_String_or_char_ptr filename) {
  String *extension = Swig_file_extension(filename);
  String *basename = NewStringWithSize(filename, Len(filename) - Len(extension));
  Delete(extension);
  return basename;
}
开发者ID:Distrotech,项目名称:swig,代码行数:6,代码来源:include.c

示例15: Char

String *Swig_string_rxspencer(String *s) {
  String *res = 0;
  if (Len(s)) {
    const char *cs = Char(s);
    const char *cb;
    const char *ce;
    if (*cs == '[') {
      int retval;
      regex_t compiled;
      cb = ++cs;
      ce = skip_delim('[', ']', cb);
      if (ce) {
	char bregexp[512];
	strncpy(bregexp, cb, ce - cb);
	bregexp[ce - cb] = '\0';
	++ce;
	retval = regcomp(&compiled, bregexp, REG_EXTENDED);
	if (retval == 0) {
	  cs = ce;
	  if (*cs == '[') {
	    cb = ++cs;
	    ce = skip_delim('[', ']', cb);
	    if (ce) {
	      const char *cvalue = ce + 1;
	      int nsub = (int) compiled.re_nsub + 1;
	      regmatch_t *pmatch = (regmatch_t *) malloc(sizeof(regmatch_t) * (nsub));
	      retval = regexec(&compiled, cvalue, nsub, pmatch, 0);
	      if (retval != REG_NOMATCH) {
		char *spos = 0;
		res = NewStringWithSize(cb, ce - cb);
		spos = Strchr(res, '@');
		while (spos) {
		  char cd = *(++spos);
		  if (isdigit(cd)) {
		    char arg[8];
		    size_t len;
		    int i = cd - '0';
		    sprintf(arg, "@%d", i);
		    if (i < nsub && (len = pmatch[i].rm_eo - pmatch[i].rm_so)) {
		      char value[256];
		      strncpy(value, cvalue + pmatch[i].rm_so, len);
		      value[len] = 0;
		      Replaceall(res, arg, value);
		    } else {
		      Replaceall(res, arg, "");
		    }
		    spos = Strchr(res, '@');
		  } else if (cd == '@') {
		    spos = strchr(spos + 1, '@');
		  }
		}
	      }
	      free(pmatch);
	    }
	  }
	}
	regfree(&compiled);
      }
    }
  }
  if (!res)
    res = NewStringEmpty();
  return res;
}
开发者ID:veeramarni,项目名称:xuggle-swig,代码行数:64,代码来源:misc.c


注:本文中的NewStringWithSize函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。