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


C++ parse_int函数代码示例

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


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

示例1: parse_macro_cmd

static int parse_macro_cmd(const char *p, unsigned char *cmd,
                           unsigned char *val)
{
	char *t;
	int q = INVALID_NUMBER, c = INVALID_NUMBER, v = INVALID_NUMBER;

	if (!p || !cmd || !val)
		goto ret;

	t = get_token(p);
	if (t) {
		c = lookup_macro_token_by_name(t);
		free(t);
	}

	if (c == INVALID_NUMBER) {
		v = c;
		goto ret;
	}

	p = skip_token(p);
	/* todo: Q_PLAY */
	if (c == Q_PUSH_META) {
		t = get_token(p);
		if (t) {
			q = lookup_macro_token_by_name(t);
			free(t);
		} else q = INVALID_NUMBER;

		if (q == INVALID_NUMBER) {
			v = q;
			goto ret;
		}

		c |= q;
		p = skip_token(p);
	}

	t = get_token(p);
	switch (get_macro_arg_type(c)) {
	case MACRO_ARG_HID:   v = lookup_hid_token_by_name(t); break;
	case MACRO_ARG_META:  v = parse_meta_handed(p);        break;
	case MACRO_ARG_DELAY: v = parse_int(t, 0, 255);        break;
	case MACRO_ARG_NONE:  v = 0;                           break;
	}
	if (t) free(t);

ret:
	*cmd = (unsigned char)c;
	*val = (unsigned char)v;
	return v == INVALID_NUMBER;
}
开发者ID:thentenaar,项目名称:sctools,代码行数:52,代码来源:scas.c

示例2: TORRENT_ASSERT

	boost::int64_t lazy_entry::int_value() const
	{
		TORRENT_ASSERT(m_type == int_t);
		boost::int64_t val = 0;
		bool negative = false;
		if (*m_data.start == '-') negative = true;
		bdecode_errors::error_code_enum ec = bdecode_errors::no_error;
		parse_int(m_data.start + negative
			, m_data.start + m_size, 'e', val, ec);
		if (ec) return 0;
		if (negative) val = -val;
		return val;
	}
开发者ID:dyingwithwind,项目名称:bootstrap-dht,代码行数:13,代码来源:lazy_bdecode.cpp

示例3: file

void generator_thread::create_script(QString uuid,QString major, QString minor, int strength){
    QString file_name;
    if(update_minor)
        file_name = uuid+"/"+major+"/start_beacon_"+major+"_"+minor+".sh";
    else
        file_name = uuid+"/"+minor+"/start_beacon_"+major+"_"+minor+".sh";

    //qDebug()<<file_name;
    QFile file(file_name);
    if(file.open(QIODevice::ReadWrite)){
         QTextStream output_stream(&file);
         QString command = "#!/bin/bash \nhciconfig hci0 up\nhciconfig hci0 leadv 3 \n";
         command.append(create_command_string(uuid));
         command.append(parse_int(major.toInt()));
         command.append(parse_int(minor.toInt()));
         command.append(QString::number(strength,16));
         command.append(" 00");
         //qDebug()<<command;
         output_stream<<command;
    }
    file.setPermissions(QFile::ExeGroup | QFile::ReadGroup | QFile::ReadOwner | QFile::ReadOther | QFile::WriteOwner | QFile::ExeUser);
}
开发者ID:AndreaCorna,项目名称:Configurator_Ibeacon,代码行数:22,代码来源:generator_thread.cpp

示例4: application_function_gpio_status_set

irom static app_action_t application_function_gpio_status_set(const string_t *src, string_t *dst)
{
	int io, pin;

	if((parse_int(1, src, &io, 0) == parse_ok) && (parse_int(2, src, &pin, 0) == parse_ok))
	{
		if((io < -1) || (io > io_id_size))
		{
			string_format(dst, "status trigger io %d/%d invalid\n", io, pin);
			return(app_action_error);
		}

		config.status_trigger_io.io = io;
		config.status_trigger_io.pin = pin;
	}

	string_format(dst, "status trigger at io %d/%d (-1 is disabled)\n",
			config.status_trigger_io.io,
			config.status_trigger_io.pin);

	return(app_action_normal);
}
开发者ID:chuanchen0,项目名称:esp8266-universal-io-bridge,代码行数:22,代码来源:application.c

示例5: parse_timeout

static int
parse_timeout(redisClient *c, robj *obj, int *p) {
    int v;
    if (parse_int(c, obj, &v) != 0) {
        return -1;
    }
    if (v < 0) {
        addReplyErrorFormat(c, "invalid timeout = %d", v);
        return -1;
    }
    *p = (v == 0) ? 100 : v;
    return 0;
}
开发者ID:107192468,项目名称:codis,代码行数:13,代码来源:slots.c

示例6: parse_orf_thresh_level

int
parse_orf_thresh_level(const char *arg, int *x)
{
    int tmp;
    if (parse_int(arg, &tmp)) {
        return -1;
    }
    if (tmp != 0 && tmp != 1 && tmp != 2) {
        return -1;
    }
    *x = tmp;
    return 0;
}
开发者ID:PapenfussLab,项目名称:reads_to_domains,代码行数:13,代码来源:common.c

示例7: parse_slot

static int
parse_slot(redisClient *c, robj *obj, int *p) {
    int v;
    if (parse_int(c, obj, &v) != 0) {
        return -1;
    }
    if (v < 0 || v >= HASH_SLOTS_SIZE) {
        addReplyErrorFormat(c, "invalid slot number = %d", v);
        return -1;
    }
    *p = v;
    return 0;
}
开发者ID:107192468,项目名称:codis,代码行数:13,代码来源:slots.c

示例8: parse_bool

bool parse_bool(const char *value, bool default_value)
{
    if (!value)
        return default_value;

    if (streq(value, "true") || streq(value, "on") || streq(value, "yes"))
        return true;

    if (streq(value, "false") || streq(value, "off") || streq(value, "no"))
        return false;

    return parse_int(value, default_value);
}
开发者ID:ktsaou,项目名称:lwan,代码行数:13,代码来源:lwan-config.c

示例9: find_if

/**
 * Looks up the column index for a range entry. It can be either a column name or a column number.
 * If it is a column number we subtract 1 because human user starts with index 1 rather than 0.
 */
size_t csv_tool::lookup_column_index(const std::string &s) {
	auto it = find_if(csv_data->mcolumns->begin(), csv_data->mcolumns->end(), [s](const meta_column_t &mc) { return mc.title == s; });
	if (it != csv_data->mcolumns->end()) {
		return it - csv_data->mcolumns->begin();
	}
	long long ltmp;
	bool success = parse_int(s, ltmp);
	if (success && ltmp <= csv_data->mcolumns->size()) {
		return ltmp-1;
	} else {
		return std::string::npos;
	}
}
开发者ID:chkhm,项目名称:qcsv,代码行数:17,代码来源:csv_tool.cpp

示例10: parse_value

static lwm2m_value parse_value(char *message, int message_len, lwm2m_type type) {
    lwm2m_value value;

    switch(type) {
        case INTEGER: {
            value.int_value = parse_int(message, message_len);
            break;
        }
        case DOUBLE: {
            value.double_value = parse_double(message, message_len);
            break;
        }
        case OPAQUE:
        case STRING: {
            char *string_value = (char *) malloc((size_t) (message_len + 1));
            memcpy(string_value, message, (size_t) message_len);
            string_value[message_len] = '\0';
            value.string_value = string_value;
            break;
        }
        case BOOLEAN: {
            int int_value = parse_int(message, message_len);
            value.bool_value = int_value ? true : false;
            break;
        }
        case LINK: {
            lwm2m_link link;
            link.object_id = parse_int(message + 2, 2);
            link.instance_id = parse_int(message, 2);
            value.link_value = link;
            break;
        }
        default:
            value.int_value = -1;
            break;
    }
    return value;
}
开发者ID:MrLynx93,项目名称:lynx-lwm2m,代码行数:38,代码来源:lwm2m_parser_deserialize.c

示例11: mput_cmd

static int mput_cmd(char* args) {
	int i = 0;
	int rv, k, v;
	
	if (th == NULL) {
		fprintf(stderr, "try `open' before `mput'\n");
		return -1;
	}
	
	while (args != NULL && args[0] != '\0') {
		rv = parse_int(&args, &k);
		if (rv != 0) {
			fprintf(stderr, "mput: argument %d not an integer number\n", i);
			return -1;
		}
		
		rv = parse_int(&args, &v);
		if (rv != 0) {
			fprintf(stderr, "mput: value for key %d expected\n", k);
			return -1;
		}
		tapioca_mput(th, &k, sizeof(int), &v, sizeof(int));
		i++;
	}
	
	if (i == 0) {
		fprintf(stderr, "mput: too few arguments\n");
		return -1;
	}
	
	rv = tapioca_mput_commit(th);
	if (rv < 0) {
		fprintf(stderr, "mput: failed.\n");
		return -1;
	}
	printf("committed (%d remote requests)\n", rv);
	return 0;
}
开发者ID:atomic77,项目名称:mosql-storage,代码行数:38,代码来源:tshell.c

示例12: ast_make_literal_atomic_int

static struct AstNode *parse_literal_int(struct DomNode *dom)
{
    long value;

    if (!dom_node_is_atom(dom)) {
        return NULL;
    }

    if (!parse_int(dom->atom, &value)) {
        return NULL;
    }

    return ast_make_literal_atomic_int(value);
}
开发者ID:k-stachowiak,项目名称:moon-lang,代码行数:14,代码来源:parse.c

示例13: switch

expr * simple_parser::parse_expr(scanner & s) {
    builtin_op op; 
    var * v;
    expr * r;
    scanner::token token;
    token = s.scan();
    switch (token) {
    case scanner::LEFT_PAREN:
        token = s.scan();
        if (token != scanner::ID_TOKEN)
            throw parser_error();
        if (m_builtin.find(s.get_id(), op)) {
            ptr_vector<expr> args;
            while (true) {
                expr * arg = parse_expr(s);
                if (arg) {
                    args.push_back(arg);
                }
                else {
                    expr * r = m_manager.mk_app(op.m_family_id, op.m_kind, args.size(), args.c_ptr());
                    m_exprs.push_back(r);
                    return r;
                }
            }
        }
        throw parser_error();
    case scanner::RIGHT_PAREN:
        return 0;
    case scanner::ID_TOKEN:
        if (m_builtin.find(s.get_id(), op)) {
            expr * r = m_manager.mk_const(op.m_family_id, op.m_kind);
            m_exprs.push_back(r);
            return r;
        }
        else if (m_vars.find(s.get_id(), v)) {
            return v;
        }
        throw parser_error();
    case scanner::INT_TOKEN:
        r = parse_int(s.get_number());
        m_exprs.push_back(r);
        return r;
    case scanner::FLOAT_TOKEN:
        r = parse_float(s.get_number());
        m_exprs.push_back(r);
        return r;
    default:
        throw parser_error();
    }
}
开发者ID:Moondee,项目名称:Artemis,代码行数:50,代码来源:simple_parser.cpp

示例14: cmd_disable

int
cmd_disable(mpd_unused int argc, char **argv, mpd_Connection *conn)
{
	int arg;

        if( ! parse_int( argv[0], &arg ) || arg <= 0 ) {
		DIE( "Not a positive integer\n" );
	} else {
		mpd_sendDisableOutputCommand( conn, ( arg - 1 ) );
	}

	mpd_finishCommand( conn );
	return cmd_outputs(0, NULL, conn);
}
开发者ID:OpenInkpot-archive,项目名称:iplinux-mpc,代码行数:14,代码来源:command.c

示例15: try_parse_int

static
int try_parse_int(int fd, int *val, const char *pname)
{
	int err;

	err = parse_int(fd, val);

	if (err)
		ERROR("error while parsing %s (%s)", pname,
		      err == -1 ? "end of file" :
		      err == -2 ? "not a number" : "number too big");

	return err;
}
开发者ID:ThangCZ,项目名称:dvb-apps,代码行数:14,代码来源:azap.c


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