本文整理汇总了C++中NewStringEmpty函数的典型用法代码示例。如果您正苦于以下问题:C++ NewStringEmpty函数的具体用法?C++ NewStringEmpty怎么用?C++ NewStringEmpty使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewStringEmpty函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: malloc
Wrapper *NewWrapper(void) {
Wrapper *w;
w = (Wrapper *) malloc(sizeof(Wrapper));
w->localh = NewHash();
w->locals = NewStringEmpty();
w->code = NewStringEmpty();
w->def = NewStringEmpty();
return w;
}
示例2: Swig_extend_merge
void Swig_extend_merge(Node *cls, Node *am) {
Node *n;
Node *csym;
n = firstChild(am);
while (n) {
String *symname;
if (Strcmp(nodeType(n),"constructor") == 0) {
symname = Getattr(n,"sym:name");
if (symname) {
if (Strcmp(symname,Getattr(n,"name")) == 0) {
/* If the name and the sym:name of a constructor are the same,
then it hasn't been renamed. However---the name of the class
itself might have been renamed so we need to do a consistency
check here */
if (Getattr(cls,"sym:name")) {
Setattr(n,"sym:name", Getattr(cls,"sym:name"));
}
}
}
}
symname = Getattr(n,"sym:name");
DohIncref(symname);
if ((symname) && (!Getattr(n,"error"))) {
/* Remove node from its symbol table */
Swig_symbol_remove(n);
csym = Swig_symbol_add(symname,n);
if (csym != n) {
/* Conflict with previous definition. Nuke previous definition */
String *e = NewStringEmpty();
String *en = NewStringEmpty();
String *ec = NewStringEmpty();
Printf(ec,"Identifier '%s' redefined by %%extend (ignored),",symname);
Printf(en,"%%extend definition of '%s'.",symname);
SWIG_WARN_NODE_BEGIN(n);
Swig_warning(WARN_PARSE_REDEFINED,Getfile(csym),Getline(csym),"%s\n",ec);
Swig_warning(WARN_PARSE_REDEFINED,Getfile(n),Getline(n),"%s\n",en);
SWIG_WARN_NODE_END(n);
Printf(e,"%s:%d:%s\n%s:%d:%s\n",Getfile(csym),Getline(csym),ec,
Getfile(n),Getline(n),en);
Setattr(csym,"error",e);
Delete(e);
Delete(en);
Delete(ec);
Swig_symbol_remove(csym); /* Remove class definition */
Swig_symbol_add(symname,n); /* Insert extend definition */
}
}
n = nextSibling(n);
}
}
示例3: SwigType_namestr
String *Swig_name_disown(const_String_or_char_ptr nspace, const_String_or_char_ptr classname) {
String *r;
String *f;
String *rclassname;
char *cname;
rclassname = SwigType_namestr(classname);
r = NewStringEmpty();
if (!naming_hash)
naming_hash = NewHash();
f = Getattr(naming_hash, "disown");
if (!f) {
Append(r, "disown_%n%c");
} else {
Append(r, f);
}
cname = Char(rclassname);
if ((strncmp(cname, "struct ", 7) == 0) || ((strncmp(cname, "class ", 6) == 0)) || ((strncmp(cname, "union ", 6) == 0))) {
cname = strchr(cname, ' ') + 1;
}
replace_nspace(r, nspace);
Replace(r, "%c", cname, DOH_REPLACE_ANY);
Delete(rclassname);
return r;
}
示例4: pcre_compile
/* -----------------------------------------------------------------------------
* Swig_string_regex()
*
* Executes a regular expression substitution. For example:
*
* Printf(stderr,"gsl%(regex:/GSL_.*_/\\1/)s","GSL_Hello_") -> gslHello
* ----------------------------------------------------------------------------- */
String *Swig_string_regex(String *s) {
const int pcre_options = 0;
String *res = 0;
pcre *compiled_pat = 0;
const char *pcre_error, *input;
int pcre_errorpos;
String *pattern = 0, *subst = 0;
int captures[30];
if (split_regex_pattern_subst(s, &pattern, &subst, &input)) {
int rc;
compiled_pat = pcre_compile(
Char(pattern), pcre_options, &pcre_error, &pcre_errorpos, NULL);
if (!compiled_pat) {
Swig_error("SWIG", Getline(s), "PCRE compilation failed: '%s' in '%s':%i.\n",
pcre_error, Char(pattern), pcre_errorpos);
exit(1);
}
rc = pcre_exec(compiled_pat, NULL, input, (int)strlen(input), 0, 0, captures, 30);
if (rc >= 0) {
res = replace_captures(rc, input, subst, captures, pattern, s);
} else if (rc != PCRE_ERROR_NOMATCH) {
Swig_error("SWIG", Getline(s), "PCRE execution failed: error %d while matching \"%s\" using \"%s\".\n",
rc, Char(pattern), input);
exit(1);
}
}
DohDelete(pattern);
DohDelete(subst);
pcre_free(compiled_pat);
return res ? res : NewStringEmpty();
}
示例5: NewStringEmpty
String *SwigType_lcaststr(const SwigType *s, const_String_or_char_ptr name) {
String *result;
result = NewStringEmpty();
if (SwigType_isarray(s)) {
String *lstr = SwigType_lstr(s, 0);
Printf(result, "(%s)%s", lstr, name);
Delete(lstr);
} else if (SwigType_isreference(s)) {
String *str = SwigType_str(s, 0);
Printf(result, "(%s)", str);
Delete(str);
if (name)
Append(result, name);
} else if (SwigType_isqualifier(s)) {
String *lstr = SwigType_lstr(s, 0);
Printf(result, "(%s)%s", lstr, name);
Delete(lstr);
} else {
if (name)
Append(result, name);
}
return result;
}
示例6: NewStringEmpty
String *Swig_string_escape(String *s) {
String *ns;
int c;
ns = NewStringEmpty();
while ((c = Getc(s)) != EOF) {
if (c == '\n') {
Printf(ns, "\\n");
} else if (c == '\r') {
Printf(ns, "\\r");
} else if (c == '\t') {
Printf(ns, "\\t");
} else if (c == '\\') {
Printf(ns, "\\\\");
} else if (c == '\'') {
Printf(ns, "\\'");
} else if (c == '\"') {
Printf(ns, "\\\"");
} else if (c == ' ') {
Putc(c, ns);
} else if (!isgraph(c)) {
if (c < 0)
c += UCHAR_MAX + 1;
Printf(ns, "\\%o", c);
} else {
Putc(c, ns);
}
}
return ns;
}
示例7: NewStringEmpty
String *replace_captures(int num_captures, const char *input, String *subst, int captures[], String *pattern, String *s)
{
String *result = NewStringEmpty();
const char *p = Char(subst);
while (*p) {
/* Copy part without substitutions */
const char *q = strchr(p, '\\');
if (!q) {
Write(result, p, strlen(p));
break;
}
Write(result, p, q - p);
p = q + 1;
/* Handle substitution */
if (*p == '\0') {
Putc('\\', result);
} else if (isdigit((unsigned char)*p)) {
int group = *p++ - '0';
if (group < num_captures) {
int l = captures[group*2], r = captures[group*2 + 1];
if (l != -1) {
Write(result, input + l, r - l);
}
} else {
Swig_error("SWIG", Getline(s), "PCRE capture replacement failed while matching \"%s\" using \"%s\" - request for group %d is greater than the number of captures %d.\n",
Char(pattern), input, group, num_captures-1);
}
}
}
return result;
}
示例8: NewHash
SwigType *SwigType_strip_qualifiers(SwigType *t) {
static Hash *memoize_stripped = 0;
SwigType *r;
List *l;
Iterator ei;
if (!memoize_stripped)
memoize_stripped = NewHash();
r = Getattr(memoize_stripped, t);
if (r)
return Copy(r);
l = SwigType_split(t);
r = NewStringEmpty();
for (ei = First(l); ei.item; ei = Next(ei)) {
if (SwigType_isqualifier(ei.item))
continue;
Append(r, ei.item);
}
Delete(l);
{
String *key, *value;
key = Copy(t);
value = Copy(r);
Setattr(memoize_stripped, key, value);
Delete(key);
Delete(value);
}
return r;
}
示例9: NewStringEmpty
String *Swig_cconstructor_call(String_or_char *name) {
DOH *func;
func = NewStringEmpty();
Printf(func, "(%s *) calloc(1, sizeof(%s))", name, name);
return func;
}
示例10: DohSetDouble
void
DohSetDouble(DOH *obj, const DOH *name, double value) {
DOH *temp;
temp = NewStringEmpty();
Printf(temp,"%0.17f",value);
Setattr(obj,(DOH *) name,temp);
}
示例11: DohSetInt
void
DohSetInt(DOH *obj, const DOH *name, int value) {
DOH *temp;
temp = NewStringEmpty();
Printf(temp,"%d",value);
Setattr(obj,(DOH *) name,temp);
}
示例12: NewStringEmpty
String *replace_captures(const char *input, String *subst, int captures[])
{
String *result = NewStringEmpty();
const char *p = Char(subst);
while (*p) {
/* Copy part without substitutions */
const char *q = strchr(p, '\\');
if (!q) {
Write(result, p, strlen(p));
break;
}
Write(result, p, q - p);
p = q + 1;
/* Handle substitution */
if (*p == '\0') {
Putc('\\', result);
} else if (isdigit(*p)) {
int group = *p++ - '0';
int l = captures[group*2], r = captures[group*2 + 1];
if (l != -1) {
Write(result, input + l, r - l);
}
}
}
return result;
}
示例13: NewStringEmpty
String *Swig_stringify_with_location(DOH *object) {
String *str = NewStringEmpty();
if (!init_fmt)
Swig_error_msg_format(DEFAULT_ERROR_MSG_FORMAT);
if (object) {
int line = Getline(object);
String *formatted_filename = format_filename(Getfile(object));
if (line > 0) {
Printf(str, diag_line_fmt, formatted_filename, line);
} else {
Printf(str, diag_eof_fmt, formatted_filename);
}
if (Len(object) == 0) {
Printf(str, "[EMPTY]");
} else {
Printf(str, "[%s]", object);
}
Delete(formatted_filename);
} else {
Printf(str, "[NULL]");
}
return str;
}
示例14: NewStringEmpty
String *Swig_cconstructor_call(const_String_or_char_ptr name) {
DOH *func;
func = NewStringEmpty();
Printf(func, "calloc(1, sizeof(%s))", name);
return func;
}
示例15: va_start
DOHString *DohNewStringf(const DOHString_or_char *fmt, ...) {
va_list ap;
DOH *r;
va_start(ap, fmt);
r = NewStringEmpty();
DohvPrintf(r, Char(fmt), ap);
va_end(ap);
return (DOHString *) r;
}