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

C++ do_update函数代码示例

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

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



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

示例1: set_disq_comment_func

static int
set_disq_comment_func(
        struct xuser_cnts_state *data,
        int user_id,
        const unsigned char *disq_comment)
{
    struct xuser_mongo_cnts_state *state = (struct xuser_mongo_cnts_state *) data;
    struct team_extra *extra = do_get_entry(state, user_id);
    if (!extra) return -1;
    if (!extra->disq_comment && !disq_comment) {
        return 0;
    }
    if (extra->disq_comment && !disq_comment) {
        ASSERT(ej_uuid_is_nonempty(extra->uuid));
        xfree(extra->disq_comment); extra->disq_comment = NULL;
        bson *doc = bson_new();
        bson_append_string(doc, "disq_comment", "", 0);
        bson_finish(doc);
        return do_update(state, extra, "$unset", doc);
    }
    if (extra->disq_comment && !strcmp(extra->disq_comment, disq_comment))
        return 0;
    xfree(extra->disq_comment);
    extra->disq_comment = xstrdup(disq_comment);
    if (ej_uuid_is_nonempty(extra->uuid)) {
        bson *doc = bson_new();
        bson_append_string(doc, "disq_comment", extra->disq_comment, strlen(extra->disq_comment));
        bson_finish(doc);
        return do_update(state, extra, NULL, doc);
    } else {
        return do_insert(state, extra);
    }
}
开发者ID:NUOG,项目名称:ejudge,代码行数:33,代码来源:xuser_mongo.c


示例2: handle_transfer_command

int
handle_transfer_command(struct thread_data_t * datum, char * args)
{
  long amount, balance;
  char * user, buffer[MAX_COMMAND_LENGTH];

  #ifndef NDEBUG
  if (*args == '\0') {
    fprintf(stderr,
            "[thread %lu] WARNING: [%s] arguments empty\n",
            datum->id, "transfer");
  } else {
    fprintf(stderr,
            "[thread %lu] INFO: [%s] '%s' (arguments)\n",
            datum->id, "transfer", args);
  }
  #endif
  amount = strtol(args, &args, 10);
  user = ++args;

  if (amount <= 0 || amount > MAX_TRANSACTION) {
    snprintf(buffer, MAX_COMMAND_LENGTH, "Invalid transfer amount.");
  } else if (datum->credentials.userlength
   && do_lookup(session_data.db_conn, NULL,
                datum->credentials.username,
                datum->credentials.userlength,
                &balance) == BANKING_SUCCESS) {
    if (balance < amount) {
      snprintf(buffer, MAX_COMMAND_LENGTH, "Insufficient funds.");
    } else if (do_update(session_data.db_conn, NULL,
               datum->credentials.username,
               datum->credentials.userlength,
               balance - amount)
            || do_lookup(session_data.db_conn, NULL,
               user, strnlen(user, MAX_COMMAND_LENGTH),
               &balance)
            || do_update(session_data.db_conn, NULL,
               user, strnlen(user, MAX_COMMAND_LENGTH),
               balance + amount)) {
      /* TODO atomic operation? */
      snprintf(buffer, MAX_COMMAND_LENGTH, "Cannot complete transfer.");
    } else {
      snprintf(buffer, MAX_COMMAND_LENGTH, "Transfered $%li to %s",
                                           amount, user);
    }
  } else {
    snprintf(buffer, MAX_COMMAND_LENGTH, "TRANSFER ERROR");
  }
  salt_and_pepper(buffer, NULL, &datum->buffet);
  encrypt_message(&datum->buffet, datum->credentials.key);
  send_message(&datum->buffet, datum->sock);

  return BANKING_SUCCESS;
}
开发者ID:hagemt,项目名称:crypto_fall2011,代码行数:54,代码来源:bank.c


示例3: select_items

static void select_items(int n) {
	int fsel = 0;

	while (42) {
		if (n > 0)
			print_item(fsel, STATUS_BG, STATUS_FG);

		switch (wait_any_key()) {
		case KEY_ENTER:
			setvar(V_sel_item, intobj[fsel]);
			goto exit_select;
		case KEY_ESCAPE:
			setvar(V_sel_item, 0xff);
			goto exit_select;
		case KEY_UP:
			if (fsel >= 2)
				fsel -= 2;
			break;
		case KEY_DOWN:
			if (fsel + 2 < n)
				fsel += 2;
			break;
		case KEY_LEFT:
			if (fsel % 2 == 1)
				fsel--;
			break;
		case KEY_RIGHT:
			if (fsel % 2 == 0 && fsel + 1 < n)
				fsel++;
			break;
		case BUTTON_LEFT:{
				int i = find_item();
				if (i >= 0 && i < n) {
					setvar(V_sel_item, intobj[fsel = i]);
					debugC(6, kDebugLevelInventory, "item found: %d", fsel);
					show_items();
					print_item(fsel, STATUS_BG, STATUS_FG);
					do_update();
					goto exit_select;
				}
				break;
			}
		default:
			break;
		}

		show_items();
		do_update();
	}

 exit_select:
	debugC(6, kDebugLevelInventory, "selected: %d", fsel);
}
开发者ID:iPodLinux-Community,项目名称:iScummVM,代码行数:53,代码来源:inv.cpp


示例4: QFrame

    items::items(editor_resource_ptr res, QWidget* parent)
      : QFrame(parent)
      , resource_(res)
    {
      setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);

      QGridLayout* l = new QGridLayout(this);
      l->setContentsMargins(0, 0, 0, 0);

      // Tablewidget
      data_ = new QTableWidget(this);

      data_->setColumnCount(3);
      data_->setHorizontalHeaderLabels(QStringList() << "Filename" << "Type" << "?");
      data_->setColumnWidth(0, 100);
      data_->setColumnWidth(1, 75);
      data_->setColumnWidth(2, 20);

      data_->verticalHeader()->setVisible(false);

      data_->setEditTriggers(QTableWidget::NoEditTriggers);
      data_->setSelectionMode(QTableWidget::SingleSelection);
      data_->setSelectionBehavior(QTableWidget::SelectRows);
      data_->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);

      l->addWidget(data_, 0, 0, 1, 2);

      // Buttons
      QPushButton* btn_edit = new QPushButton("Edit", this);
      btn_edit->setMaximumWidth(80);
      l->addWidget(btn_edit, 2, 0, Qt::AlignCenter);
      connect(btn_edit, SIGNAL(clicked()), SLOT(do_edit()));

      QPushButton* btn_add = new QPushButton("Add", this);
      btn_add->setMaximumWidth(80);
      l->addWidget(btn_add, 1, 0, Qt::AlignCenter);
      connect(btn_add, SIGNAL(clicked()), SLOT(do_add()));

      QPushButton* btn_remove = new QPushButton("Remove", this);
      btn_remove->setMaximumWidth(80);
      l->addWidget(btn_remove, 1, 1, Qt::AlignCenter);
      connect(btn_remove, SIGNAL(clicked()), SLOT(do_remove()));

      QPushButton* btn_generate = new QPushButton("Generate", this);
      btn_generate->setMaximumWidth(80);
      l->addWidget(btn_generate, 2, 1, Qt::AlignCenter);
      connect(btn_generate, SIGNAL(clicked()), SLOT(do_generate()));

      connect(resource_.data(), SIGNAL(sig_resource_updated()), SLOT(do_update()));
      do_update();
    }
开发者ID:nelbok,项目名称:MaskedDuck,代码行数:51,代码来源:items.cpp


示例5: timer_callback

// Callbacks
void timer_callback(uint unused0, uint unused1) {
    use(unused0);
    use(unused1);
    time++;

    log_debug("Timer tick %d", time);

    if ((infinite_run != TRUE) && (time == simulation_ticks)) {
        simulation_handle_pause_resume(NULL);
        log_info("Simulation complete.\n");
        simulation_ready_to_read();
    }

    // Process the incoming spikes
    spike_t s;
    uint32_t nid;
    while (in_spikes_get_next_spike(&s)) {
        nid = (s & NEURON_ID_MASK);

        if (nid < N_COUNTERS) {
            counters[nid] += 1;
        } else {
            log_debug("Received spike from unknown neuron %d", nid);
        }
    }

    // Work out if there is any motion
    if ((time % sample_time) == 0) {

        // Do motion in pairs
        do_motion(MOTION_FORWARD, MOTION_BACK, "Forwards", "Backwards");
        do_motion(MOTION_LEFT, MOTION_RIGHT, "Left", "Right");
        do_motion(MOTION_CLOCKWISE, MOTION_C_CLOCKWISE, "Clockwise",
                  "Anti-clockwise");

        // Reset the counters
        for (uint32_t i = 0; i < N_COUNTERS; i++) {
            counters[i] = 0;
        }
    } else if ((time % update_time) == 0) {

        // Do updates in pairs
        do_update(MOTION_FORWARD, MOTION_BACK, "Forwards", "Backwards");
        do_update(MOTION_LEFT, MOTION_RIGHT, "Left", "Right");
        do_update(MOTION_CLOCKWISE, MOTION_C_CLOCKWISE, "Clockwise",
                  "Anti-clockwise");
    }
}
开发者ID:SpiNNakerManchester,项目名称:sPyNNaker,代码行数:49,代码来源:robot_motor_control.c


示例6: run_application

static void run_application(MYSQL &mysql,
			    Ndb_cluster_connection &cluster_connection)
{
  /********************************************
   * Connect to database via mysql-c          *
   ********************************************/
  mysql_query(&mysql, "CREATE DATABASE TEST_DB_1");
  if (mysql_query(&mysql, "USE TEST_DB_1") != 0) MYSQLERROR(mysql);
  create_table(mysql);

  /********************************************
   * Connect to database via NdbApi           *
   ********************************************/
  // Object representing the database
  Ndb myNdb( &cluster_connection, "TEST_DB_1" );
  if (myNdb.init()) APIERROR(myNdb.getNdbError());

  /*
   * Do different operations on database
   */
  do_insert(myNdb);
  do_update(myNdb);
  do_delete(myNdb);
  do_read(myNdb);
  drop_table(mysql);
  mysql_query(&mysql, "DROP DATABASE TEST_DB_1");
}
开发者ID:A-eolus,项目名称:mysql,代码行数:27,代码来源:ndbapi_simple.cpp


示例7: done_jiqi

int done_jiqi(object me) {
	
	string msg;
	
	if (!me || me->is_ghost() || environment(me)!= this_object())
		return 1;
		
	if (me->query_temp("jiqi/num")>=3) {
		msg = HIR"
һ�������ֻ���������������������ȫ������֮�У�����һ����
ˮ���ڵ�����ת�������ޱȡ�ǡ��ˮ����ã��������ᣬ������ʮ��
����һһ���ƣ����Ǵ 

鲜花

握手

雷人

路过

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

请发表评论

全部评论

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