本文整理汇总了C++中rb_str_append函数的典型用法代码示例。如果您正苦于以下问题:C++ rb_str_append函数的具体用法?C++ rb_str_append怎么用?C++ rb_str_append使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rb_str_append函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: fc_path
static VALUE
fc_path(struct fc_result *fc, ID name)
{
VALUE path, tmp;
path = rb_str_dup(rb_id2str(name));
while (fc) {
st_data_t n;
if (fc->track == rb_cObject) break;
if (RCLASS_IV_TBL(fc->track) &&
st_lookup(RCLASS_IV_TBL(fc->track), (st_data_t)classpath, &n)) {
tmp = rb_str_dup((VALUE)n);
rb_str_cat2(tmp, "::");
rb_str_append(tmp, path);
path = tmp;
break;
}
tmp = rb_str_dup(rb_id2str(fc->name));
rb_str_cat2(tmp, "::");
rb_str_append(tmp, path);
path = tmp;
fc = fc->prev;
}
OBJ_FREEZE(path);
return path;
}
开发者ID:alexanderblair,项目名称:Gemdata,代码行数:26,代码来源:variable.c
示例2: Map_inspect
/*
* call-seq:
* Map.inspect => string
*
* Returns a string representing this map's elements. It will be formatted as
* "{key => value, key => value, ...}", with each key and value string
* representation computed by its own #inspect method.
*/
VALUE Map_inspect(VALUE _self) {
Map* self = ruby_to_Map(_self);
VALUE str = rb_str_new2("{");
bool first = true;
VALUE inspect_sym = rb_intern("inspect");
upb_strtable_iter it;
for (upb_strtable_begin(&it, &self->table);
!upb_strtable_done(&it);
upb_strtable_next(&it)) {
VALUE key = table_key_to_ruby(
self, upb_strtable_iter_key(&it), upb_strtable_iter_keylength(&it));
upb_value v = upb_strtable_iter_value(&it);
void* mem = value_memory(&v);
VALUE value = native_slot_get(self->value_type,
self->value_type_class,
mem);
if (!first) {
str = rb_str_cat2(str, ", ");
} else {
first = false;
}
str = rb_str_append(str, rb_funcall(key, inspect_sym, 0));
str = rb_str_cat2(str, "=>");
str = rb_str_append(str, rb_funcall(value, inspect_sym, 0));
}
str = rb_str_cat2(str, "}");
return str;
}
开发者ID:Livefyre,项目名称:protobuf,代码行数:42,代码来源:map.c
示例3: shoes_http_headers
SHOES_DOWNLOAD_HEADERS
shoes_http_headers(VALUE hsh)
{
long i;
LPWSTR hdrs = NULL;
VALUE keys = rb_funcall(hsh, s_keys, 0);
if (RARRAY_LEN(keys) > 0)
{
VALUE headers = rb_str_new2("");
//for (i = 0; i < RARRAY(keys)->as.heap.len; i++ )
for (i = 0; i < RARRAY_LEN(keys); i++ )
{
VALUE key = rb_ary_entry(keys, i);
rb_str_append(headers, key);
rb_str_cat2(headers, ": ");
rb_str_append(headers, rb_hash_aref(hsh, key));
rb_str_cat2(headers, "\n");
}
hdrs = SHOE_ALLOC_N(WCHAR, RSTRING_LEN(headers) + 1);
SHOE_MEMZERO(hdrs, WCHAR, RSTRING_LEN(headers) + 1);
MultiByteToWideChar(CP_UTF8, 0, RSTRING_PTR(headers), -1, hdrs, RSTRING_LEN(headers) + 1);
}
return hdrs;
}
开发者ID:kannans,项目名称:shoes,代码行数:25,代码来源:windownload.c
示例4: figure_singleton_name
/* ================ Helper Functions =================*/
static VALUE
figure_singleton_name(VALUE klass)
{
VALUE result = Qnil;
/* We have come across a singleton object. First
figure out what it is attached to.*/
VALUE attached = rb_iv_get(klass, "__attached__");
/* Is this a singleton class acting as a metaclass? */
if (BUILTIN_TYPE(attached) == T_CLASS)
{
result = rb_str_new2("<Class::");
rb_str_append(result, rb_inspect(attached));
rb_str_cat2(result, ">");
}
/* Is this for singleton methods on a module? */
else if (BUILTIN_TYPE(attached) == T_MODULE)
{
result = rb_str_new2("<Module::");
rb_str_append(result, rb_inspect(attached));
rb_str_cat2(result, ">");
}
/* Is this for singleton methods on an object? */
else if (BUILTIN_TYPE(attached) == T_OBJECT)
{
/* Make sure to get the super class so that we don't
mistakenly grab a T_ICLASS which would lead to
unknown method errors. */
#ifdef HAVE_RB_CLASS_SUPERCLASS
// 1.9.3
VALUE super = rb_class_superclass(klass);
#else
# ifdef RCLASS_SUPER
VALUE super = rb_class_real(RCLASS_SUPER(klass));
# else
VALUE super = rb_class_real(RCLASS(klass)->super);
# endif
#endif
result = rb_str_new2("<Object::");
rb_str_append(result, rb_inspect(super));
rb_str_cat2(result, ">");
}
/* Ok, this could be other things like an array made put onto
a singleton object (yeah, it happens, see the singleton
objects test case). */
else
{
result = rb_inspect(klass);
}
return result;
}
开发者ID:jokester01au,项目名称:GetUpQuiz,代码行数:57,代码来源:ruby_prof.c
示例5: mArray_json_transfrom
inline static VALUE mArray_json_transfrom(VALUE self, VALUE Vstate, VALUE Vdepth) {
long i, len = RARRAY_LEN(self);
VALUE shift, result;
long depth = NIL_P(Vdepth) ? 0 : FIX2LONG(Vdepth);
VALUE delim = rb_str_new2(",");
GET_STATE(Vstate);
if (state->check_circular) {
VALUE self_id = rb_obj_id(self);
rb_hash_aset(state->seen, self_id, Qtrue);
result = rb_str_buf_new(len);
if (RSTRING_LEN(state->array_nl)) rb_str_append(delim, state->array_nl);
shift = rb_str_times(state->indent, LONG2FIX(depth + 1));
rb_str_buf_cat2(result, "[");
rb_str_buf_append(result, state->array_nl);
for (i = 0; i < len; i++) {
VALUE element = RARRAY_PTR(self)[i];
if (RTEST(rb_hash_aref(state->seen, rb_obj_id(element)))) {
rb_raise(eCircularDatastructure,
"circular data structures not supported!");
}
OBJ_INFECT(result, element);
if (i > 0) rb_str_buf_append(result, delim);
rb_str_buf_append(result, shift);
rb_str_buf_append(result, rb_funcall(element, i_to_json, 2, Vstate, LONG2FIX(depth + 1)));
}
if (RSTRING_LEN(state->array_nl)) {
rb_str_buf_append(result, state->array_nl);
rb_str_buf_append(result, rb_str_times(state->indent, LONG2FIX(depth)));
}
rb_str_buf_cat2(result, "]");
rb_hash_delete(state->seen, self_id);
} else {
result = rb_str_buf_new(len);
if (RSTRING_LEN(state->array_nl)) rb_str_append(delim, state->array_nl);
shift = rb_str_times(state->indent, LONG2FIX(depth + 1));
rb_str_buf_cat2(result, "[");
rb_str_buf_append(result, state->array_nl);
for (i = 0; i < len; i++) {
VALUE element = RARRAY_PTR(self)[i];
OBJ_INFECT(result, element);
if (i > 0) rb_str_buf_append(result, delim);
rb_str_buf_append(result, shift);
rb_str_buf_append(result, rb_funcall(element, i_to_json, 2, Vstate, LONG2FIX(depth + 1)));
}
rb_str_buf_append(result, state->array_nl);
if (RSTRING_LEN(state->array_nl)) {
rb_str_buf_append(result, rb_str_times(state->indent, LONG2FIX(depth)));
}
rb_str_buf_cat2(result, "]");
}
return result;
}
开发者ID:gingerhendrix,项目名称:tagulus,代码行数:55,代码来源:generator.c
示例6: buffered_file_read
/* Read using an internal buffer to avoid system calls */
static VALUE buffered_file_read(VALUE self, VALUE arg_length) {
long length = FIX2INT(arg_length);
VALUE buffer = rb_ivar_get(self, id_ivar_buffer);
long buffer_length = RSTRING_LEN(buffer);
long buffer_index = FIX2INT(rb_ivar_get(self, id_ivar_buffer_index));
VALUE result = Qnil;
VALUE super_arg = Qnil;
if (length <= (buffer_length - buffer_index)) {
/* Return part of the buffer without having to go to the OS */
result = rb_str_substr(buffer, buffer_index, length);
buffer_index += length;
rb_ivar_set(self, id_ivar_buffer_index, INT2FIX(buffer_index));
return result;
} else if (length > BUFFER_SIZE) {
/* Reading more than our buffer */
if (buffer_length > 0) {
if (buffer_index > 0) {
rb_funcall(buffer, id_method_slice_bang, 1, rb_range_new(INT2FIX(0), INT2FIX(buffer_index - 1), Qfalse));
buffer_length = RSTRING_LEN(buffer);
buffer_index = 0;
rb_ivar_set(self, id_ivar_buffer_index, INT2FIX(0));
}
super_arg = INT2FIX(length - buffer_length);
rb_str_append(buffer, rb_funcall(rb_call_super(1, &super_arg), id_method_to_s, 0));
return rb_funcall(buffer, id_method_slice_bang, 1, rb_const_get(cBufferedFile, id_const_ALL_RANGE));
} else {
return rb_call_super(1, &arg_length);
}
} else {
/* Read into the buffer */
if (buffer_index > 0) {
rb_funcall(buffer, id_method_slice_bang, 1, rb_range_new(INT2FIX(0), INT2FIX(buffer_index - 1), Qfalse));
buffer_length = RSTRING_LEN(buffer);
buffer_index = 0;
rb_ivar_set(self, id_ivar_buffer_index, INT2FIX(0));
}
super_arg = INT2FIX(BUFFER_SIZE - buffer_length);
rb_str_append(buffer, rb_funcall(rb_call_super(1, &super_arg), id_method_to_s, 0));
buffer_length = RSTRING_LEN(buffer);
if (buffer_length <= 0) {
return Qnil;
}
if (length <= buffer_length) {
result = rb_str_substr(buffer, buffer_index, length);
buffer_index += length;
rb_ivar_set(self, id_ivar_buffer_index, INT2FIX(buffer_index));
return result;
} else {
return rb_funcall(buffer, id_method_slice_bang, 1, rb_const_get(cBufferedFile, id_const_ALL_RANGE));
}
}
}
开发者ID:WEST3357,项目名称:COSMOS,代码行数:55,代码来源:buffered_file.c
示例7: Message_inspect
/*
* call-seq:
* Message.inspect => string
*
* Returns a human-readable string representing this message. It will be
* formatted as "<MessageType: field1: value1, field2: value2, ...>". Each
* field's value is represented according to its own #inspect method.
*/
VALUE Message_inspect(VALUE _self) {
MessageHeader* self;
TypedData_Get_Struct(_self, MessageHeader, &Message_type, self);
VALUE str = rb_str_new2("<");
str = rb_str_append(str, rb_str_new2(rb_class2name(CLASS_OF(_self))));
str = rb_str_cat2(str, ": ");
str = rb_str_append(str, layout_inspect(
self->descriptor->layout, Message_data(self)));
str = rb_str_cat2(str, ">");
return str;
}
开发者ID:goodleon,项目名称:protobuf,代码行数:20,代码来源:message.c
示例8: munge_xpath_namespace
VALUE munge_xpath_namespace( VALUE orig_expr, xmlChar *root_ns )
{
VALUE path_bits = rb_str_split( orig_expr, "/" );
VALUE ns_prefix = rb_str_new2( (const char*)root_ns );
VALUE ns_indic = rb_str_new2( ":" );
VALUE slash = rb_str_new2( "/" );
VALUE path_bit, str_idx;
VALUE ret_ary = rb_ary_new();
long i;
rb_str_append( ns_prefix, ns_indic );
for (i=0; i<RARRAY(path_bits)->len; i++) {
path_bit = RARRAY(path_bits)->ptr[i];
if (RSTRING_LEN(path_bit) > 0) {
str_idx = rb_funcall( path_bit, rb_intern( "index" ), 1, ns_indic );
if (str_idx == Qnil || str_idx == Qfalse) // didn't find the :, so it looks like we don't have a namespace
path_bit = rb_str_plus( ns_prefix, path_bit );
}
rb_ary_push( ret_ary, path_bit );
}
return rb_ary_join( ret_ary, slash );
}
开发者ID:segfault,项目名称:fastxml,代码行数:25,代码来源:fastxml.c
示例9: compile_err_append
static void
compile_err_append(VALUE mesg)
{
rb_thread_t *th = GET_THREAD();
VALUE err = th->errinfo;
rb_block_t *prev_base_block = th->base_block;
th->base_block = 0;
/* base_block should be zero while normal Ruby execution */
/* after this line, any Ruby code *can* run */
if (th->mild_compile_error) {
if (RTEST(err)) {
VALUE str = rb_obj_as_string(err);
rb_str_cat2(str, "\n");
rb_str_append(str, mesg);
mesg = str;
}
err = rb_exc_new3(rb_eSyntaxError, mesg);
th->errinfo = err;
}
else {
if (!RTEST(err)) {
err = rb_exc_new2(rb_eSyntaxError, "compile error");
th->errinfo = err;
}
rb_str_cat2(mesg, "\n");
rb_write_error_str(mesg);
}
/* returned to the parser world */
th->base_block = prev_base_block;
}
开发者ID:knugie,项目名称:ruby,代码行数:33,代码来源:error.c
示例10: ossl_sslctx_set_ciphers
/*
* call-seq:
* ctx.ciphers = "cipher1:cipher2:..."
* ctx.ciphers = [name, ...]
* ctx.ciphers = [[name, version, bits, alg_bits], ...]
*/
static VALUE
ossl_sslctx_set_ciphers(VALUE self, VALUE v)
{
SSL_CTX *ctx;
VALUE str, elem;
int i;
rb_check_frozen(self);
if (NIL_P(v))
return v;
else if (TYPE(v) == T_ARRAY) {
str = rb_str_new(0, 0);
for (i = 0; i < RARRAY_LEN(v); i++) {
elem = rb_ary_entry(v, i);
if (TYPE(elem) == T_ARRAY) elem = rb_ary_entry(elem, 0);
elem = rb_String(elem);
rb_str_append(str, elem);
if (i < RARRAY_LEN(v)-1) rb_str_cat2(str, ":");
}
} else {
str = v;
StringValue(str);
}
Data_Get_Struct(self, SSL_CTX, ctx);
if(!ctx){
ossl_raise(eSSLError, "SSL_CTX is not initialized.");
return Qnil;
}
if (!SSL_CTX_set_cipher_list(ctx, RSTRING_PTR(str))) {
ossl_raise(eSSLError, "SSL_CTX_set_cipher_list:");
}
return v;
}
开发者ID:2220142,项目名称:ruby,代码行数:41,代码来源:ossl_ssl.c
示例11: oci8_get_error_message
VALUE oci8_get_error_message(ub4 msgno, const char *default_msg)
{
char head[32];
size_t headsz;
const char *errmsg = NULL;
char msgbuf[64];
if (have_OCIMessageGet) {
if (msghp == NULL) {
chkerr(OCIMessageOpen(oci8_envhp, oci8_errhp, &msghp, TO_CONST_ORATEXT("rdbms"), TO_CONST_ORATEXT("ora"), OCI_DURATION_PROCESS));
}
errmsg = TO_CHARPTR(OCIMessageGet(msghp, msgno, NULL, 0));
}
if (errmsg == NULL) {
if (default_msg != NULL) {
errmsg = default_msg;
} else {
/* last resort */
snprintf(msgbuf, sizeof(msgbuf), "Message %u not found; product=rdbms; facility=ora", msgno);
errmsg = msgbuf;
}
}
headsz = snprintf(head, sizeof(head), "ORA-%05u: ", msgno);
return rb_str_append(rb_usascii_str_new(head, headsz),
rb_external_str_new_with_enc(errmsg, strlen(errmsg), oci8_encoding));
}
开发者ID:afterthought,项目名称:ruby-oci8,代码行数:26,代码来源:error.c
示例12: load_failed
static void
load_failed(VALUE fname)
{
VALUE mesg = rb_str_buf_new_cstr("cannot load such file -- ");
rb_str_append(mesg, fname); /* should be ASCII compatible */
rb_exc_raise(rb_exc_new3(rb_eLoadError, mesg));
}
开发者ID:Subv,项目名称:Ruby-Impl,代码行数:7,代码来源:load.c
示例13: ossl_engine_inspect
static VALUE
ossl_engine_inspect(VALUE self)
{
VALUE str;
const char *cname = rb_class2name(rb_obj_class(self));
str = rb_str_new2("#<");
rb_str_cat2(str, cname);
rb_str_cat2(str, " id=\"");
rb_str_append(str, ossl_engine_get_id(self));
rb_str_cat2(str, "\" name=\"");
rb_str_append(str, ossl_engine_get_name(self));
rb_str_cat2(str, "\">");
return str;
}
开发者ID:Emily,项目名称:rubinius,代码行数:16,代码来源:ossl_engine.c
示例14: rb_load_fail
void
rb_load_fail(VALUE path, const char *err)
{
VALUE mesg = rb_str_buf_new_cstr(err);
rb_str_cat2(mesg, " -- ");
rb_str_append(mesg, path); /* should be ASCII compatible */
raise_loaderror(path, mesg);
}
开发者ID:knugie,项目名称:ruby,代码行数:8,代码来源:error.c
示例15: full_name
static VALUE
full_name(VALUE klass, ID mid)
{
VALUE result = klass_name(klass);
rb_str_cat2(result, "#");
rb_str_append(result, method_name(mid));
return result;
}
开发者ID:skaes,项目名称:ruby-prof-obsolete,代码行数:8,代码来源:ruby_prof.c
示例16: inspect_struct
static VALUE
inspect_struct(VALUE s, VALUE dummy, int recur)
{
VALUE cname = rb_class_name(rb_obj_class(s));
VALUE members, str = rb_str_new2("#<struct ");
VALUE *ptr, *ptr_members;
long i, len;
char first = RSTRING_PTR(cname)[0];
if (recur || first != '#') {
rb_str_append(str, cname);
}
if (recur) {
return rb_str_cat2(str, ":...>");
}
members = rb_struct_members(s);
ptr_members = RARRAY_PTR(members);
ptr = RSTRUCT_PTR(s);
len = RSTRUCT_LEN(s);
for (i=0; i<len; i++) {
VALUE slot;
ID id;
if (i > 0) {
rb_str_cat2(str, ", ");
}
else if (first != '#') {
rb_str_cat2(str, " ");
}
slot = ptr_members[i];
id = SYM2ID(slot);
if (rb_is_local_id(id) || rb_is_const_id(id)) {
rb_str_append(str, rb_id2str(id));
}
else {
rb_str_append(str, rb_inspect(slot));
}
rb_str_cat2(str, "=");
rb_str_append(str, rb_inspect(ptr[i]));
}
rb_str_cat2(str, ">");
OBJ_INFECT(str, s);
return str;
}
开发者ID:Chatto,项目名称:VGdesk,代码行数:46,代码来源:struct.c
示例17: join_der_i
static VALUE
join_der_i(VALUE i, VALUE str)
{
i = ossl_to_der_if_possible(i);
StringValue(i);
rb_str_append(str, i);
return Qnil;
}
开发者ID:DocPsy,项目名称:MacRuby,代码行数:8,代码来源:ossl_asn1.c
示例18: rb_str_to_pas
VALUE rb_str_to_pas(VALUE str) {
VALUE str2;
char slen[2];
slen[0] = RSTRING_LEN(str);
slen[1] = '\0';
str2 = rb_str_new2(slen);
rb_str_append(str2, str);
return str2;
}
开发者ID:Shoes3,项目名称:shoes3,代码行数:9,代码来源:ruby.c
示例19: rb_xthread_fifo_inspect
VALUE
rb_xthread_fifo_inspect(VALUE self)
{
xthread_fifo_t *fifo;
VALUE str;
GetXThreadFifoPtr(self, fifo);
str = rb_sprintf("<%s ", rb_obj_classname(self), (void*)self);
rb_str_append(str, rb_inspect(rb_xthread_fifo_to_a(self)));
rb_str_cat2(str, ">");
return str;
}
开发者ID:keiju,项目名称:xthread,代码行数:13,代码来源:fifo.c
示例20: range_to_s
static VALUE
range_to_s(VALUE range, SEL sel)
{
VALUE str, str2;
str = rb_obj_as_string(RANGE_BEG(range));
str2 = rb_obj_as_string(RANGE_END(range));
str = rb_str_dup(str);
rb_str_cat(str, "...", EXCL(range) ? 3 : 2);
rb_str_append(str, str2);
OBJ_INFECT(str, str2);
return str;
}
开发者ID:HumbleRepose,项目名称:MacRuby,代码行数:14,代码来源:range.c
注:本文中的rb_str_append函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论