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


C++ NUM2ULL函数代码示例

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


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


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