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

C++ rb_sprintf函数代码示例

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

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



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

示例1: rb_class_path

VALUE
rb_class_path(VALUE klass)
{
    VALUE path = classname(klass);
    st_data_t n = (st_data_t)path;

    if (!NIL_P(path)) return path;
    if (RCLASS_IV_TBL(klass) && st_lookup(RCLASS_IV_TBL(klass),
					  (st_data_t)tmp_classpath, &n)) {
	return (VALUE)n;
    }
    else {
	const char *s = "Class";

	if (TYPE(klass) == T_MODULE) {
	    if (rb_obj_class(klass) == rb_cModule) {
		s = "Module";
	    }
	    else {
		s = rb_class2name(RBASIC(klass)->klass);
	    }
	}
	path = rb_sprintf("#<%s:%p>", s, (void*)klass);
	OBJ_FREEZE(path);
	rb_ivar_set(klass, tmp_classpath, path);

	return path;
    }
}
开发者ID:technohippy,项目名称:uruby,代码行数:29,代码来源:variable.c


示例2: rb_class_path

VALUE
rb_class_path(VALUE klass)
{
    VALUE path = classname(klass);

    if (!NIL_P(path)) return path;
    if ((path = rb_attr_get(klass, tmp_classpath)) != Qnil) {
	return path;
    }
    else {
	const char *s = "Class";

	if (TYPE(klass) == T_MODULE) {
	    if (rb_obj_class(klass) == rb_cModule) {
		s = "Module";
	    }
	    else {
		s = rb_class2name(RBASIC(klass)->klass);
	    }
	}
	path = rb_sprintf("#<%s:%p>", s, (void*)klass);
	OBJ_FREEZE(path);
	rb_ivar_set(klass, tmp_classpath, path);

	return path;
    }
}
开发者ID:MSch,项目名称:MacRuby,代码行数:27,代码来源:variable.c


示例3: rd_die_inspect

static VALUE rd_die_inspect(VALUE self)
{
    rd_die_t *die = GetDie(self);
    char *name;
    Dwarf_Off dieoff = 0;
    Dwarf_Error err;

    dwarf_dieoffset(die->die, &dieoff, &err);

    switch (dwarf_diename(die->die, &name, &err)) {
    case DW_DLV_OK:
        return rb_sprintf("#<%s:(%llu) '%s'>", rb_obj_classname(self), dieoff, name);
    default:
        return rb_sprintf("#<%s:(%llu)>", rb_obj_classname(self), dieoff);
    }
}
开发者ID:kubo,项目名称:rdwarf,代码行数:16,代码来源:rdwarf.c


示例4: load_encoding

static int
load_encoding(const char *name)
{
    VALUE enclib = rb_sprintf("enc/%s.so", name);
    VALUE verbose = ruby_verbose;
    VALUE debug = ruby_debug;
    VALUE errinfo;
    char *s = RSTRING_PTR(enclib) + 4, *e = RSTRING_END(enclib) - 3;
    int loaded;
    int idx;

    while (s < e) {
	if (!ISALNUM(*s)) *s = '_';
	else if (ISUPPER(*s)) *s = (char)TOLOWER(*s);
	++s;
    }
    FL_UNSET(enclib, FL_TAINT);
    enclib = rb_fstring(enclib);
    ruby_verbose = Qfalse;
    ruby_debug = Qfalse;
    errinfo = rb_errinfo();
    loaded = rb_require_internal(enclib, rb_safe_level());
    ruby_verbose = verbose;
    ruby_debug = debug;
    rb_set_errinfo(errinfo);
    if (loaded < 0 || 1 < loaded) return -1;
    if ((idx = rb_enc_registered(name)) < 0) return -1;
    if (enc_autoload_p(enc_table.list[idx].enc)) return -1;
    return idx;
}
开发者ID:tenderlove,项目名称:ruby,代码行数:30,代码来源:encoding.c


示例5: path_inspect

/* :nodoc: */
static VALUE
path_inspect(VALUE self)
{
    const char *c = rb_obj_classname(self);
    VALUE str = get_strpath(self);
    return rb_sprintf("#<%s:%"PRIsVALUE">", c, str);
}
开发者ID:gferguson-gd,项目名称:ruby,代码行数:8,代码来源:pathname.c


示例6: load_encoding

static int
load_encoding(const char *name)
{
    VALUE enclib = rb_sprintf("enc/%s.so", name);
    VALUE verbose = ruby_verbose;
    VALUE debug = ruby_debug;
    VALUE loaded;
    char *s = RSTRING_PTR(enclib) + 4, *e = RSTRING_END(enclib) - 3;
    int idx;

    while (s < e) {
	if (!ISALNUM(*s)) *s = '_';
	else if (ISUPPER(*s)) *s = TOLOWER(*s);
	++s;
    }
    OBJ_FREEZE(enclib);
    ruby_verbose = Qfalse;
    ruby_debug = Qfalse;
    loaded = rb_protect(require_enc, enclib, 0);
    ruby_verbose = verbose;
    ruby_debug = debug;
    rb_set_errinfo(Qnil);
    if (NIL_P(loaded)) return -1;
    if ((idx = rb_enc_registered(name)) < 0) return -1;
    if (enc_autoload_p(enc_table.list[idx].enc)) return -1;
    return idx;
}
开发者ID:217,项目名称:ruby,代码行数:27,代码来源:encoding.c


示例7: rb_funcall

// View#inspect
// View#to_s
VALUE rbView::Inspect( VALUE aSelf )
{
	VALUE viewportString = rb_funcall( rbView::GetViewport( aSelf ), rb_intern( "insepct" ), 0 );
	return rb_sprintf( "%s(%s)",
					   rb_obj_classname( aSelf ),
					   StringValueCStr( viewportString ) );
}
开发者ID:silverhammermba,项目名称:rbSFML,代码行数:9,代码来源:View.cpp


示例8: _inspect

/*
 * call-seq:
 *   inspect -> String
 *
 * Human-readable description.
 * ===Return value
 * String
*/
DLL_LOCAL VALUE _inspect(VALUE self)
{
	return rb_sprintf( "%s(%d, %d)",
		rb_obj_classname( self ),
		RB_NUM2INT(_getWidth(self)),
		RB_NUM2INT(_getHeight(self)));
}
开发者ID:Hanmac,项目名称:rwx,代码行数:15,代码来源:wxSize.cpp


示例9: m_ison

/*
 * m_ison added by Darren Reed 13/8/91 to act as an efficent user indicator
 * with respect to cpu/bandwidth used. Implemented for NOTIFY feature in
 * clients. Designed to reduce number of whois requests. Can process
 * nicknames in batches as long as the maximum buffer length.
 *
 * format:
 * ISON :nicklist
 */
static int
m_ison(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
	struct Client *target_p;
	char *nick;
	char *p;
	char *current_insert_point, *current_insert_point2;
	int len;
	int i;
	int done = 0;

	current_insert_point2 = buf2;
	*buf2 = '\0';

	rb_sprintf(buf, form_str(RPL_ISON), me.name, source_p->name);
	len = strlen(buf);
	current_insert_point = buf + len;

	/* rfc1489 is ambigious about how to handle ISON
	 * this should handle both interpretations.
	 */
	for(i = 1; i < parc; i++)
	{
		char *cs = LOCAL_COPY(parv[i]);
		for(nick = rb_strtok_r(cs, " ", &p); nick; nick = rb_strtok_r(NULL, " ", &p))
		{
			target_p = find_named_client(nick);

			if(target_p != NULL)
			{
				len = strlen(target_p->name);
				if((current_insert_point + (len + 5)) < (buf + sizeof(buf)))
				{
					memcpy(current_insert_point, target_p->name, len);
					current_insert_point += len;
					*current_insert_point++ = ' ';
				}
				else
				{
					done = 1;
					break;
				}
			}
		}
		if(done)
			break;
	}

	/*  current_insert_point--;
	 *  Do NOT take out the trailing space, it breaks ircII
	 *  --Rodder */

	*current_insert_point = '\0';
	*current_insert_point2 = '\0';

	sendto_one_buffer(source_p, buf);

	return 0;
}
开发者ID:asterIRC,项目名称:ircd-ratbox-ircnet,代码行数:68,代码来源:m_ison.c


示例10: tracepoint_inspect

static VALUE
tracepoint_inspect(VALUE self)
{
    rb_tp_t *tp = tpptr(self);
    rb_trace_arg_t *trace_arg = GET_THREAD()->trace_arg;

    if (trace_arg) {
	switch (trace_arg->event) {
	  case RUBY_EVENT_LINE:
	  case RUBY_EVENT_SPECIFIED_LINE:
	    {
		VALUE sym = rb_tracearg_method_id(trace_arg);
		if (NIL_P(sym))
		  goto default_inspect;
		return rb_sprintf("#<TracePoint:%"PRIsVALUE"@%"PRIsVALUE":%d in `%"PRIsVALUE"'>",
				  rb_tracearg_event(trace_arg),
				  rb_tracearg_path(trace_arg),
				  FIX2INT(rb_tracearg_lineno(trace_arg)),
				  sym);
	    }
	  case RUBY_EVENT_CALL:
	  case RUBY_EVENT_C_CALL:
	  case RUBY_EVENT_RETURN:
	  case RUBY_EVENT_C_RETURN:
	    return rb_sprintf("#<TracePoint:%"PRIsVALUE" `%"PRIsVALUE"'@%"PRIsVALUE":%d>",
			      rb_tracearg_event(trace_arg),
			      rb_tracearg_method_id(trace_arg),
			      rb_tracearg_path(trace_arg),
			      FIX2INT(rb_tracearg_lineno(trace_arg)));
	  case RUBY_EVENT_THREAD_BEGIN:
	  case RUBY_EVENT_THREAD_END:
	    return rb_sprintf("#<TracePoint:%"PRIsVALUE" %"PRIsVALUE">",
			      rb_tracearg_event(trace_arg),
			      rb_tracearg_self(trace_arg));
	  default:
	  default_inspect:
	    return rb_sprintf("#<TracePoint:%"PRIsVALUE"@%"PRIsVALUE":%d>",
			      rb_tracearg_event(trace_arg),
			      rb_tracearg_path(trace_arg),
			      FIX2INT(rb_tracearg_lineno(trace_arg)));
	}
    }
    else {
	return rb_sprintf("#<TracePoint:%s>", tp->tracing ? "enabled" : "disabled");
    }
}
开发者ID:Chatto,项目名称:VGdesk,代码行数:46,代码来源:vm_trace.c


示例11: ov_http_client_add_header

static int ov_http_client_add_header(VALUE name, VALUE value, struct curl_slist** headers) {
    VALUE header = Qnil;

    header = rb_sprintf("%"PRIsVALUE": %"PRIsVALUE"", name, value);
    *headers = curl_slist_append(*headers, StringValueCStr(header));

    return ST_CONTINUE;
}
开发者ID:oVirt,项目名称:ovirt-engine-sdk-ruby,代码行数:8,代码来源:ov_http_client.c


示例12: iow_inspect

static VALUE
iow_inspect(VALUE self)
{
    VALUE obj = (VALUE)DATA_PTR(self);
    VALUE type = type2sym(BUILTIN_TYPE(obj));

    return rb_sprintf("#<InternalObject:%p %s>", (void *)obj, rb_id2name(SYM2ID(type)));
}
开发者ID:Chatto,项目名称:VGdesk,代码行数:8,代码来源:objspace.c


示例13: esignal_init

static VALUE
esignal_init(int argc, VALUE *argv, VALUE self)
{
    int argnum = 1;
    VALUE sig = Qnil;
    int signo;
    const char *signm;

    if (argc > 0) {
	sig = rb_check_to_integer(argv[0], "to_int");
	if (!NIL_P(sig)) argnum = 2;
	else sig = argv[0];
    }
    rb_check_arity(argc, 1, argnum);
    if (argnum == 2) {
	signo = NUM2INT(sig);
	if (signo < 0 || signo > NSIG) {
	    rb_raise(rb_eArgError, "invalid signal number (%d)", signo);
	}
	if (argc > 1) {
	    sig = argv[1];
	}
	else {
	    signm = signo2signm(signo);
	    if (signm) {
		sig = rb_sprintf("SIG%s", signm);
	    }
	    else {
		sig = rb_sprintf("SIG%u", signo);
	    }
	}
    }
    else {
	signm = SYMBOL_P(sig) ? rb_id2name(SYM2ID(sig)) : StringValuePtr(sig);
	if (strncmp(signm, "SIG", 3) == 0) signm += 3;
	signo = signm2signo(signm);
	if (!signo) {
	    rb_raise(rb_eArgError, "unsupported name `SIG%s'", signm);
	}
	sig = rb_sprintf("SIG%s", signm);
    }
    rb_call_super(1, &sig);
    rb_iv_set(self, "signo", INT2NUM(signo));

    return self;
}
开发者ID:SongJungHwan,项目名称:hwan,代码行数:46,代码来源:signal.c


示例14: iow_inspect

/* See Object#inspect. */
static VALUE
iow_inspect(VALUE self)
{
    VALUE obj = (VALUE)DATA_PTR(self);
    VALUE type = type2sym(BUILTIN_TYPE(obj));

    return rb_sprintf("#<InternalObject:%p %"PRIsVALUE">", (void *)obj, rb_sym2str(type));
}
开发者ID:knugie,项目名称:ruby,代码行数:9,代码来源:objspace.c


示例15: rb_sprintf

// RenderTexture#inspect
// RenderTexture#to_s
VALUE rbRenderTexture::Inspect( VALUE aSelf )
{
    return rb_sprintf( "%s(%ix%i, %p)",
                       rb_obj_classname( aSelf ),
                       rbMacros::ToSFML< sf::RenderTexture >( aSelf, rbRenderTexture::Class )->getSize().x,
                       rbMacros::ToSFML< sf::RenderTexture >( aSelf, rbRenderTexture::Class )->getSize().y,
                       rbMacros::ToSFML< sf::RenderTexture >( aSelf, rbRenderTexture::Class ) );
}
开发者ID:paulas,项目名称:rbSFML,代码行数:10,代码来源:RenderTexture.cpp


示例16: showExc

static void showExc(VALUE exc, const BacktraceData &btData)
{
	VALUE bt = rb_funcall2(exc, rb_intern("backtrace"), 0, NULL);
	VALUE msg = rb_funcall2(exc, rb_intern("message"), 0, NULL);
	VALUE bt0 = rb_ary_entry(bt, 0);
	VALUE name = rb_class_path(rb_obj_class(exc));

	VALUE ds = rb_sprintf("%" PRIsVALUE ": %" PRIsVALUE " (%" PRIsVALUE ")",
	                      bt0, exc, name);
	/* omit "useless" last entry (from ruby:1:in `eval') */
	for (long i = 1, btlen = RARRAY_LEN(bt) - 1; i < btlen; ++i)
		rb_str_catf(ds, "\n\tfrom %" PRIsVALUE, rb_ary_entry(bt, i));
	Debug() << StringValueCStr(ds);

	char *s = RSTRING_PTR(bt0);

	char line[16];
	std::string file(512, '\0');

	char *p = s + strlen(s);
	char *e;

	while (p != s)
		if (*--p == ':')
			break;

	e = p;

	while (p != s)
		if (*--p == ':')
			break;

	/* s         p  e
	 * SectionXXX:YY: in 'blabla' */

	*e = '\0';
	strncpy(line, *p ? p+1 : p, sizeof(line));
	line[sizeof(line)-1] = '\0';
	*e = ':';
	e = p;

	/* s         e
	 * SectionXXX:YY: in 'blabla' */

	*e = '\0';
	strncpy(&file[0], s, file.size());
	*e = ':';

	/* Shrink to fit */
	file.resize(strlen(file.c_str()));
	file = btData.scriptNames.value(file, file);

	std::string ms(640, '\0');
	snprintf(&ms[0], ms.size(), "Script '%s' line %s: %s occured.\n\n%s",
	         file.c_str(), line, RSTRING_PTR(name), RSTRING_PTR(msg));

	showMsg(ms);
}
开发者ID:Ancurio,项目名称:mkxp-abs,代码行数:58,代码来源:binding-mri.cpp


示例17: enc_inspect

/*
 * call-seq:
 *   enc.inspect -> string
 *
 * Returns a string which represents the encoding for programmers.
 *
 *   Encoding::UTF_8.inspect       #=> "#<Encoding:UTF-8>"
 *   Encoding::ISO_2022_JP.inspect #=> "#<Encoding:ISO-2022-JP (dummy)>"
 */
static VALUE
enc_inspect(VALUE self)
{
    VALUE str = rb_sprintf("#<%s:%s%s>", rb_obj_classname(self),
		      rb_enc_name((rb_encoding*)DATA_PTR(self)),
		      (enc_dummy_p(self) ? " (dummy)" : ""));
    ENCODING_CODERANGE_SET(str, rb_usascii_encindex(), ENC_CODERANGE_7BIT);
    return str;
}
开发者ID:217,项目名称:ruby,代码行数:18,代码来源:encoding.c


示例18: ossl_engine_inspect

static VALUE
ossl_engine_inspect(VALUE self)
{
    ENGINE *e;

    GetEngine(self, e);
    return rb_sprintf("#<%"PRIsVALUE" id=\"%s\" name=\"%s\">",
		      RB_OBJ_CLASSNAME(self), ENGINE_get_id(e), ENGINE_get_name(e));
}
开发者ID:richo,项目名称:unrubby,代码行数:9,代码来源:ossl_engine.c


示例19: _inspect

/*
 * call-seq:
 *   inspect -> String
 *
 * Human-readable description.
 * ===Return value
 * String
*/
VALUE _inspect(VALUE self)
{
	rb_sprintf("%s(%f, %f, %f, %f)",
		rb_obj_classname(self),
		NUM2DBL(_get_left(self)),
		NUM2DBL(_get_top(self)),
		NUM2DBL(_get_width(self)),
		NUM2DBL(_get_height(self)));
}
开发者ID:Hanmac,项目名称:sfml-ruby,代码行数:17,代码来源:Rect.cpp


示例20: _inspect

/*
 * call-seq:
 *   inspect -> String
 *
 * Human-readable description.
 * ===Return value
 * String
*/
VALUE _inspect(VALUE self)
{
	return rb_sprintf( "%s(%i, %i, %i, %i)",
		rb_obj_classname( self ),
		FIX2INT(_get_r(self)),
		FIX2INT(_get_g(self)),
		FIX2INT(_get_b(self)),
		FIX2INT(_get_a(self)));
}
开发者ID:Hanmac,项目名称:sfml-ruby,代码行数:17,代码来源:Color.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ rb_str_append函数代码示例发布时间:2022-05-30
下一篇:
C++ rb_singleton_class函数代码示例发布时间: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