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


C++ rb_str_concat函数代码示例

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


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

示例1: rb_trie_save

/*
 * call-seq:
 *   save(filename_base) -> true
 *
 * Saves the trie data to two files, filename_base.da and filename_base.tail.
 * Returns true if saving was successful.
 */
static VALUE rb_trie_save(VALUE self, VALUE filename_base) {
  VALUE da_filename = rb_str_dup(filename_base);
  rb_str_concat(da_filename, rb_str_new2(".da"));
  StringValue(da_filename);
    
  VALUE tail_filename = rb_str_dup(filename_base);
  rb_str_concat(tail_filename, rb_str_new2(".tail"));
  StringValue(tail_filename);

  Trie *trie;
  Data_Get_Struct(self, Trie, trie);

  FILE *da_file = fopen(RSTRING_PTR(da_filename), "w");
  if (da_file == NULL)
    raise_ioerror("Error opening .da file for writing.");
  if (da_write(trie->da, da_file) != 0)
    raise_ioerror("Error writing DArray data.");
  fclose(da_file);

  FILE *tail_file = fopen(RSTRING_PTR(tail_filename), "w");
  if (tail_file == NULL)
    raise_ioerror("Error opening .tail file for writing.");
  if (tail_write(trie->tail, tail_file) != 0)
    raise_ioerror("Error writing Tail data.");
  fclose(tail_file);

  return Qtrue;
}
开发者ID:kritik,项目名称:trie,代码行数:35,代码来源:trie.c

示例2: rb_rsvg_dim_to_s

static VALUE
rb_rsvg_dim_to_s(VALUE self)
{
    VALUE ret;

    ret = rb_str_new2("#<");
    rb_str_cat2(ret, rb_obj_classname(self));
    rb_str_cat2(ret, ":");
    rb_str_concat(ret, rb_funcall(INT2NUM(self), id_to_s, 0));
    rb_str_cat2(ret, " ");

    rb_str_cat2(ret, "width=");
    rb_str_concat(ret, to_s(rb_rsvg_dim_get_width(self)));
    rb_str_cat2(ret, ", ");
    rb_str_cat2(ret, "height=");
    rb_str_concat(ret, to_s(rb_rsvg_dim_get_height(self)));
    rb_str_cat2(ret, ", ");
    rb_str_cat2(ret, "em=");
    rb_str_concat(ret, to_s(rb_rsvg_dim_get_em(self)));
    rb_str_cat2(ret, ", ");
    rb_str_cat2(ret, "ex=");
    rb_str_concat(ret, to_s(rb_rsvg_dim_get_ex(self)));
    rb_str_cat2(ret, ">");

    return ret;
}
开发者ID:benolee,项目名称:ruby-gnome2,代码行数:26,代码来源:rbrsvg.c

示例3: pq_node2dot

// Dot a single node of a priority queue. Called by pq_to_dot to do the inner work.
// (I'm not proud of this function ;-( )
static
void pq_node2dot(VALUE result_string, priority_node* n, unsigned int level) {
  if (n == NULL) return;  
  unsigned int i;
  for (i=0; i<level; i++) rb_str_cat2(result_string, "  ");  
  if (n->mark)
    rb_str_concat(result_string,
	rb_funcall(Qnil, id_format, 4, rb_str_new2("NODE%i [label=\"%s (%s)\"];\n"), 
	  ULONG2NUM((unsigned long) n), n->object, n->priority));
  else
    rb_str_concat(result_string,
	rb_funcall(Qnil, id_format, 4, rb_str_new2("NODE%i [label=\"%s (%s)\",shape=box];\n"), 
	  ULONG2NUM((unsigned long) n), n->object, n->priority));
  if (n->child != NULL) {
    priority_node* n1 = n->child;
    do {
      pq_node2dot(result_string, n1, level + 1);
      for (i=0; i<level; i++) rb_str_cat2(result_string, "  ");  
      rb_str_concat(result_string,
	  rb_funcall(Qnil, id_format, 4, rb_str_new2("NODE%i -> NODE%i;\n"), 
	    ULONG2NUM((unsigned long) n), ULONG2NUM((unsigned long) n1)));
      n1 = n1->right;
    } while(n1 != n->child);
  }
}
开发者ID:J-Y,项目名称:RubyQuiz,代码行数:27,代码来源:priority_queue.c

示例4: rb_grn_context_inspect

/*
 * call-seq:
 *   context.inspect -> String
 *
 * コンテキストの中身を人に見やすい文字列で返す。
 */
static VALUE
rb_grn_context_inspect (VALUE self)
{
    VALUE inspected;
    grn_ctx *context;
    grn_obj *database;
    VALUE rb_database;

    context = SELF(self);

    inspected = rb_str_new2("#<");
    rb_str_concat(inspected, rb_inspect(rb_obj_class(self)));
    rb_str_cat2(inspected, " ");

    rb_str_cat2(inspected, "encoding: <");
    rb_str_concat(inspected, rb_inspect(GRNENCODING2RVAL(context->encoding)));
    rb_str_cat2(inspected, ">, ");

    rb_str_cat2(inspected, "database: <");
    database = grn_ctx_db(context);
    rb_database = GRNDB2RVAL(context, database, RB_GRN_FALSE);
    rb_str_concat(inspected, rb_inspect(rb_database));
    rb_str_cat2(inspected, ">");

    rb_str_cat2(inspected, ">");
    return inspected;
}
开发者ID:nobu,项目名称:rroonga,代码行数:33,代码来源:rb-grn-context.c

示例5: oletypelib_path

static VALUE
oletypelib_path(VALUE guid, VALUE version)
{
    int k;
    LONG err;
    HKEY hkey;
    HKEY hlang;
    VALUE lang;
    VALUE path = Qnil;

    VALUE key = rb_str_new2("TypeLib\\");
    rb_str_concat(key, guid);
    rb_str_cat2(key, "\\");
    rb_str_concat(key, version);

    err = reg_open_vkey(HKEY_CLASSES_ROOT, key, &hkey);
    if (err != ERROR_SUCCESS) {
        return Qnil;
    }
    for(k = 0; path == Qnil; k++) {
        lang = reg_enum_key(hkey, k);
        if (lang == Qnil)
            break;
        err = reg_open_vkey(hkey, lang, &hlang);
        if (err == ERROR_SUCCESS) {
            path = reg_get_typelib_file_path(hlang);
            RegCloseKey(hlang);
        }
    }
    RegCloseKey(hkey);
    return path;
}
开发者ID:DashYang,项目名称:sim,代码行数:32,代码来源:win32ole_typelib.c

示例6: rb_trie_read

/*
 * call-seq:
 *   read(filename_base) -> Trie
 *
 * Returns a new trie with data as read from disk.
 */
static VALUE rb_trie_read(VALUE self, VALUE filename_base) {
	VALUE da_filename = rb_str_dup(filename_base);
	VALUE tail_filename = rb_str_dup(filename_base);
	rb_str_concat(da_filename, rb_str_new2(".da"));
	rb_str_concat(tail_filename, rb_str_new2(".tail"));
	StringValue(tail_filename);
    StringValue(da_filename);
	Trie *trie = trie_new();

	VALUE obj;
	obj = Data_Wrap_Struct(self, 0, trie_free, trie);

	DArray *old_da = trie->da;
	Tail *old_tail = trie->tail;

	FILE *da_file = fopen(RSTRING_PTR(da_filename), "r");
	if (da_file == NULL)
		raise_ioerror("Error reading .da file.");

	trie->da = da_read(da_file);
	fclose(da_file);

	FILE *tail_file = fopen(RSTRING_PTR(tail_filename), "r");
	if (tail_file == NULL)
		raise_ioerror("Error reading .tail file.");

	trie->tail = tail_read(tail_file);
	fclose(tail_file);

	da_free(old_da);
	tail_free(old_tail);

	return obj;
}
开发者ID:witgo,项目名称:fast_trie,代码行数:40,代码来源:trie.c

示例7: rb_gsl_rational_inspect

static VALUE rb_gsl_rational_inspect(VALUE obj)
{
  VALUE str;
  str = rb_str_new2(rb_class2name(CLASS_OF(obj)));
  rb_str_concat(str, rb_str_new2("\n"));
  rb_str_concat(str, rb_gsl_rational_to_s(obj));
  return str;
}
开发者ID:AbhimanyuAryan,项目名称:rb-gsl,代码行数:8,代码来源:rational.c

示例8: dh_quote

static VALUE dh_quote(VALUE self, VALUE string2quote)
{
 /*
  This quoting-stuff is _very_ basic and probably needs *some* work.
 */
 VALUE quotedStr = rb_funcall(string2quote, rb_intern("gsub"), 2, rb_reg_new("'", 1, 0), rb_str_new2("''"));
 
 return  rb_str_concat(rb_str_concat(rb_str_new2("'"), quotedStr), rb_str_new2("'"));
} // dh_quote
开发者ID:joegen,项目名称:sipx-externals,代码行数:9,代码来源:dbd_sybase.c

示例9: inspect_enumerator

static VALUE
inspect_enumerator(VALUE obj, VALUE dummy, int recur)
{
    struct enumerator *e;
    const char *cname;
    VALUE eobj, str;
    int tainted, untrusted;

    TypedData_Get_Struct(obj, struct enumerator, &enumerator_data_type, e);

    cname = rb_obj_classname(obj);

    if (!e || e->obj == Qundef) {
	return rb_sprintf("#<%s: uninitialized>", cname);
    }

    if (recur) {
	str = rb_sprintf("#<%s: ...>", cname);
	OBJ_TAINT(str);
	return str;
    }

    eobj = e->obj;

    tainted   = OBJ_TAINTED(eobj);
    untrusted = OBJ_UNTRUSTED(eobj);

    /* (1..100).each_cons(2) => "#<Enumerator: 1..100:each_cons(2)>" */
    str = rb_sprintf("#<%s: ", cname);
    rb_str_concat(str, rb_inspect(eobj));
    rb_str_buf_cat2(str, ":");
    rb_str_buf_cat2(str, rb_id2name(e->meth));

    if (e->args) {
	long   argc = RARRAY_LEN(e->args);
	VALUE *argv = RARRAY_PTR(e->args);

	rb_str_buf_cat2(str, "(");

	while (argc--) {
	    VALUE arg = *argv++;

	    rb_str_concat(str, rb_inspect(arg));
	    rb_str_buf_cat2(str, argc > 0 ? ", " : ")");

	    if (OBJ_TAINTED(arg)) tainted = TRUE;
	    if (OBJ_UNTRUSTED(arg)) untrusted = TRUE;
	}
    }

    rb_str_buf_cat2(str, ">");

    if (tainted) OBJ_TAINT(str);
    if (untrusted) OBJ_UNTRUST(str);
    return str;
}
开发者ID:amtep,项目名称:ruby,代码行数:56,代码来源:enumerator.c

示例10: rb_gsl_rational_to_s

static VALUE rb_gsl_rational_to_s(VALUE obj)
{
  gsl_rational *r = NULL;
  VALUE str;
  Data_Get_Struct(obj, gsl_rational, r);
  str = rb_gsl_vector_to_s(r->num);
  rb_str_concat(str, rb_str_new2("\n"));
  rb_str_concat(str, rb_gsl_vector_to_s(r->den));
  return str;
}
开发者ID:AbhimanyuAryan,项目名称:rb-gsl,代码行数:10,代码来源:rational.c

示例11: rsym_inspect

static VALUE
rsym_inspect(VALUE sym, SEL sel)
{
    VALUE str = rb_str_new2(":");
    if (sym_should_be_escaped(sym)) {
	rb_str_concat(str, rb_str_inspect(RSYM(sym)->str));
    }
    else {
	rb_str_concat(str, RSYM(sym)->str);
    }
    return str;
}
开发者ID:Hunter-Dolan,项目名称:MacRuby,代码行数:12,代码来源:symbol.c

示例12: db_s_init

/*
 * Initialize the package database
 * The database {RPM::DB#root} / var / lib /rpm is created.
 *
 * @param [String] root Root of the database
 * @param [Boolean] writable Whether the database is writable. Default +false+.
 */
static VALUE
db_s_init(int argc, VALUE* argv, VALUE obj)
{
	int writable = 0;
	const char* root;

	switch (argc) {
	case 0:
		rb_raise(rb_eArgError, "too few argument(1..2)");

	case 1: case 2:
		if (TYPE(argv[0]) != T_STRING) {
			rb_raise(rb_eTypeError, "illegal argument type");
		}
		root = RSTRING_PTR(argv[0]);
		if (argc == 2) {
			writable = RTEST(argv[1]);
		}
		break;

	default:
		rb_raise(rb_eArgError, "too many argument(1..2)");
	}

	if (rpmdbInit(root, writable ? O_RDWR | O_CREAT : O_RDONLY)) {
		rb_raise(rb_eRuntimeError, "can not initialize database in %s",
				 RSTRING_PTR(rb_str_concat(rb_str_new2(root),
									   rb_str_new2("/var/lib/rpm"))));
	}

	return Qnil;
}
开发者ID:basecamp,项目名称:ruby-rpm,代码行数:39,代码来源:db.c

示例13: string_spec_RSTRING_ptr_assign_call

VALUE string_spec_RSTRING_ptr_assign_call(VALUE self, VALUE str) {
  char *ptr = RSTRING(str)->ptr;

  ptr[1] = 'x';
  rb_str_concat(str, rb_str_new2("d"));
  return str;
}
开发者ID:kstephens,项目名称:rubyspec,代码行数:7,代码来源:string_spec.c

示例14: string_spec_rb_str_ptr_readonly_append

VALUE string_spec_rb_str_ptr_readonly_append(VALUE self, VALUE str, VALUE more) {
  char *ptr = rb_str_ptr_readonly(str);

  rb_str_concat(str, more);

  return rb_str_new2(ptr);
}
开发者ID:kstephens,项目名称:rubyspec,代码行数:7,代码来源:string_spec.c

示例15: string_spec_rb_str_ptr_assign_call

VALUE string_spec_rb_str_ptr_assign_call(VALUE self, VALUE str) {
  char *ptr = rb_str_ptr(str);

  ptr[1] = 'x';
  rb_str_concat(str, rb_str_new2("d"));
  return str;
}
开发者ID:kstephens,项目名称:rubyspec,代码行数:7,代码来源:string_spec.c


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