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


C++ erl_format函数代码示例

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


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

示例1: term_sequence_test

static int term_sequence_test(IC_Env *env)
{
    ETERM* et_array[4] = {
	erl_format("[{apa, 1, 23}, \"string\", {1.23, 45}]"),
	erl_format("[{banan, 1, 23}, \"string\", {1.23, 45}]"),
	erl_format("[{apelsin, 1, 23}, \"string\", {1.23, 45}]"),
	erl_format("[{mango, 1, 23}, \"string\", {1.23, 45}]")};
    m_etseq etsi = {4, 4, et_array}, *etso, *etsr;

    fprintf(stdout, "\n======== m_i_term_sequence test ======\n\n");
    etsr = m_i_term_sequence_test(NULL, &etsi, &etso, env);
    CHECK_EXCEPTION(env);
    RETURN_IF_OK(cmp_etseq(&etsi, etso) && cmp_etseq(&etsi, etsr));
    if (!cmp_etseq(&etsi, etso)) {
	fprintf(stdout, " out parameter error, sent:\n");
	print_etseq(&etsi);
	fprintf(stdout, "got:\n");
	print_etseq(etso);
    }
    if (!cmp_etseq(&etsi, etsr)) {
	fprintf(stdout, " result error, sent:\n");
	print_etseq(&etsi);
	fprintf(stdout, "got:\n");
	print_etseq(etsr);
    }
    free_etseq_buf(&etsi);
    free_etseq_buf(etso);
    free_etseq_buf(etsr);
    CORBA_free(etso);
    CORBA_free(etsr);
    return -1;
}
开发者ID:3112517927,项目名称:otp,代码行数:32,代码来源:c_client.c

示例2: new_image_blank

ETERM * new_image_blank(ETERM *arg, int c_node) { 
    int stride, cbufsize, status, key_length;
    ETERM *width, *height;
    cairo_context *ctx = NULL;             
    width = erl_element(1, arg);
    height = erl_element(2, arg);
    stride = ERL_INT_VALUE(width) * 4;
    cbufsize = ERL_INT_VALUE(height) * stride;
    ctx = malloc(sizeof(cairo_context));
    if (ctx) {
        ctx->cbuf = (byte *)malloc(cbufsize);
        if (ctx->cbuf) {
            memset(ctx->cbuf, 0, cbufsize);
            ctx->sf = cairo_image_surface_create_for_data(ctx->cbuf, 
                    CAIRO_FORMAT_ARGB32, ERL_INT_VALUE(width), 
                    ERL_INT_VALUE(height), stride);
            ctx->cr = cairo_create(ctx->sf);
            return erl_format("{c_node, ~i, {ok, ~i}}", c_node, ctx);
        } else {
            free(ctx);
            return erl_format("{c_node, ~i, {error, '~s'}}", c_node, ERR_CONTEXT);
        }
    } else {
        return erl_format("{c_node, ~i, {error, '~s'}}", c_node, ERR_CONTEXT);
    }
    erl_free_term(width);
    erl_free_term(height);
}
开发者ID:chinnurtb,项目名称:erlycairo,代码行数:28,代码来源:erlycairo.c

示例3: handle_last

void
handle_last(ETERM *msg)
{
  ETERM *ecols, *erows, *resp;

  if (results == NULL) {
    resp = erl_format("{error, result_set_does_not_exist}");
    write_msg(resp);
    erl_free_term(resp);

    return;
  }

  mysql_stmt_data_seek(sth, numrows - 1);
  resultoffset = numrows;

  ecols = make_cols();
  erows = make_rows(1);
  resp = erl_format("{selected, ~w, ~w}", ecols, erows);
  erl_free_term(erows);

  erl_free_term(ecols);
  write_msg(resp);
  erl_free_term(resp);
}
开发者ID:bjc,项目名称:mysqlerl,代码行数:25,代码来源:mysqlerl.c

示例4: handle_prev

void
handle_prev(ETERM *msg)
{
  ETERM *ecols, *erows, *resp;

  if (results == NULL) {
    resp = erl_format("{error, result_set_does_not_exist}");
    write_msg(resp);
    erl_free_term(resp);

    return;
  }

  ecols = make_cols();
  if (resultoffset <= 1) {
    resp = erl_format("{selected, ~w, []}", ecols);
  } else {
    resultoffset--;
    mysql_stmt_data_seek(sth, resultoffset - 1);
    erows = make_rows(1);
    resp = erl_format("{selected, ~w, ~w}", ecols, erows);
    erl_free_term(erows);
  }

  erl_free_term(ecols);
  write_msg(resp);
  erl_free_term(resp);
}
开发者ID:bjc,项目名称:mysqlerl,代码行数:28,代码来源:mysqlerl.c

示例5: rel_curve_to

ETERM * rel_curve_to(ETERM* arg, int c_node) {
    ETERM *c1x, *c1y, *c2x, *c2y, *x, *y;
    cairo_context *ctx = get_cairo_context(arg);
    if (ctx) {
        c1x = erl_element(2, arg);  
        c1y = erl_element(3, arg); 
        c2x = erl_element(4, arg);  
        c2y = erl_element(5, arg);
        x = erl_element(6, arg);  
        y = erl_element(7, arg);
        cairo_rel_curve_to(ctx->cr, val(c1x), 
            val(c1y),
            val(c2x),
            val(c2y),
            val(x),
            val(y));
        erl_free_term(c1x);
        erl_free_term(c1y);
        erl_free_term(c2x);
        erl_free_term(c2y);
        erl_free_term(x);
        erl_free_term(y);
        return erl_format("{c_node, ~i, ok}", c_node);
    } else { 
        return erl_format("{c_node, ~i, {error, '~s'}}", c_node, ERR_CONTEXT);
    }
}
开发者ID:chinnurtb,项目名称:erlycairo,代码行数:27,代码来源:erlycairo.c

示例6: hello_getattr

static int hello_getattr(const char *path, struct stat *stbuf)
{
	ETERM * response = erl_rpc(FERL_DATA->erlang_fd,"gen_server","call",erl_format("[nefs,{get_attr,~s}]",path));
	ETERM * pattern = erl_format("{directory,Mode,Nlink}");
	ETERM * pattern2 = erl_format("{file,Mode,Nlink,Size}");
        int res = 0;
	memset(stbuf, 0, sizeof(struct stat));

	if(erl_match(pattern, response)) { //directory
		ETERM * Mode = erl_var_content(pattern, "Mode");
		ETERM * Nlink = erl_var_content(pattern, "Nlink");
		if(ERL_IS_INTEGER(Nlink) && ERL_IS_INTEGER(Mode)){
			stbuf->st_mode = S_IFDIR | ERL_INT_VALUE(Mode); //permissions
        	        stbuf->st_nlink = ERL_INT_VALUE(Nlink); // directories have the number of files in them
		}else{
			res = -ENOENT;
		}
	}else if(erl_match(pattern2, response)){ //file
		ETERM * Mode = erl_var_content(pattern2, "Mode");
                ETERM * Nlink = erl_var_content(pattern2, "Nlink");
		ETERM * Size = erl_var_content(pattern2, "Size");
                if(ERL_IS_INTEGER(Nlink) && ERL_IS_INTEGER(Mode) && ERL_IS_INTEGER(Size)){

			stbuf->st_mode = S_IFREG | ERL_INT_VALUE(Mode); //permissions
			stbuf->st_nlink = ERL_INT_VALUE(Nlink); //files only have 1
			stbuf->st_size = ERL_INT_VALUE(Size); // length of the file
                }else{
                        res = -ENOENT;
                }
	}else{
		res = -ENOENT;
	}	

	return res;
}
开发者ID:DBarney,项目名称:efs,代码行数:35,代码来源:hello.c

示例7: hello_readdir

static int hello_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
			 off_t offset, struct fuse_file_info *fi)
{
	int res = 0;
	ETERM * response = erl_rpc(FERL_DATA->erlang_fd,"gen_server","call",erl_format("[nefs,{read_dir,~s}]",path));
	ETERM * pattern = erl_format("{ok,Listing}");	
	if(erl_match(pattern, response)) { //directory
		ETERM * Tail = erl_var_content(pattern, "Listing");
		if(ERL_IS_LIST(Tail)){
			while(!ERL_IS_EMPTY_LIST(Tail)){
				ETERM * elem = ERL_CONS_HEAD(Tail);
				// add in the links to the previous folders
				filler(buf, ".", NULL, 0);
        			filler(buf, "..", NULL, 0);
				
				// add in the folders contents
				if(ERL_IS_LIST(elem)){
					filler(buf,(char *)ERL_BIN_PTR(elem),NULL,0);
				}else{
					res = -ENOENT;
					break;
				}
				Tail = ERL_CONS_TAIL(Tail);
			}
		}else{
			res = -ENOENT;
		}
	}else{
                res = -ENOENT;
        }

        return res;
}
开发者ID:DBarney,项目名称:efs,代码行数:33,代码来源:hello.c

示例8: stroke_preserve

ETERM * stroke_preserve(ETERM* arg, int c_node) {   
    cairo_context *ctx = get_cairo_context(arg);
    if (ctx) {
        cairo_stroke_preserve(ctx->cr);
        return erl_format("{c_node, ~i, ok}", c_node);
    } else { 
        return erl_format("{c_node, ~i, {error, '~s'}}", c_node, ERR_CONTEXT);
    }
}
开发者ID:chinnurtb,项目名称:erlycairo,代码行数:9,代码来源:erlycairo.c

示例9: close_image

ETERM * close_image(ETERM* arg, int c_node) {
    cairo_context *ctx = get_cairo_context(arg);
    if (ctx) {
        cairo_destroy(ctx->cr);
        cairo_surface_destroy(ctx->sf); 
        free(ctx->cbuf);
        return erl_format("{c_node, ~i, ok}", c_node);
    } else { 
        return erl_format("{c_node, ~i, {error, '~s'}}", c_node, ERR_CONTEXT);
    }
}
开发者ID:chinnurtb,项目名称:erlycairo,代码行数:11,代码来源:erlycairo.c

示例10: set_line_width

ETERM * set_line_width(ETERM* arg, int c_node) {
    ETERM *width;
    cairo_context *ctx = get_cairo_context(arg);
    if (ctx) {
        width = erl_element(2, arg);   
        cairo_set_line_width(ctx->cr, ERL_INT_VALUE(width));
        erl_free_term(width);
        return erl_format("{c_node, ~i, ok}", c_node);
    } else { 
        return erl_format("{c_node, ~i, {error, '~s'}}", c_node, ERR_CONTEXT);
    }
}
开发者ID:chinnurtb,项目名称:erlycairo,代码行数:12,代码来源:erlycairo.c

示例11: show_text

ETERM * show_text(ETERM* arg, int c_node) {
    ETERM *text;
    cairo_context *ctx = get_cairo_context(arg);
    if (ctx) {
        text = erl_element(2, arg);   
        cairo_show_text(ctx->cr, (char *)ERL_ATOM_PTR(text));
        erl_free_term(text);
        return erl_format("{c_node, ~i, ok}", c_node);
    } else { 
        return erl_format("{c_node, ~i, {error, '~s'}}", c_node, ERR_CONTEXT);
    }
}
开发者ID:chinnurtb,项目名称:erlycairo,代码行数:12,代码来源:erlycairo.c

示例12: set_font_size

ETERM * set_font_size(ETERM* arg, int c_node) {
    ETERM *size;
    cairo_context *ctx = get_cairo_context(arg);
    if (ctx) {
      size = erl_element(2, arg);   
        cairo_set_font_size(ctx->cr, val(size));
        erl_free_term(size);
        return erl_format("{c_node, ~i, ok}", c_node);
    } else { 
        return erl_format("{c_node, ~i, {error, '~s'}}", c_node, ERR_CONTEXT);
    }
}
开发者ID:chinnurtb,项目名称:erlycairo,代码行数:12,代码来源:erlycairo.c

示例13: rotate

ETERM * rotate(ETERM* arg, int c_node) {
    ETERM *angle;
    cairo_context *ctx = get_cairo_context(arg);
    if (ctx) {
        angle = erl_element(2, arg);   
        cairo_rotate(ctx->cr, val(angle));
        erl_free_term(angle);
        return erl_format("{c_node, ~i, ok}", c_node);
    } else { 
        return erl_format("{c_node, ~i, {error, '~s'}}", c_node, ERR_CONTEXT);
    }
}
开发者ID:chinnurtb,项目名称:erlycairo,代码行数:12,代码来源:erlycairo.c

示例14: set_operator

ETERM * set_operator(ETERM* arg, int c_node) {
    ETERM *operator;
    cairo_context *ctx = get_cairo_context(arg);
    if (ctx) {
        operator = erl_element(2, arg);    
        cairo_set_operator(ctx->cr, ERL_INT_VALUE(operator));
        erl_free_term(operator);
        return erl_format("{c_node, ~i, ok}", c_node);
    } else { 
        return erl_format("{c_node, ~i, {error, '~s'}}", c_node, ERR_CONTEXT);
    }
}
开发者ID:chinnurtb,项目名称:erlycairo,代码行数:12,代码来源:erlycairo.c

示例15: write_to_png

ETERM * write_to_png(ETERM* arg, int c_node) {
    int status;
    ETERM *file;
    cairo_context *ctx = get_cairo_context(arg);
    if (ctx) { 
        file = erl_element(2, arg); 
        status = cairo_surface_write_to_png(ctx->sf, (char *)ERL_ATOM_PTR(file));
        erl_free_term(file);
        return erl_format("{c_node, ~i, ok}", c_node);
    } else { 
        return erl_format("{c_node, ~i, {error, '~s'}}", c_node, ERR_CONTEXT);
    }
}
开发者ID:chinnurtb,项目名称:erlycairo,代码行数:13,代码来源:erlycairo.c


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