• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ REPLACE函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: vsmw_delseg

static void
vsmw_delseg(struct vsmw *vsmw, struct vsmwseg *seg, int fixidx)
{
	char *t = NULL;
	ssize_t s;
	int fd;

	CHECK_OBJ_NOTNULL(vsmw, VSMW_MAGIC);
	CHECK_OBJ_NOTNULL(seg, VSMWSEG_MAGIC);

	VTAILQ_REMOVE(&vsmw->segs, seg, list);
	REPLACE(seg->class, NULL);
	REPLACE(seg->id, NULL);
	FREE_OBJ(seg);

	if (fixidx) {
		vsmw_mkent(vsmw, vsmw->idx);
		REPLACE(t, VSB_data(vsmw->vsb));
		AN(t);
		fd = openat(vsmw->vdirfd,
		    t, O_WRONLY|O_CREAT|O_EXCL, vsmw->mode);
		assert(fd >= 0);
		vsmw_idx_head(vsmw, fd);
		VSB_clear(vsmw->vsb);
		VTAILQ_FOREACH(seg, &vsmw->segs, list)
			vsmw_fmt_index(vsmw, seg);
		AZ(VSB_finish(vsmw->vsb));
		s = write(fd, VSB_data(vsmw->vsb), VSB_len(vsmw->vsb));
		assert(s == VSB_len(vsmw->vsb));
		AZ(close(fd));
		AZ(renameat(vsmw->vdirfd, t, vsmw->vdirfd, vsmw->idx));
		REPLACE(t, NULL);
	}
}
开发者ID:hermunn,项目名称:varnish-cache,代码行数:34,代码来源:common_vsmw.c


示例2: tweak_group_cc

int
tweak_group_cc(struct vsb *vsb, const struct parspec *par, const char *arg)
{
	struct group *gr;

	(void)par;
	if (arg != NULL) {
		if (*arg != '\0') {
			gr = getgrnam(arg);
			if (gr == NULL) {
				VSB_printf(vsb, "Unknown group");
				return(-1);
			}
			REPLACE(mgt_param.group_cc, gr->gr_name);
			mgt_param.gid_cc = gr->gr_gid;
		} else {
			REPLACE(mgt_param.group_cc, "");
			mgt_param.gid_cc = 0;
		}
	} else if (strlen(mgt_param.group_cc) > 0) {
		VSB_printf(vsb, "%s (%d)",
		    mgt_param.group_cc, (int)mgt_param.gid_cc);
	} else {
		VSB_printf(vsb, "<not set>");
	}
	return (0);
}
开发者ID:Open-Party,项目名称:Varnish-Cache,代码行数:27,代码来源:mgt_param_tweak.c


示例3: tweak_user

void
tweak_user(struct cli *cli, const struct parspec *par, const char *arg)
{
	struct passwd *pw;

	(void)par;
	if (arg != NULL) {
		if (*arg != '\0') {
			pw = getpwnam(arg);
			if (pw == NULL) {
				VCLI_Out(cli, "Unknown user");
				VCLI_SetResult(cli, CLIS_PARAM);
				return;
			}
			REPLACE(mgt_param.user, pw->pw_name);
			mgt_param.uid = pw->pw_uid;
		} else {
			mgt_param.uid = getuid();
		}
	} else if (mgt_param.user) {
		VCLI_Out(cli, "%s (%d)", mgt_param.user, (int)mgt_param.uid);
	} else {
		VCLI_Out(cli, "UID %d", (int)mgt_param.uid);
	}
}
开发者ID:comur,项目名称:Varnish-Cache,代码行数:25,代码来源:mgt_param.c


示例4: xyzzy_dyn__init

VCL_VOID
xyzzy_dyn__init(VRT_CTX, struct xyzzy_debug_dyn **dynp,
    const char *vcl_name, VCL_STRING addr, VCL_STRING port, VCL_PROBE probe)
{
	struct xyzzy_debug_dyn *dyn;

	ASSERT_CLI();
	CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
	AN(dynp);
	AZ(*dynp);
	AN(vcl_name);

	if (*addr == '\0' || *port == '\0') {
		AN(ctx->handling);
		AZ(*ctx->handling);
		VRT_fail(ctx, "Missing dynamic backend address or port");
		return;
	}

	ALLOC_OBJ(dyn, VMOD_DEBUG_DYN_MAGIC);
	AN(dyn);
	REPLACE(dyn->vcl_name, vcl_name);

	AZ(pthread_mutex_init(&dyn->mtx, NULL));

	dyn_dir_init(ctx, dyn, addr, port, probe);
	XXXAN(dyn->dir);
	*dynp = dyn;
}
开发者ID:hermunn,项目名称:varnish-cache,代码行数:29,代码来源:vmod_debug_dyn.c


示例5: tweak_group

static void
tweak_group(struct cli *cli, const struct parspec *par, const char *arg)
{
	struct group *gr;

	(void)par;
	if (arg != NULL) {
		if (!strcmp(arg, MAGIC_INIT_STRING)) {
			gr = getgrnam("nogroup");
			if (gr == NULL) {
				/* Only replace if tweak_user didn't */
				if (master.gid == 0)
					master.gid = getgid();
				return;
			}
		} else
			gr = getgrnam(arg);
		if (gr == NULL) {
			VCLI_Out(cli, "Unknown group");
			VCLI_SetResult(cli, CLIS_PARAM);
			return;
		}
		REPLACE(master.group, gr->gr_name);
		master.gid = gr->gr_gid;
	} else if (master.group) {
		VCLI_Out(cli, "%s (%d)", master.group, (int)master.gid);
	} else {
		VCLI_Out(cli, "%d", (int)master.gid);
	}
}
开发者ID:QES,项目名称:Varnish-Cache,代码行数:30,代码来源:mgt_param.c


示例6: tweak_group

int
tweak_group(struct vsb *vsb, const struct parspec *par, const char *arg)
{
	struct group *gr;

	(void)par;
	if (arg != NULL) {
		if (*arg != '\0') {
			gr = getgrnam(arg);
			if (gr == NULL) {
				VSB_printf(vsb, "Unknown group");
				return(-1);
			}
			REPLACE(mgt_param.group, gr->gr_name);
			mgt_param.gid = gr->gr_gid;
		} else {
			mgt_param.gid = getgid();
		}
	} else if (mgt_param.group) {
		VSB_printf(vsb, "%s (%d)", mgt_param.group, (int)mgt_param.gid);
	} else {
		VSB_printf(vsb, "GID %d", (int)mgt_param.gid);
	}
	return (0);
}
开发者ID:Open-Party,项目名称:Varnish-Cache,代码行数:25,代码来源:mgt_param_tweak.c


示例7: sanitise

// Sanitise the given type (sub)AST, which has already been copied
static void sanitise(ast_t** astp)
{
  assert(astp != NULL);

  ast_t* type = *astp;
  assert(type != NULL);

  ast_clearflag(*astp, AST_FLAG_PASS_MASK);

  if(ast_id(type) == TK_TYPEPARAMREF)
  {
    // We have a type param reference, convert to a nominal
    ast_t* def = (ast_t*)ast_data(type);
    assert(def != NULL);

    const char* name = ast_name(ast_child(def));
    assert(name != NULL);

    REPLACE(astp,
      NODE(TK_NOMINAL,
        NONE      // Package name
        ID(name)
        NONE      // Type args
        NONE      // Capability
        NONE));   // Ephemeral

    return;
  }

  // Process all our children
  for(ast_t* p = ast_child(type); p != NULL; p = ast_sibling(p))
    sanitise(&p);
}
开发者ID:danielaRiesgo,项目名称:ponyc,代码行数:34,代码来源:sanitise.c


示例8: mgt_cli_setup

void
mgt_cli_setup(int fdi, int fdo, int auth, const char *ident,
    mgt_cli_close_f *closefunc, void *priv)
{
	struct cli *cli;
	struct vev *ev;

	cli = VCLS_AddFd(mgt_cls, fdi, fdo, closefunc, priv);

	REPLACE(cli->ident, ident);

	if (!auth && secret_file != NULL) {
		cli->auth = MCF_NOAUTH;
		mgt_cli_challenge(cli);
	} else {
		cli->auth = MCF_AUTH;
		mcf_banner(cli, NULL, NULL);
	}
	AZ(VSB_finish(cli->sb));
	(void)VCLI_WriteResult(fdo, cli->result, VSB_data(cli->sb));

	ev = VEV_Alloc();
	AN(ev);
	ev->name = cli->ident;
	ev->fd = fdi;
	ev->fd_flags = VEV__RD;
	ev->callback = mgt_cli_callback2;
	ev->priv = cli;
	AZ(VEV_Start(mgt_evb, ev));
}
开发者ID:ehocdet,项目名称:varnish-cache,代码行数:30,代码来源:mgt_cli.c


示例9: VRT_init_dir

void
VRT_init_dir(struct cli *cli, struct director **bp, int idx, const void *priv)
{
	const struct vrt_backend *t;
	struct vdi_simple *vs;

	ASSERT_CLI();
	(void)cli;
	t = priv;

	ALLOC_OBJ(vs, VDI_SIMPLE_MAGIC);
	XXXAN(vs);
	vs->dir.magic = DIRECTOR_MAGIC;
	vs->dir.priv = vs;
	vs->dir.name = "simple";
	REPLACE(vs->dir.vcl_name, t->vcl_name);
	vs->dir.getfd = vdi_simple_getfd;
	vs->dir.healthy = vdi_simple_healthy;

	vs->vrt = t;

	vs->backend = VBE_AddBackend(cli, t);
	if (vs->vrt->probe != NULL)
		VBP_Insert(vs->backend, vs->vrt->probe, vs->vrt->hosthdr);

	bp[idx] = &vs->dir;
}
开发者ID:Matt8109,项目名称:Varnish-Cache,代码行数:27,代码来源:cache_backend.c


示例10: sugar_binop

static ast_result_t sugar_binop(ast_t** astp, const char* fn_name)
{
  AST_GET_CHILDREN(*astp, left, right);

  ast_t* positional = ast_from(right, TK_POSITIONALARGS);

  if(ast_id(right) == TK_TUPLE)
  {
    ast_t* value = ast_child(right);

    while(value != NULL)
    {
      BUILD(arg, right, NODE(TK_SEQ, TREE(value)));
      ast_append(positional, arg);
      value = ast_sibling(value);
    }
  } else {
    BUILD(arg, right, NODE(TK_SEQ, TREE(right)));
    ast_add(positional, arg);
  }

  REPLACE(astp,
    NODE(TK_CALL,
      TREE(positional)
      NONE
      NODE(TK_DOT, TREE(left) ID(fn_name))
      ));

  return AST_OK;
}
开发者ID:shepheb,项目名称:ponyc,代码行数:30,代码来源:sugar.c


示例11: sugar_update

static ast_result_t sugar_update(ast_t** astp)
{
  ast_t* ast = *astp;
  assert(ast_id(ast) == TK_ASSIGN);

  AST_GET_CHILDREN(ast, value, call);

  if(ast_id(call) != TK_CALL)
    return AST_OK;

  // We are of the form:  x(y) = z
  // Replace us with:     x.update(y where value = z)
  AST_EXTRACT_CHILDREN(call, positional, named, expr);

  // If there are no named arguments yet, named will be a TK_NONE.
  ast_setid(named, TK_NAMEDARGS);

  // Build a new namedarg.
  BUILD_NO_DEBUG(namedarg, ast,
    NODE(TK_UPDATEARG,
      ID("value")
      NODE(TK_SEQ, TREE(value))));

  // Append the named arg to our existing list.
  ast_append(named, namedarg);

  // Replace with the update call.
  REPLACE(astp,
    NODE(TK_CALL,
      TREE(positional)
      TREE(named)
      NODE(TK_DOT, TREE(expr) ID("update"))));

  return AST_OK;
}
开发者ID:shepheb,项目名称:ponyc,代码行数:35,代码来源:sugar.c


示例12: extmacro_def

void
extmacro_def(const char *name, const char *fmt, ...)
{
	char buf[256];
	struct extmacro *m;
	va_list ap;

	VTAILQ_FOREACH(m, &extmacro_list, list)
		if (!strcmp(name, m->name))
			break;
	if (m == NULL && fmt != NULL) {
		m = calloc(sizeof *m, 1);
		AN(m);
		REPLACE(m->name, name);
		VTAILQ_INSERT_TAIL(&extmacro_list, m, list);
	}
	if (fmt != NULL) {
		AN(m);
		va_start(ap, fmt);
		free(m->val);
		vbprintf(buf, fmt, ap);
		va_end(ap);
		m->val = strdup(buf);
		AN(m->val);
	} else if (m != NULL) {
		VTAILQ_REMOVE(&extmacro_list, m, list);
		free(m->name);
		free(m->val);
		free(m);
	}
}
开发者ID:BMDan,项目名称:Varnish-Cache,代码行数:31,代码来源:vtc.c


示例13: tweak_group

void
tweak_group(struct cli *cli, const struct parspec *par, const char *arg)
{
	struct group *gr;

	(void)par;
	if (arg != NULL) {
		if (*arg != '\0') {
			gr = getgrnam(arg);
			if (gr == NULL) {
				VCLI_Out(cli, "Unknown group");
				VCLI_SetResult(cli, CLIS_PARAM);
				return;
			}
			REPLACE(mgt_param.group, gr->gr_name);
			mgt_param.gid = gr->gr_gid;
		} else {
			mgt_param.gid = getgid();
		}
	} else if (mgt_param.group) {
		VCLI_Out(cli, "%s (%d)", mgt_param.group, (int)mgt_param.gid);
	} else {
		VCLI_Out(cli, "GID %d", (int)mgt_param.gid);
	}
}
开发者ID:comur,项目名称:Varnish-Cache,代码行数:25,代码来源:mgt_param.c


示例14: tweak_user

int
tweak_user(struct vsb *vsb, const struct parspec *par, const char *arg)
{
	struct passwd *pw;

	(void)par;
	if (arg != NULL) {
		if (*arg != '\0') {
			pw = getpwnam(arg);
			if (pw == NULL) {
				VSB_printf(vsb, "Unknown user");
				return(-1);
			}
			REPLACE(mgt_param.user, pw->pw_name);
			mgt_param.uid = pw->pw_uid;
		} else {
			mgt_param.uid = getuid();
		}
	} else if (mgt_param.user) {
		VSB_printf(vsb, "%s (%d)", mgt_param.user, (int)mgt_param.uid);
	} else {
		VSB_printf(vsb, "UID %d", (int)mgt_param.uid);
	}
	return (0);
}
开发者ID:Open-Party,项目名称:Varnish-Cache,代码行数:25,代码来源:mgt_param_tweak.c


示例15: vdir_new

void
vdir_new(struct vdir **vdp, const char *name, const char *vcl_name,
    vdi_healthy_f *healthy, vdi_resolve_f *resolve, void *priv)
{
	struct vdir *vd;

	AN(name);
	AN(vcl_name);
	AN(vdp);
	AZ(*vdp);
	ALLOC_OBJ(vd, VDIR_MAGIC);
	AN(vd);
	*vdp = vd;
	AZ(pthread_mutex_init(&vd->mtx, NULL));

	ALLOC_OBJ(vd->dir, DIRECTOR_MAGIC);
	AN(vd->dir);
	vd->dir->name = name;
	REPLACE(vd->dir->vcl_name, vcl_name);
	vd->dir->priv = priv;
	vd->dir->healthy = healthy;
	vd->dir->resolve = resolve;
	vd->vbm = vbit_init(8);
	AN(vd->vbm);
}
开发者ID:daghf,项目名称:varnish-cache-oldfork,代码行数:25,代码来源:vdir.c


示例16: check_type_params

static bool check_type_params(ast_t** astp)
{
  ast_t* lhs = *astp;
  ast_t* type = ast_type(lhs);

  if(is_typecheck_error(type))
    return false;

  ast_t* typeparams = ast_childidx(type, 1);
  assert(ast_id(type) == TK_FUNTYPE);

  if(ast_id(typeparams) == TK_NONE)
    return true;

  BUILD(typeargs, typeparams, NODE(TK_TYPEARGS));

  if(!check_constraints(typeparams, typeargs, true))
  {
    ast_free_unattached(typeargs);
    return false;
  }

  type = reify(type, typeparams, typeargs);
  typeparams = ast_childidx(type, 1);
  ast_replace(&typeparams, ast_from(typeparams, TK_NONE));

  REPLACE(astp, NODE(ast_id(lhs), TREE(lhs) TREE(typeargs)));
  ast_settype(*astp, type);

  return true;
}
开发者ID:abingham,项目名称:ponyc,代码行数:31,代码来源:call.c


示例17: sugar_ifdef

static ast_result_t sugar_ifdef(typecheck_t* t, ast_t* ast)
{
  assert(t != NULL);
  assert(ast != NULL);

  AST_GET_CHILDREN(ast, cond, then_block, else_block, else_cond);

  // Combine parent ifdef condition with ours.
  ast_t* parent_ifdef_cond = t->frame->ifdef_cond;

  if(parent_ifdef_cond != NULL)
  {
    // We have a parent ifdef, combine its condition with ours.
    assert(ast_id(ast_parent(parent_ifdef_cond)) == TK_IFDEF);

    REPLACE(&else_cond,
      NODE(TK_AND,
        TREE(parent_ifdef_cond)
        NODE(TK_NOT, TREE(cond))));

    REPLACE(&cond,
      NODE(TK_AND,
        TREE(parent_ifdef_cond)
        TREE(cond)));
  }
  else
  {
    // Make else condition for our children to use.
    REPLACE(&else_cond, NODE(TK_NOT, TREE(cond)));
  }

  // Normalise condition so and, or and not nodes aren't sugared to function
  // calls.
  if(!ifdef_cond_normalise(&cond))
  {
    ast_error(ast, "ifdef condition will never be true");
    return AST_ERROR;
  }

  if(!ifdef_cond_normalise(&else_cond))
  {
    ast_error(ast, "ifdef condition is always true");
    return AST_ERROR;
  }

  return sugar_else(ast);
}
开发者ID:shepheb,项目名称:ponyc,代码行数:47,代码来源:sugar.c


示例18: VRT_Vmod_Init

void
VRT_Vmod_Init(void **hdl, void *ptr, int len, const char *nm, const char *path)
{
	struct vmod *v;
	void *x;
	const int *i;

	ASSERT_CLI();

	VTAILQ_FOREACH(v, &vmods, list)
		if (!strcmp(v->nm, nm))
			break;
	if (v == NULL) {
		ALLOC_OBJ(v, VMOD_MAGIC);
		AN(v);

		VTAILQ_INSERT_TAIL(&vmods, v, list);
		VSC_main->vmods++;

		REPLACE(v->nm, nm);
		REPLACE(v->path, path);

		v->hdl = dlopen(v->path, RTLD_NOW | RTLD_LOCAL);
		AN(v->hdl);

		x = dlsym(v->hdl, "Vmod_Name");
		AN(x);
		/* XXX: check that name is correct */

		x = dlsym(v->hdl, "Vmod_Len");
		AN(x);
		i = x;
		v->funclen = *i;

		x = dlsym(v->hdl, "Vmod_Func");
		AN(x);
		v->funcs = x;
	}

	assert(len == v->funclen);
	memcpy(ptr, v->funcs, v->funclen);
	v->ref++;

	*hdl = v;
}
开发者ID:drwilco,项目名称:varnish-cache-old,代码行数:45,代码来源:cache_vrt_vmod.c


示例19: main

int
main(int argc, char * const *argv)
{
	int opt;

	memset(&LOG, 0, sizeof LOG);
	VUT_Init(progname);

	while ((opt = getopt(argc, argv, vopt_optstring)) != -1) {
		switch (opt) {
		case 'a':
			/* Append to file */
			LOG.a_opt = 1;
			break;
		case 'B':
			/* Binary output */
			LOG.B_opt = 1;
			break;
		case 'h':
			/* Usage help */
			usage(0);
			break;
		case 'w':
			/* Write to file */
			REPLACE(LOG.w_arg, optarg);
			break;
		default:
			if (!VUT_Arg(opt, optarg))
				usage(1);
		}
	}

	if (optind != argc)
		usage(1);

	/* Setup output */
	if (LOG.B_opt)
		VUT.dispatch_f = VSL_WriteTransactions;
	else
		VUT.dispatch_f = VSL_PrintTransactions;
	if (LOG.w_arg) {
		openout(LOG.a_opt);
		AN(LOG.fo);
		VUT.sighup_f = rotateout;
	} else
		LOG.fo = stdout;
	VUT.idle_f = flushout;

	VUT_Setup();
	VUT_Main();
	VUT_Fini();

	(void)flushout();

	exit(0);
}
开发者ID:alexislitool,项目名称:Varnish-Cache,代码行数:56,代码来源:varnishlog.c


示例20: create_directory_hierarchy

		void		create_directory_hierarchy(const wcs& path)
		{
			wcs dir=REPLACE(path,L"/",L"\\");
			if(is_directory(path))
				return;
			int pos=-1;
			while((pos=(int)dir.find('\\',pos+1))>=0)
				CreateDirectory(dir.substr(0,pos).c_str(),NULL);
			CreateDirectory(dir.c_str(),NULL);
		}
开发者ID:vinceplusplus,项目名称:z3D,代码行数:10,代码来源:Misc.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ REPORT_ERROR函数代码示例发布时间:2022-05-30
下一篇:
C++ RENDERER_LOG_ERROR函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap