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


C++ NewStringf函数代码示例

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


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

示例1: Len

String *Swig_new_subdirectory(String *basedirectory, String *subdirectory) {
  String *error = 0;
  int current_directory = Len(basedirectory) == 0;

  if (current_directory || is_directory(basedirectory)) {
    Iterator it;
    String *dir = NewString(basedirectory);
    List *subdirs = Split(subdirectory, SWIG_FILE_DELIMITER[0], INT_MAX);

    for (it = First(subdirs); it.item; it = Next(it)) {
      int result;
      String *subdirectory = it.item;
      Printf(dir, "%s", subdirectory);
#ifdef _WIN32
      result = _mkdir(Char(dir));
#else
      result = mkdir(Char(dir), 0777);
#endif
      if (result != 0 && errno != EEXIST) {
	error = NewStringf("Cannot create directory %s: %s", dir, strerror(errno));
	break;
      }
      if (!is_directory(dir)) {
	error = NewStringf("Cannot create directory %s: it may already exist but not be a directory", dir);
	break;
      }
      Printf(dir, SWIG_FILE_DELIMITER);
    }
  } else {
    error = NewStringf("Cannot create subdirectory %s under the base directory %s. Either the base does not exist as a directory or it is not readable.", subdirectory, basedirectory);
  }
  return error;
}
开发者ID:EemeliSyynimaa,项目名称:yam2d,代码行数:33,代码来源:misc.c

示例2: Copy

/* Create a name applying rename/namewarn if needed */
static String *apply_rename(String *newname, int fullname, String *prefix, String *name) {
  String *result = 0;
  if (newname && Len(newname)) {
    if (Strcmp(newname, "$ignore") == 0) {
      result = Copy(newname);
    } else {
      char *cnewname = Char(newname);
      if (cnewname) {
	int destructor = name && (*(Char(name)) == '~');
	String *fmt = newname;
	/* use name as a fmt, but avoid C++ "%" and "%=" operators */
	if (Len(newname) > 1 && strchr(cnewname, '%') && !(strcmp(cnewname, "%=") == 0)) {
	  if (fullname && prefix) {
	    result = NewStringf(fmt, prefix, name);
	  } else {
	    result = NewStringf(fmt, name);
	  }
	} else {
	  result = Copy(newname);
	}
	if (destructor && result && (*(Char(result)) != '~')) {
	  Insert(result, 0, "~");
	}
      }
    }
  }

  return result;
}
开发者ID:progranism,项目名称:Allegro-5-SWIG-Wrapper,代码行数:30,代码来源:naming.c

示例3: Swig_cargs

/* -----------------------------------------------------------------------------
 * Swig_cargs()
 *
 * Emit all of the local variables for a list of parameters.  Returns the
 * number of parameters.
 * Default values for the local variables are only emitted if the compact default
 * argument behaviour is required.
 * ----------------------------------------------------------------------------- */
int Swig_cargs(Wrapper *w, ParmList *p) {
  int i = 0;
  int compactdefargs = ParmList_is_compactdefargs(p);

  while (p != 0) {
    String *lname = Swig_cparm_name(p, i);
    SwigType *pt = Getattr(p, k_type);
    if ((SwigType_type(pt) != T_VOID)) {
      String *local = 0;
      String *type = Getattr(p, k_type);
      /* default values only emitted if in compact default args mode */
      String *pvalue = (compactdefargs) ? Getattr(p, k_value) : 0;
      SwigType *altty = SwigType_alttype(type, 0);
      int tycode = SwigType_type(type);
      if (tycode == T_REFERENCE) {
	if (pvalue) {
	  SwigType *tvalue;
	  String *defname, *defvalue, *rvalue, *qvalue;
	  rvalue = SwigType_typedef_resolve_all(pvalue);
	  qvalue = SwigType_typedef_qualified(rvalue);
	  defname = NewStringf("%s_defvalue", lname);
	  tvalue = Copy(type);
	  SwigType_del_reference(tvalue);
	  tycode = SwigType_type(tvalue);
	  if (tycode != T_USER) {
	    /* plain primitive type, we copy the the def value */
	    String *lstr = SwigType_lstr(tvalue, defname);
	    defvalue = NewStringf("%s = %s", lstr, qvalue);
	    Delete(lstr);
	  } else {
	    /* user type, we copy the reference value */
	    String *str = SwigType_str(type, defname);
	    defvalue = NewStringf("%s = %s", str, qvalue);
	    Delete(str);
	  }
	  Wrapper_add_localv(w, defname, defvalue, NIL);
	  Delete(tvalue);
	  Delete(rvalue);
	  Delete(qvalue);
	  Delete(defname);
	  Delete(defvalue);
	}
      } else if (!pvalue && ((tycode == T_POINTER) || (tycode == T_STRING))) {
	pvalue = (String *) "0";
      }
      if (!altty) {
	local = Swig_clocal(pt, lname, pvalue);
      } else {
	local = Swig_clocal(altty, lname, pvalue);
	Delete(altty);
      }
      Wrapper_add_localv(w, lname, local, NIL);
      Delete(local);
      i++;
    }
    Delete(lname);
    p = nextSibling(p);
  }
  return (i);
}
开发者ID:abhishekgahlot,项目名称:Python-Fingerprint-Attendance-System,代码行数:68,代码来源:cwrap.c

示例4: Swig_name_nameobj_add

void Swig_name_nameobj_add(Hash *name_hash, List *name_list, String *prefix, String *name, SwigType *decl, Hash *nameobj) {
  String *nname = 0;
  if (name && Len(name)) {
    String *target_fmt = Getattr(nameobj, "targetfmt");
    nname = prefix ? NewStringf("%s::%s", prefix, name) : NewString(name);
    if (target_fmt) {
      String *tmp = NewStringf(target_fmt, nname);
      Delete(nname);
      nname = tmp;
    }
  }

  if (!nname || !Len(nname) || Getattr(nameobj, "fullname") ||	/* any of these options trigger a 'list' nameobj */
      Getattr(nameobj, "sourcefmt") || Getattr(nameobj, "matchlist") || Getattr(nameobj, "regextarget")) {
    if (decl)
      Setattr(nameobj, "decl", decl);
    if (nname && Len(nname))
      Setattr(nameobj, "targetname", nname);
    /* put the new nameobj at the beginnig of the list, such that the
       last inserted rule take precedence */
    Insert(name_list, 0, nameobj);
  } else {
    /* here we add an old 'hash' nameobj, simple and fast */
    Swig_name_object_set(name_hash, nname, decl, nameobj);
  }
  Delete(nname);
}
开发者ID:progranism,项目名称:Allegro-5-SWIG-Wrapper,代码行数:27,代码来源:naming.c

示例5: Swig_MembersetToFunction

int
Swig_MembersetToFunction(Node *n, String *classname, int flags) {
  String   *name;
  ParmList *parms;
  Parm     *p;
  SwigType *t;
  SwigType *ty;
  SwigType *type;
  String   *membername;
  String   *mangled;
  String   *self= 0;

  if (flags & CWRAP_SMART_POINTER) {
    self = NewString("(*this)->");
  }

  name = Getattr(n,"name");
  type = Getattr(n,"type");

  membername = Swig_name_member(classname, Swig_name_set(name));
  mangled = Swig_name_mangle(membername);

  t = NewString(classname);
  SwigType_add_pointer(t);
  parms = NewParm(t,"self");
  Delete(t);

  ty = Swig_wrapped_var_type(type);
  p = NewParm(ty,name);
  set_nextSibling(parms,p);

  /* If the type is a pointer or reference.  We mark it with a special wrap:disown attribute */
  if (SwigType_check_decl(type,"p.")) {
    Setattr(p,"wrap:disown","1");
  }
  Delete(p);

  if (flags & CWRAP_EXTEND) {
    String *code = Getattr(n,"code");
    if (code) {
      String *s = NewStringf("void %s(%s)", mangled, ParmList_str(parms));
      Printv(s,code,"\n",NIL);
      Setattr(n,"wrap:code",s);
      Delete(s);
    }
    Setattr(n,"wrap:action", NewStringf("%s;\n", Swig_cfunction_call(mangled,parms)));
  } else {
    Setattr(n,"wrap:action", NewStringf("%s;\n", Swig_cmemberset_call(name,type,self)));
  }
  Setattr(n,"type","void");
  Setattr(n,"parms", parms);
  Delete(parms);
  Delete(ty);
  Delete(membername);
  Delete(mangled);
  Delete(self);
  return SWIG_OK;
}
开发者ID:jumpinjackie,项目名称:node-mapguide,代码行数:58,代码来源:cwrap.c

示例6: Len

Hash *Swig_name_nameobj_lget(List *namelist, Node *n, String *prefix, String *name, String *decl) {
  Hash *res = 0;
  if (namelist) {
    int len = Len(namelist);
    int i;
    int match = 0;
    for (i = 0; !match && (i < len); i++) {
      Hash *rn = Getitem(namelist, i);
      String *rdecl = Getattr(rn, "decl");
      if (rdecl && (!decl || !Equal(rdecl, decl))) {
	continue;
      } else if (Swig_name_match_nameobj(rn, n)) {
	String *tname = Getattr(rn, "targetname");
	if (tname) {
	  String *sfmt = Getattr(rn, "sourcefmt");
	  String *sname = 0;
	  int fullname = GetFlag(rn, "fullname");
	  int regextarget = GetFlag(rn, "regextarget");
	  if (sfmt) {
	    if (fullname && prefix) {
	      String *pname = NewStringf("%s::%s", prefix, name);
	      sname = NewStringf(sfmt, pname);
	      Delete(pname);
	    } else {
	      sname = NewStringf(sfmt, name);
	    }
	  } else {
	    if (fullname && prefix) {
	      sname = NewStringf("%s::%s", prefix, name);
	    } else {
	      sname = name;
	      DohIncref(name);
	    }
	  }
	  match = regextarget ? Swig_name_regexmatch_value(n, tname, sname)
	    : Swig_name_match_value(tname, sname);
	  Delete(sname);
	} else {
	  /* Applying the renaming rule may fail if it contains a %(regex)s expression that doesn't match the given name. */
	  String *sname = NewStringf(Getattr(rn, "name"), name);
	  if (sname) {
	    if (Len(sname))
	      match = 1;
	    Delete(sname);
	  }
	}
      }
      if (match) {
	res = rn;
	break;
      }
    }
  }
  return res;
}
开发者ID:progranism,项目名称:Allegro-5-SWIG-Wrapper,代码行数:55,代码来源:naming.c

示例7: NewStringf

static String *Swig_wrapped_var_assign(SwigType *t, const String_or_char *name, int varcref) {
  if (SwigType_isclass(t)) {
    if (varcref) {
      return NewStringf("%s", name);
    } else {
      return NewStringf("&%s", name);
    }
  } else {
    return SwigType_lcaststr(t, name);
  }
}
开发者ID:abhishekgahlot,项目名称:Python-Fingerprint-Attendance-System,代码行数:11,代码来源:cwrap.c

示例8: Swig_name_object_get

DOH *
Swig_name_object_get(Hash *namehash, String *prefix, String *name, SwigType *decl) {
  String *tname;
  DOH    *rn = 0;
  Hash   *n;
  char   *ncdecl = 0;

  if (!namehash) return 0;

  /* DB: This removed to more tightly control feature/name matching */
  /*  if ((decl) && (SwigType_isqualifier(decl))) {
    ncdecl = strchr(Char(decl),'.');
    ncdecl++;
  }
  */

  /* Perform a class-based lookup (if class prefix supplied) */
  if (prefix) {
    if (Len(prefix)) {
      tname = NewStringf("%s::%s",prefix,name);
      n = Getattr(namehash,tname);
      rn = get_object(n,decl);
      if ((!rn) && ncdecl) rn = get_object(n,ncdecl);
      if (!rn) rn = get_object(n,0);
      Delete(tname);
    }
    /* A wildcard-based class lookup */
    if (!rn) {
      tname = NewStringf("*::%s",name);
      n = Getattr(namehash,tname);
      rn = get_object(n,decl);
      if ((!rn) && ncdecl) rn = get_object(n,ncdecl);
      if (!rn) rn = get_object(n,0);
      Delete(tname);
    }
  } else {
    /* Lookup in the global namespace only */
    tname = NewStringf("::%s",name);
    n = Getattr(namehash,tname);
    rn = get_object(n,decl);
    if ((!rn) && ncdecl) rn = get_object(n,ncdecl);
    if (!rn) rn = get_object(n,0);
    Delete(tname);
  }
  /* Catch-all */
  if (!rn) {
    n = Getattr(namehash,name);
    rn = get_object(n,decl);
    if ((!rn) && ncdecl) rn = get_object(n,ncdecl);
    if (!rn) rn = get_object(n,0);
  }
  return rn;
}
开发者ID:kanbang,项目名称:Colt,代码行数:53,代码来源:naming.c

示例9: ParmList_str_defaultargs

/* -----------------------------------------------------------------------------
 * extension_code()
 *
 * Generates an extension function (a function defined in %extend)
 *
 *        return_type function_name(parms) code
 *
 * ----------------------------------------------------------------------------- */
static String *extension_code(const String *function_name, ParmList *parms, SwigType *return_type, const String *code, int cplusplus, const String *self) {
  String *parms_str = cplusplus ? ParmList_str_defaultargs(parms) : ParmList_str(parms);
  String *sig = NewStringf("%s(%s)", function_name, parms_str);
  String *rt_sig = SwigType_str(return_type, sig);
  String *body = NewStringf("SWIGINTERN %s", rt_sig);
  Printv(body, code, "\n", NIL);
  if (self)
    Replaceall(body, "$self", self);
  Delete(parms_str);
  Delete(sig);
  Delete(rt_sig);
  return body;
}
开发者ID:abhishekgahlot,项目名称:Python-Fingerprint-Attendance-System,代码行数:21,代码来源:cwrap.c

示例10: Swig_DestructorToFunction

int Swig_DestructorToFunction(Node *n, String *classname, int cplus, int flags) {
  SwigType *type;
  Parm *p;

  type = NewString(classname);
  SwigType_add_pointer(type);
  p = NewParm(type, k_self);
  Setattr(p, k_self, "1");
  Setattr(p, k_hidden, "1");
  Setattr(p, k_wrapdisown, "1");
  Delete(type);
  type = NewString("void");

  if (flags & CWRAP_EXTEND) {
    String *cres;
    String *call;
    String *membername, *mangled, *code;
    membername = Swig_name_destroy(classname);
    mangled = Swig_name_mangle(membername);
    code = Getattr(n, k_code);
    if (code) {
      Swig_add_extension_code(n, mangled, p, type, code, cparse_cplusplus, k_self);
    }
    call = Swig_cfunction_call(mangled, p);
    cres = NewStringf("%s;\n", call);
    Setattr(n, k_wrapaction, cres);
    Delete(membername);
    Delete(mangled);
    Delete(call);
    Delete(cres);
  } else {
    if (cplus) {
      String *call = Swig_cppdestructor_call(n);
      String *cres = NewStringf("%s\n", call);
      Setattr(n, k_wrapaction, cres);
      Delete(call);
      Delete(cres);
    } else {
      String *call = Swig_cdestructor_call(n);
      String *cres = NewStringf("%s\n", call);
      Setattr(n, k_wrapaction, cres);
      Delete(call);
      Delete(cres);
    }
  }
  Setattr(n, k_type, type);
  Setattr(n, k_parms, p);
  Delete(type);
  Delete(p);
  return SWIG_OK;
}
开发者ID:abhishekgahlot,项目名称:Python-Fingerprint-Attendance-System,代码行数:51,代码来源:cwrap.c

示例11: Swig_restore

void Swig_restore(Node *n) {
  String *temp;
  int len;
  List *l;
  String *ns;
  Iterator ki;

  ns = Getattr(n, "view");
  assert(ns);

  l = NewList();

  temp = NewStringf("%s:", ns);
  len = Len(temp);

  for (ki = First(n); ki.key; ki = Next(ki)) {
    if (Strncmp(temp, ki.key, len) == 0) {
      Append(l, ki.key);
    }
  }
  for (ki = First(l); ki.item; ki = Next(ki)) {
    DOH *obj = Getattr(n, ki.item);
    Setattr(n, Char(ki.item) + len, obj);
    Delattr(n, ki.item);
  }
  Delete(l);
  Delete(temp);
}
开发者ID:GSGroup,项目名称:swig-v8,代码行数:28,代码来源:tree.c

示例12: SwigType_add_default

static
void SwigType_add_default(String *def, SwigType *nr) {
  if (Strcmp(nr, "SWIGTYPE") == 0) {
    Append(def, "SWIGTYPE");
  } else {
    String *q = SwigType_isqualifier(nr) ? SwigType_pop(nr) : 0;
    if (q && strstr(Char(nr), "SWIGTYPE")) {
      Append(def, nr);
    } else {
      String *nd = SwigType_default(nr);
      if (nd) {
	String *bdef = nd;
	if (q) {
	  bdef = NewStringf("%s%s", q, nd);
	  if ((Strcmp(nr, bdef) == 0)) {
	    Delete(bdef);
	    bdef = nd;
	  } else {
	    Delete(nd);
	  }
	}
	Append(def, bdef);
	Delete(bdef);
      } else {
	Append(def, nr);
      }
    }
    Delete(q);
  }
}
开发者ID:charlie5,项目名称:swig4ada,代码行数:30,代码来源:stype.c

示例13: Swig_VarsetToFunction

int Swig_VarsetToFunction(Node *n, int flags) {
    String *name, *nname;
    ParmList *parms;
    SwigType *type, *ty;

    int varcref = flags & CWRAP_NATURAL_VAR;

    name = Getattr(n, "name");
    type = Getattr(n, "type");
    nname = SwigType_namestr(name);
    ty = Swig_wrapped_var_type(type, varcref);
    parms = NewParm(ty, name);

    if (flags & CWRAP_EXTEND) {
        String *sname = Swig_name_set(name);
        String *mangled = Swig_name_mangle(sname);
        String *call = Swig_cfunction_call(mangled, parms);
        String *cres = NewStringf("%s;", call);
        Setattr(n, "wrap:action", cres);
        Delete(cres);
        Delete(call);
        Delete(mangled);
        Delete(sname);
    } else {
        if (!Strstr(type, "enum $unnamed")) {
            String *pname = Swig_cparm_name(0, 0);
            String *dref = Swig_wrapped_var_deref(type, pname, varcref);
            String *call = NewStringf("%s = %s;", nname, dref);
            Setattr(n, "wrap:action", call);
            Delete(call);
            Delete(dref);
            Delete(pname);
        } else {
            String *pname = Swig_cparm_name(0, 0);
            String *call = NewStringf("if (sizeof(int) == sizeof(%s)) *(int*)(void*)&(%s) = %s;", nname, nname, pname);
            Setattr(n, "wrap:action", call);
            Delete(pname);
            Delete(call);
        }
    }
    Setattr(n, "type", "void");
    Setattr(n, "parms", parms);
    Delete(parms);
    Delete(ty);
    Delete(nname);
    return SWIG_OK;
}
开发者ID:sunaku,项目名称:swig-ruby-ffi,代码行数:47,代码来源:cwrap.c

示例14: Swig_wrapped_var_deref

String *
Swig_wrapped_var_deref(SwigType *t, String_or_char *name) {
  if (SwigType_isclass(t)) {
    return NewStringf("*%s",name);
  } else {
    return SwigType_rcaststr(t,name);
  }
}
开发者ID:jumpinjackie,项目名称:node-mapguide,代码行数:8,代码来源:cwrap.c

示例15: Swig_require

void Swig_require(const char *ns, Node *n, ...) {
  va_list ap;
  char *name;
  DOH *obj;

  va_start(ap, n);
  name = va_arg(ap, char *);
  while (name) {
    int newref = 0;
    int opt = 0;
    if (*name == '*') {
      newref = 1;
      name++;
    } else if (*name == '?') {
      newref = 1;
      opt = 1;
      name++;
    }
    obj = Getattr(n, name);
    if (!opt && !obj) {
      Swig_error(Getfile(n), Getline(n), "Fatal error (Swig_require).  Missing attribute '%s' in node '%s'.\n", name, nodeType(n));
      assert(obj);
    }
    if (!obj)
      obj = DohNone;
    if (newref) {
      /* Save a copy of the attribute */
      Setattr(n, NewStringf("%s:%s", ns, name), obj);
    }
    name = va_arg(ap, char *);
  }
  va_end(ap);

  /* Save the view */
  {
    String *view = Getattr(n, "view");
    if (view) {
      if (Strcmp(view, ns) != 0) {
	Setattr(n, NewStringf("%s:view", ns), view);
	Setattr(n, "view", NewString(ns));
      }
    } else {
      Setattr(n, "view", NewString(ns));
    }
  }
}
开发者ID:GSGroup,项目名称:swig-v8,代码行数:46,代码来源:tree.c


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