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

C++ NUM2ULL函数代码示例

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

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



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

示例1: cb_params_arith_parse_options

    static void
cb_params_arith_parse_options(struct params_st *params, VALUE options)
{
    VALUE tmp;

    if (NIL_P(options)) {
        return;
    }
    params->cmd.arith.create = RTEST(rb_hash_aref(options, sym_create));
    params->cmd.arith.extended = RTEST(rb_hash_aref(options, sym_extended));
    tmp = rb_hash_aref(options, sym_ttl);
    if (tmp != Qnil) {
        params->cmd.arith.ttl = NUM2ULONG(tmp);
    }
    tmp = rb_hash_aref(options, sym_initial);
    if (tmp != Qnil) {
        params->cmd.arith.initial = NUM2ULL(tmp);
        params->cmd.arith.create = 1;
    }
    tmp = rb_hash_aref(options, sym_delta);
    if (tmp != Qnil) {
        params->cmd.arith.delta = NUM2ULL(tmp) & INT64_MAX;
    }
    tmp = rb_hash_aref(options, sym_format);
    if (tmp != Qnil) { /* rewrite format bits */
        params->cmd.arith.format = tmp;
    }
    if (params->cmd.arith.format == sym_document) {
        /* just amend datatype for now */
        params->cmd.arith.datatype = 0x01;
    }
}
开发者ID:wr0ngway,项目名称:couchbase-ruby-client,代码行数:32,代码来源:arguments.c


示例2: rb_gst_index_get_assoc_entry

/*
 * Method: get_assoc_entry(id, method, flags, format, value) { ... }
 * id: the ID of the index writer.
 * method: the lookup method to use (see Gst::Index::LookupMethod).
 * flags: flags for the entry (see Gst::Index::AssocFlags).
 * format: a Gst::Format object.
 * value: the value to find.
 * 
 * Finds the given format/value in the index.  If a block is given, it will be
 * called as a compare function, passing references to 2 Gst::IndexEntry objects,
 * and waiting for a boolean as the return value.
 *
 * Returns: the entry associated with the value (as a Gst::IndexEntry object), or nil 
 * if the value is not found.
 */
static VALUE
rb_gst_index_get_assoc_entry (VALUE self, VALUE id, VALUE method, VALUE flags,
                              VALUE format, VALUE value)
{
    GstIndexEntry *index_entry;

    if (rb_block_given_p () == Qfalse)
        index_entry =
            gst_index_get_assoc_entry (RGST_INDEX (self), FIX2INT (id),
                                       RVAL2GENUM (method,
                                                   GST_TYPE_INDEX_LOOKUP_METHOD),
                                       RVAL2GFLAGS (flags,
                                                    GST_TYPE_ASSOC_FLAGS),
                                       *RGST_FORMAT (format), NUM2ULL (value));
    else
        index_entry =
            gst_index_get_assoc_entry_full (RGST_INDEX (self), FIX2INT (id),
                                            RVAL2GENUM (method,
                                                        GST_TYPE_INDEX_LOOKUP_METHOD),
                                            RVAL2GFLAGS (flags,
                                                         GST_TYPE_ASSOC_FLAGS),
                                            *RGST_FORMAT (format),
                                            NUM2ULL (value), __compare,
                                            (gpointer) rb_block_proc ());

    return index_entry != NULL ? RGST_INDEX_ENTRY_NEW (index_entry)
        : Qnil;
}
开发者ID:benolee,项目名称:ruby-gnome2,代码行数:43,代码来源:rbgstindex.c


示例3: hamming_distance

static VALUE hamming_distance(VALUE self, VALUE a, VALUE b) {
    int result = 0;
    result = ph_hamming_distance(NUM2ULL(a), NUM2ULL(b));
    if (-1 == result) {
      rb_raise(rb_eRuntimeError, "Unknown pHash error");
    }
    return INT2NUM(result);
}
开发者ID:JoeyBurzynski,项目名称:phashion,代码行数:8,代码来源:phashion_ext.c


示例4: rb_send

static VALUE rb_send (VALUE self_, VALUE exchange_, VALUE data_, VALUE size_,
    VALUE block_)
{
    //  Get the context.
    context_t* context;
    Data_Get_Struct (self_, context_t, context);
	
    //  Forward the call to native 0MQ library.
    zmq::message_t msg ((size_t) NUM2ULL (size_));
    memcpy (msg.data (), (void*) StringValueCStr (data_), 
    	(size_t) NUM2ULL (size_));
    return context->api_thread->send (NUM2INT (exchange_), msg,
        NUM2INT (block_) ? true : false);
}
开发者ID:floydprice,项目名称:helloworld,代码行数:14,代码来源:zmq.cpp


示例5: test_num2ull

static VALUE
test_num2ull(VALUE obj, VALUE num)
{
    char buf[128];
    sprintf(buf, "%"PRI_LL_PREFIX"u", NUM2ULL(num));
    return rb_str_new_cstr(buf);
}
开发者ID:0x00evil,项目名称:ruby,代码行数:7,代码来源:num2int.c


示例6: controller_send_message

/*
 * @overload send_message(datapath_id, message)
 *   Sends an OpenFlow message to the datapath.
 *
 *   @example
 *     send_message datapath_id, FeaturesRequest.new
 *
 *   @param [Integer] datapath_id
 *     the datapath to which a message is sent.
 *   @param [Hello, EchoRequest, EchoReply, FeaturesRequest, SetConfig, GetConfigRequest, QueueGetConfigRequest, StatsRequest, BarrierRequest, PortMod, Vendor] message
 *     the message to be sent.
 */
static VALUE
controller_send_message( VALUE self, VALUE datapath_id, VALUE message ) {
  buffer *buf;
  Data_Get_Struct( message, buffer, buf );
  send_openflow_message( NUM2ULL( datapath_id ), buf );
  return self;
}
开发者ID:aigamo,项目名称:trema,代码行数:19,代码来源:controller.c


示例7: call_tsk_istat

VALUE call_tsk_istat(int argc, VALUE *args, VALUE self) {
  VALUE io; VALUE inum; VALUE options;
  rb_scan_args(argc, args, "21", &inum, &io, &options);
  if (! rb_obj_is_kind_of(io, rb_cIO) ) {
    rb_raise(rb_eArgError, "Method did not recieve IO object");
  }
  
  TSK_DADDR_T numblock; int32_t sec_skew;
  VALUE block = rb_hash_aref(options, ID2SYM(rb_intern("block")));
  if (! NIL_P(block)) { numblock = (TSK_DADDR_T)NUM2ULL(block); } else { numblock = 0; }
  VALUE skew = rb_hash_aref(options, rb_symname_p("skew"));
  if (! NIL_P(skew)) {  sec_skew = (int32_t)NUM2INT(skew); } else { sec_skew = 0; }

  TSK_INUM_T inum_int;
  inum_int = NUM2INT(inum);
  int fd = FIX2LONG(rb_funcall(io, rb_intern("fileno"), 0));
  FILE * hFile = fdopen((int)fd, "w");
  
  struct tsk4r_fs_wrapper * fs_ptr;
  Data_Get_Struct(self, struct tsk4r_fs_wrapper, fs_ptr);
  
  if (fs_ptr->filesystem != NULL) {
    uint8_t(*myfunc) (TSK_FS_INFO * fs, FILE * hFile, TSK_INUM_T inum,
                      TSK_DADDR_T numblock, int32_t sec_skew);
    myfunc = fs_ptr->filesystem->istat;
    int r = myfunc(fs_ptr->filesystem, hFile, inum_int, numblock, sec_skew);
    fflush(hFile); // clear file buffer, completing write
    if (r != 0 ) { rb_raise(rb_eRuntimeError, "TSK function: fsstat exited with an error."); }

  }
  return self;
}
开发者ID:Lorrie,项目名称:RubyTSK,代码行数:32,代码来源:file_system.c


示例8: mc_cas

static VALUE mc_cas(int argc, VALUE *argv, VALUE self) {
  memcached_st *mc;
  VALUE key, value, cas, expiry, flags;
  static memcached_return_t result;

  Data_Get_Struct(self, memcached_st, mc);
  rb_scan_args(argc, argv, "32", &key, &value, &cas, &expiry, &flags);

  key = StringValue(key);
  if (!use_binary(mc)) key = escape_key(key, NULL);
  value = StringValue(value);

  result = memcached_cas(mc, RSTRING_PTR(key), RSTRING_LEN(key), RSTRING_PTR(value), RSTRING_LEN(value),
                        RTEST(expiry) ? NUM2UINT(expiry) : 0,
                        RTEST(flags)  ? NUM2UINT(flags)  : 0,
                        NUM2ULL(cas));

  if (result == MEMCACHED_SUCCESS) {
    return value;
  } else if (result == MEMCACHED_NOTFOUND || result == MEMCACHED_DATA_EXISTS) {
    return Qnil;
  } else {
    return throw_error(&result);
  }
}
开发者ID:oleg-z,项目名称:memcache,代码行数:25,代码来源:native_server.c


示例9: cb_params_unlock_extract_keys_i

    static int
cb_params_unlock_extract_keys_i(VALUE key, VALUE value, VALUE arg)
{
    struct params_st *params = (struct params_st *)arg;
    cb_params_unlock_init_item(params, params->idx++, key, NUM2ULL(value));
    return ST_CONTINUE;
}
开发者ID:wr0ngway,项目名称:couchbase-ruby-client,代码行数:7,代码来源:arguments.c


示例10: rb_gst_index_add

/*
 * Method: add(id, *args)
 * id: the ID of the index writer.
 * args: additional parameters, see below.
 *
 * Adds an entry into the index.  The type of the entry depends of
 * the number and kind of additional parameters.
 *
 *	* For an ID type, args must be a String.
 *	* For a FORMAT type, args must be a Gst::Format.
 *	* For an ASSOCIATION type, args must contains an association flag (see Gst::Index::AssocFlags), a Gst::Format and a value for the format.
 *	* For an OBJECT type, well you must wait, because it is not yet implemented.
 *
 * Returns: a reference to the newly allocated entry in the index, as a Gst::EntryIndex object.
 */
static VALUE
rb_gst_index_add (int argc, VALUE * argv, VALUE self)
{
    GstIndexEntry *index_entry;
    VALUE id;

    if (argc == 2) {
        VALUE var;

        rb_scan_args (argc, argv, "2", &id, &var);

        index_entry = CLASS2GTYPE (CLASS_OF (var)) == GST_TYPE_FORMAT2
            ? gst_index_add_format (RGST_INDEX (self), FIX2INT (id),
                                    *RGST_FORMAT (var))
            : gst_index_add_id (RGST_INDEX (self), FIX2INT (id),
                                RVAL2CSTR (var));

    } else {
        VALUE flags, format, value;

        rb_scan_args (argc, argv, "4", &id, &flags, &format, &value);

        index_entry =
            gst_index_add_association (RGST_INDEX (self), FIX2INT (id),
                                       RVAL2GFLAGS (flags,
                                                    GST_TYPE_ASSOC_FLAGS),
                                       *RGST_FORMAT (format), NUM2ULL (value));
    }

    return index_entry != NULL ? RGST_INDEX_ENTRY_NEW (index_entry)
        : Qnil;
}
开发者ID:benolee,项目名称:ruby-gnome2,代码行数:47,代码来源:rbgstindex.c


示例11: cb_params_store_parse_options

    static void
cb_params_store_parse_options(struct params_st *params, VALUE options)
{
    VALUE tmp;

    if (NIL_P(options)) {
        return;
    }
    tmp = rb_hash_aref(options, sym_flags);
    if (tmp != Qnil) {
        params->cmd.store.flags = (lcb_uint32_t)NUM2ULONG(tmp);
    }
    tmp = rb_hash_aref(options, sym_format);
    if (tmp != Qnil) { /* rewrite format bits */
        params->cmd.store.flags = flags_set_format(params->cmd.store.flags, tmp);
    }
    tmp = rb_hash_aref(options, sym_ttl);
    if (tmp != Qnil) {
        params->cmd.store.ttl = NUM2ULONG(tmp);
    }
    tmp = rb_hash_aref(options, sym_cas);
    if (tmp != Qnil) {
        params->cmd.store.cas = NUM2ULL(tmp);
    }
    tmp = rb_hash_aref(options, sym_observe);
    if (tmp != Qnil) {
        Check_Type(tmp, T_HASH);
        rb_funcall(params->bucket->self, id_verify_observe_options, 1, tmp);
        params->cmd.store.observe = tmp;
    }
    if (flags_get_format(params->cmd.store.flags) == sym_document) {
        /* just amend datatype for now */
        params->cmd.store.datatype = 0x01;
    }
}
开发者ID:wr0ngway,项目名称:couchbase-ruby-client,代码行数:35,代码来源:arguments.c


示例12: dump_forward_entries_from_switch

/*
 * @!group Operation for existing switch
 *
 * @overload dump_forward_entries_from_switch datapath_id, type, {|result, services| ... }
 * Dump forwarding entry of a switch specified.
 *
 * @param [Integer] dpid Switch datapath_id
 * @param [Symbol] type Switch event type. it must be one of :vendor, :packet_in, :port_status, :state_notify
 * @return [Boolean] true if request was sent successfully.
 *
 * @yield Callback to notify the result of operation.
 * @yieldparam result [Boolean] true if result successful on all switches and switch manager
 * @yieldparam services [Array<String>] Service Name list on forwarding entry after operation.
 */
static VALUE
dump_forward_entries_from_switch( VALUE self, VALUE dpid, VALUE type ) {
  debug( "%s", __func__ );
  enum efi_event_type c_type;
  if ( !event_type_symbol_to_enum( type, &c_type ) ) {
    warn( "Invalid event type was specified" );
    return Qfalse;
  }

  const uint64_t c_dpid = NUM2ULL( dpid );

  callback_info *cb = xcalloc( 1, sizeof( callback_info ) );
  cb->self = self;
  cb->block = Qnil;
  if ( rb_block_given_p() == Qtrue ) {
    cb->block = rb_block_proc();
  }
  bool succ = dump_switch_event_forward_entries(
                                c_dpid, c_type,
                                handle_event_forward_entry_operation_callback,
                                cb );
  if ( succ ) {
    return Qtrue;
  }
  else {
    xfree( cb );
    return Qfalse;
  }
}
开发者ID:aigamo,项目名称:trema,代码行数:43,代码来源:switch-event.c


示例13: delete_forward_entry_from_switch

/*
 * @!group Operation for existing switch
 *
 * @overload delete_forward_entry_from_switch datapath_id, type, service_name, {|result, services| ... }
 * Delete forwarding entry of a switch specified.
 *
 * @param [Integer] dpid Switch datapath_id
 * @param [Symbol] type Switch event type. it must be one of :vendor, :packet_in, :port_status, :state_notify
 * @param [String] service_name Name of controller to forward event.
 * @return [Boolean] true if request was sent successfully.
 *
 * @yield Callback to notify the result of operation.
 * @yieldparam result [Boolean] true if result successful.
 * @yieldparam services [Array<String>] Service Name list on forwarding entry after operation.
 */
static VALUE
delete_forward_entry_from_switch( VALUE self, VALUE dpid, VALUE type,
                                  VALUE service_name ) {
  debug( "%s", __func__ );
  enum efi_event_type c_type;
  if ( !event_type_symbol_to_enum( type, &c_type ) ) {
    warn( "Invalid event type was specified" );
    return Qfalse;
  }

  const uint64_t c_dpid = NUM2ULL( dpid );
  const char *c_service_name = StringValuePtr( service_name );
  if ( strlen( c_service_name ) == 0 ) {
    warn( "service_name cannot be empty" );
    return Qfalse;
  }

  callback_info *cb = xcalloc( 1, sizeof( callback_info ) );
  cb->self = self;
  cb->block = Qnil;
  if ( rb_block_given_p() == Qtrue ) {
    cb->block = rb_block_proc();
  }
  bool succ = delete_switch_event_forward_entry(
                                c_dpid, c_type, c_service_name,
                                handle_event_forward_entry_operation_callback,
                                cb );
  if ( succ ) {
    return Qtrue;
  }
  else {
    xfree( cb );
    return Qfalse;
  }
}
开发者ID:aigamo,项目名称:trema,代码行数:50,代码来源:switch-event.c


示例14: rg_get_state

/* Method: get_state(timeout=nil)
 */
static VALUE
rg_get_state(int argc, VALUE *argv, VALUE self)
{
    VALUE result, timeout;
    ThreadData thread_data;
    GetStateData *get_state_data;

    rb_scan_args(argc, argv, "01", &timeout);

    thread_data.element = SELF(self);
    thread_data.context = "get_state";
    get_state_data = &(thread_data.data.get_state_data);
    if (NIL_P(timeout))
        get_state_data->timeout = GST_CLOCK_TIME_NONE;
    else
        get_state_data->timeout = NUM2ULL(timeout);

    do_in_thread(get_state_thread_pool, &thread_data);

    result = rb_ary_new3(3,
                         GST_STATE_CHANGE_RETURN2RVAL(get_state_data->result),
                         GST_STATE2RVAL(get_state_data->state),
                         GST_STATE2RVAL(get_state_data->pending));

    return result;
}
开发者ID:masaakiaoyagi,项目名称:ruby-gnome2,代码行数:28,代码来源:rbgst-element.c


示例15: api_rwrite

static VALUE api_rwrite(VALUE self, VALUE s_, VALUE buffer)
{
  servlet *s = (servlet*)NUM2ULL(s_);
  const void *ptr = StringValuePtr(buffer);
  int length = RSTRING_LEN(buffer);
  rwrite(s, ptr, length);
  return Qnil;
}
开发者ID:raj347,项目名称:modserver,代码行数:8,代码来源:ruby.c


示例16: ruby_libvirt_value_to_ulonglong

unsigned long long ruby_libvirt_value_to_ulonglong(VALUE in)
{
    if (NIL_P(in)) {
        return 0;
    }

    return NUM2ULL(in);
}
开发者ID:agx,项目名称:ruby-libvirt,代码行数:8,代码来源:common.c


示例17: rb_bson_byte_buffer_put_decimal128

/**
 * Writes a 128 bit decimal to the byte buffer.
 */
VALUE rb_bson_byte_buffer_put_decimal128(VALUE self, VALUE low, VALUE high)
{
  byte_buffer_t *b;
  const int64_t low64 = BSON_UINT64_TO_LE(NUM2ULL(low));
  const int64_t high64 = BSON_UINT64_TO_LE(NUM2ULL(high));

  TypedData_Get_Struct(self, byte_buffer_t, &rb_byte_buffer_data_type, b);
  ENSURE_BSON_WRITE(b, 8);
  memcpy(WRITE_PTR(b), &low64, 8);
  b->write_position += 8;

  ENSURE_BSON_WRITE(b, 8);
  memcpy(WRITE_PTR(b), &high64, 8);
  b->write_position += 8;

  return self;
}
开发者ID:estolfo,项目名称:bson-ruby,代码行数:20,代码来源:bson_native.c


示例18: seek_initialize

static VALUE
seek_initialize(VALUE self, VALUE rate, VALUE format, VALUE flags,
   VALUE start_type, VALUE start, VALUE stop_type, VALUE stop)
{
    GstEvent *event;

    event = gst_event_new_seek(NUM2DBL(rate),
                               RVAL2GST_FORMAT(format),
                               RVAL2GFLAGS(flags, GST_TYPE_SEEK_FLAGS),
                               RVAL2GENUM(start_type, GST_TYPE_SEEK_TYPE),
                               NUM2ULL(start),
                               RVAL2GENUM(stop_type, GST_TYPE_SEEK_TYPE),
                               NUM2ULL(stop));

    G_INITIALIZE(self, event);
    return Qnil;
}
开发者ID:masaakiaoyagi,项目名称:ruby-gnome2,代码行数:17,代码来源:rbgst-event.c


示例19: oci8_lob_truncate

/*
 *  call-seq:
 *    truncate(length)
 *
 *  @param [Integer] length length in characters if +self+ is a {CLOB} or a {NCLOB}.
 *    length in bytes if +self+ is a {BLOB} or a {BFILE}.
 *  @return [self]
 *  @see #size=
 */
static VALUE oci8_lob_truncate(VALUE self, VALUE len)
{
    oci8_lob_t *lob = TO_LOB(self);
    oci8_svcctx_t *svcctx = check_svcctx(lob);

    chker2(OCILobTrim2_nb(svcctx, svcctx->base.hp.svc, oci8_errhp, lob->base.hp.lob, NUM2ULL(len)),
           &svcctx->base);
    return self;
}
开发者ID:kubo,项目名称:ruby-oci8,代码行数:18,代码来源:lob.c


示例20: distance

int distance(VALUE _1, VALUE _2) {
  uint64_t _1_ll;
  uint64_t _2_ll;
  uint64_t differences;
  const int max_dist = 64;

  if (_1 == Qnil) {
    return max_dist;
  } else if (_2 == Qnil) {
    return max_dist;
  }

  _1_ll = NUM2ULL(_1);
  _2_ll = NUM2ULL(_2);
  differences = _1_ll ^ _2_ll;

  return __builtin_popcountll(differences);
}
开发者ID:jordanshoebox,项目名称:fast_hamming,代码行数:18,代码来源:fast_hamming.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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