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

C++ set_number函数代码示例

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

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



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

示例1: test_program

// The test program (function is called in an endless loop)
// Used to display all digits
// Activated when both buttons are pressed during system startup
// Button 0 switches between continous running mode (where
// digits just get incremented every 250ms) and selective mode where
// Button 1 is used to increment the digits
void test_program(void)
{
	update_buttons();
	
	if(g_buttons[0] && !g_last_buttons[0])
		g_last_blink_state = 1 - g_last_blink_state;
	
	if(g_last_blink_state == 0)
	{
		if(g_buttons[1] && !g_last_buttons[1])
		{
			g_last_blink_action = g_ticks;
			g_blink_numbers = (g_blink_numbers + 1) % 10;
		}
	}
	else if(time_since(g_last_blink_action) > 25)
	{	
		g_last_blink_action = g_ticks;
		g_blink_numbers = (g_blink_numbers + 1) % 10;
	}
	
	set_number(pins_d1, g_blink_numbers);
	set_number(pins_d2, g_blink_numbers);
	set_number(pins_d3, g_blink_numbers);
	set_number(pins_d4, g_blink_numbers);
}
开发者ID:MGraefe,项目名称:nixie-clock,代码行数:32,代码来源:nixie.c


示例2: kplib_curr_taskinfo

/*
 * use gdb to get field offset of struct task_struct, for example:
 *
 * gdb vmlinux
 * (gdb)p &(((struct task_struct *)0).prio)
 */
static int kplib_curr_taskinfo(ktap_state_t *ks)
{
	int offset = kp_arg_checknumber(ks, 1);
	int fetch_bytes  = kp_arg_checkoptnumber(ks, 2, 4); /* fetch 4 bytes */

	if (offset >= sizeof(struct task_struct)) {
		set_nil(ks->top++);
		kp_error(ks, "access out of bound value of task_struct\n");
		return 1;
	}

#define RET_VALUE ((unsigned long)current + offset)

	switch (fetch_bytes) {
	case 4:
		set_number(ks->top, *(unsigned int *)RET_VALUE);
		break;
	case 8:
		set_number(ks->top, *(unsigned long *)RET_VALUE);
		break;
	default:
		kp_error(ks, "unsupported fetch bytes in curr_task_info\n");
		set_nil(ks->top);
		break;
	}

#undef RET_VALUE

	incr_top(ks);
	return 1;
}
开发者ID:feng-tao,项目名称:ktap,代码行数:37,代码来源:lib_base.c


示例3: write_output

void write_output(uint8_t a, uint8_t b)
{
	set_number(pins_d1, a > 99 ? 0xF : (a / 10));
	set_number(pins_d2, a > 99 ? 0xF : (a % 10));
	set_number(pins_d3, b > 99 ? 0xF : (b / 10));
	set_number(pins_d4, b > 99 ? 0xF : (b % 10));
}
开发者ID:MGraefe,项目名称:nixie-clock,代码行数:7,代码来源:nixie.c


示例4: test_serde

  void test_serde() {
    // dynamic create message.
    MessageHelper helper;
    FileDescriptorProto file_proto;
    file_proto.set_name("test.proo");
    DescriptorProto *message_proto = file_proto.add_message_type();
    message_proto->set_name("Pair");
    auto field = message_proto->add_field();
    field->set_name("key");
    field->set_label(FieldDescriptorProto_Label_LABEL_REQUIRED);
    field->set_type(FieldDescriptorProto_Type_TYPE_STRING);
    field->set_number(1);

    field = message_proto->add_field();
    field->set_name("value");
    field->set_label(FieldDescriptorProto_Label_LABEL_REQUIRED);
    field->set_type(FieldDescriptorProto_Type_TYPE_BYTES);
    field->set_number(2);
    helper.registerDynamicMessage(file_proto);
    auto src = helper.createMessage("Pair");
    auto ref = src->GetReflection();
    string key("scott");
    string value("tiger");
    ref->SetString(src.get(), src->GetDescriptor()->FindFieldByName("key"), key);
    ref->SetString(src.get(), src->GetDescriptor()->FindFieldByName("value"), value);

    // test serde
    check_serde_str(src.get(), helper.createMessage("Pair").get());
    check_serde_array(src.get(), helper.createMessage("Pair").get());
    check_serstr_dearray(src.get(), helper.createMessage("Pair").get());
    check_serarray_destr(src.get(), helper.createMessage("Pair").get());
  }
开发者ID:XiaominZhang,项目名称:raf,代码行数:32,代码来源:pair_serde_test.cpp


示例5: QDialog

HandCloseWindow::HandCloseWindow(QWidget *parent) :
	QDialog(parent),
	ui(new Ui::HandCloseWindow)
{
	ui->setupUi(this);
	QObject::connect(&timer, SIGNAL(timeout()),this,SLOT(set_number()));
}
开发者ID:Amxx,项目名称:MDMA,代码行数:7,代码来源:handclosewindow.cpp


示例6: kplib_gettimeofday_us

static int kplib_gettimeofday_us(ktap_state *ks)
{
	set_number(ks->top, gettimeofday_us());
	incr_top(ks);

	return 1;
}
开发者ID:WinLinKer,项目名称:ktap,代码行数:7,代码来源:lib_base.c


示例7: kplib_in_iowait

/*
 * This built-in function mainly purpose scripts/schedule/schedtimes.kp
 */
static int kplib_in_iowait(ktap_state *ks)
{
	set_number(ks->top, current->in_iowait);
	incr_top(ks);

	return 1;
}
开发者ID:cofyc,项目名称:ktap,代码行数:10,代码来源:lib_base.c


示例8: kplib_gettimeofday_s

static int kplib_gettimeofday_s(ktap_state *ks)
{
	set_number(ks->top, gettimeofday_ns() / NSEC_PER_SEC);
	incr_top(ks);

	return 1;
}
开发者ID:cofyc,项目名称:ktap,代码行数:7,代码来源:lib_base.c


示例9: kp_cdata_init

/* Init its cdata type, but not its actual value */
static void kp_cdata_init(ktap_state_t *ks, ktap_val_t *val, void *addr, int len,
			  csymbol_id id)
{
	ffi_type type = csym_type(id_to_csym(ks, id));

	switch (type) {
	case FFI_PTR:
		set_cdata(val, kp_cdata_new_ptr(ks, addr, len, id, 0));
		break;
	case FFI_STRUCT:
	case FFI_UNION:
		set_cdata(val, kp_cdata_new_record(ks, addr, id));
		break;
	case FFI_UINT8:
	case FFI_INT8:
	case FFI_UINT16:
	case FFI_INT16:
	case FFI_UINT32:
	case FFI_INT32:
	case FFI_UINT64:
	case FFI_INT64:
		/* set all these value into ktap_number(long) */
		set_number(val, 0);
		break;
	default:
		set_cdata(val, kp_cdata_new(ks, id));
		break;
	}
}
开发者ID:ktap,项目名称:ktap,代码行数:30,代码来源:cdata.c


示例10: kplib_tid

static int kplib_tid(ktap_state *ks)
{
	pid_t pid = task_pid_vnr(current);

	set_number(ks->top, (int)pid);
	incr_top(ks);
	return 1;
}
开发者ID:cofyc,项目名称:ktap,代码行数:8,代码来源:lib_base.c


示例11: QDialog

MaskWindow::MaskWindow(QWidget *parent) :
	QDialog(parent),
	ui(new Ui::MaskWindow)
{
	ui->setupUi(this);
	if(!Configuration::config().user_mask.empty()) ui->pushButton->setText("Reconfigure mask");
	QObject::connect(&timer, SIGNAL(timeout()),this,SLOT(set_number()));
}
开发者ID:Amxx,项目名称:MDMA,代码行数:8,代码来源:maskwindow.cpp


示例12: kplib_in_interrupt

static int kplib_in_interrupt(ktap_state *ks)
{
	int ret = in_interrupt();

	set_number(ks->top, ret);
	incr_top(ks);
	return 1;
}
开发者ID:cofyc,项目名称:ktap,代码行数:8,代码来源:lib_base.c


示例13: kplib_avg

static int kplib_avg(ktap_state *ks)
{
	ktap_value *v = kp_arg(ks, 1);
	ktap_stat_data *sd;

	if (is_nil(v)) {
		set_number(ks->top, 0);
		incr_top(ks);
		return 1;	
	}

	kp_arg_check(ks, 1, KTAP_TYPE_STATDATA);
	sd = sdvalue(v);

	set_number(ks->top, sd->sum / sd->count);
	incr_top(ks);
	return 1;
}
开发者ID:cofyc,项目名称:ktap,代码行数:18,代码来源:lib_base.c


示例14: ktap_lib_min

static int ktap_lib_min(ktap_state *ks)
{
    ktap_value *v = kp_arg(ks, 1);
    ktap_stat_data *sd;

    if (is_nil(v)) {
        set_number(ks->top, 0);
        incr_top(ks);
        return 1;
    }

    kp_arg_check(ks, 1, KTAP_TSTATDATA);
    sd = sdvalue(v);

    set_number(ks->top, sd->min);
    incr_top(ks);
    return 1;
}
开发者ID:atmark-techno,项目名称:linux-3.14-at,代码行数:18,代码来源:lib_base.c


示例15: kplib_curr_taskinfo

/*
 * use gdb to get field offset of struct task_struct, for example:
 *
 * gdb vmlinux
 * (gdb)p &(((struct task_struct *)0).prio)
 */
static int kplib_curr_taskinfo(ktap_state *ks)
{
	int offset;
	int fetch_bytes;

	kp_arg_check(ks, 1, KTAP_TYPE_NUMBER);

	offset = nvalue(kp_arg(ks, 1));
	
	if (kp_arg_nr(ks) == 1)
		fetch_bytes = 4; /* default fetch 4 bytes*/
	else {
		kp_arg_check(ks, 2, KTAP_TYPE_NUMBER);
		fetch_bytes = nvalue(kp_arg(ks, 2));
	}

	if (offset >= sizeof(struct task_struct)) {
		set_nil(ks->top++);
		kp_error(ks, "access out of bound value of task_struct\n");
		return 1;
	}

#define RET_VALUE ((unsigned long)current + offset)

	switch (fetch_bytes) {
	case 4:
		set_number(ks->top, *(unsigned int *)RET_VALUE);
		break;
	case 8:
		set_number(ks->top, *(unsigned long *)RET_VALUE);
		break;
	default:
		kp_error(ks, "unsupported fetch bytes in curr_task_info\n");
		set_nil(ks->top);
		break;
	}

#undef RET_VALUE

	incr_top(ks);
	return 1;
}
开发者ID:cofyc,项目名称:ktap,代码行数:48,代码来源:lib_base.c


示例16: process_command

static int process_command(usb_dev_handle *handle, char *cmd) {
	int tube = 0;
	int value = 0;
	int anim = 0;
	int speed = 0;
	int r = 0;
	int g = 0;
	int b = 0;
	if (sscanf(cmd, "t%d:%d", &tube, &value) == 2 && tube >= 0 && value >= 0) {
		printf("Setting nixie tube %u to %u.\n", tube, value);
		return set_tube(handle, tube, value);
	} else if (sscanf(cmd, "l%d:%d/%d/%d", &tube, &r, &g, &b) == 4 && tube >= 0) {
		printf("Setting nixie LED %u to %u/%u/%u.\n", tube, r, g, b);
		return set_led(handle, tube, r, g, b);
	} else if (sscanf(cmd, "anim:%d:%d", &anim, &speed) == 2 && anim >= 0 && anim >= 0) {
		printf("Setting animation style %u with speed %u.\n", anim, speed);
		return set_animation(handle, anim, speed);
	} else if (sscanf(cmd, "lnum:%d", &value) == 1 && value >= 0) {
		printf("Setting number %u\n", value);
		return set_number(handle, value, 1);
	} else if (sscanf(cmd, "num:%d", &value) == 1 && value >= 0) {
		printf("Setting number %u\n", value);
		return set_number(handle, value, 0);
	} else if (sscanf(cmd, "color:%d/%d/%d", &r, &g, &b) == 3) {
		printf("Setting color %u/%u/%u\n", r, g, b);
		return set_color(handle, r, g, b);
	} else if (strcmp(cmd, "off") == 0) {
		printf("Turning off all tubes...\n");
		return tubes_off(handle);
	} else if (strcmp(cmd, "read") == 0) {
		printf("Reading commands from stdin...\n");
		return read_cmds(handle, 0);
	} else if (strcmp(cmd, "readf") == 0) {
		printf("Reading commands from stdin (autofail)...\n");
		return read_cmds(handle, 1);
	} else {
		fprintf(stderr, "Unable to parse command: %s\n", cmd);
		return 2;
	}
	return 0;

}
开发者ID:wertarbyte,项目名称:nixie-usb,代码行数:42,代码来源:nixie.c


示例17: kplib_uid

static int kplib_uid(ktap_state *ks)
{
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5, 0)
	uid_t uid = from_kuid_munged(current_user_ns(), current_uid());
#else
	uid_t uid = current_uid();
#endif
	set_number(ks->top, (int)uid);
	incr_top(ks);
	return 1;
}
开发者ID:cofyc,项目名称:ktap,代码行数:11,代码来源:lib_base.c


示例18: kplib_len

static int kplib_len(ktap_state *ks)
{
	int len = kp_obj_len(ks, kp_arg(ks, 1));

	if (len < 0)
		return -1;

	set_number(ks->top, len);
	incr_top(ks);
	return 1;
}
开发者ID:cofyc,项目名称:ktap,代码行数:11,代码来源:lib_base.c


示例19: GOOGLE_CHECK_NE

void Person_PhoneNumber::MergeFrom(const Person_PhoneNumber& from) {
  GOOGLE_CHECK_NE(&from, this);
  if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
    if (from.has_number()) {
      set_number(from.number());
    }
    if (from.has_type()) {
      set_type(from.type());
    }
  }
  mutable_unknown_fields()->append(from.unknown_fields());
}
开发者ID:1514louluo,项目名称:acl,代码行数:12,代码来源:test.pb.cpp


示例20: load_constants

static int load_constants(struct load_state *S, ktap_proto *f)
{
	int i,n;

	n = READ_INT(S);

	f->sizek = n;
	f->k = NEW_VECTOR(S, n * sizeof(ktap_value));
	for (i = 0; i < n; i++)
		set_nil(&f->k[i]);

	for (i=0; i < n; i++) {
		ktap_value *o = &f->k[i];

		int t = READ_CHAR(S);
		switch (t) {
		case KTAP_TNIL:
			set_nil(o);
			break;
		case KTAP_TBOOLEAN:
			set_boolean(o, READ_CHAR(S));
			break;
		case KTAP_TNUMBER:
			/*
			 * todo: kernel not support fp, check double when
			 * loading
			 */
			set_number(o, READ_NUMBER(S));
			break;
		case KTAP_TSTRING:
			set_string(o, READ_STRING(S));
			break;
		default:
			kp_error(S->ks, "ktap: load_constants: "
					"unknow ktap_value\n");
			return -1;
			
		}
	}

	n = READ_INT(S);
	f->p = NEW_VECTOR(S, n * sizeof(ktap_proto));
	f->sizep = n;
	for (i = 0; i < n; i++)
		f->p[i] = NULL;
	for (i = 0; i < n; i++) {
		f->p[i] = kp_newproto(S->ks);
		if (load_function(S, f->p[i]))
			return -1;
	}

	return 0;
}
开发者ID:bruce2008github,项目名称:ktap,代码行数:53,代码来源:loader.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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