本文整理汇总了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);
}
示例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);
}
}
示例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;
}
示例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;
}
}
示例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;
}
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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));
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}