本文整理汇总了C++中parse_int函数的典型用法代码示例。如果您正苦于以下问题:C++ parse_int函数的具体用法?C++ parse_int怎么用?C++ parse_int使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parse_int函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: extract_subst_tail
/* extract substitution tail from the command buffer */
char extract_subst_tail( const char **ibufpp, int *gflagsp, int *snump,
const char isglobal )
{
const char delimiter = **ibufpp;
*gflagsp = *snump = 0;
if( delimiter == '\n' ) { stlen = 0; *gflagsp = GPR; return 1; }
if( !extract_subst_template( ibufpp, isglobal ) ) return 0;
if( **ibufpp == '\n' ) { *gflagsp = GPR; return 1; }
if( **ibufpp == delimiter ) ++(*ibufpp);
if( **ibufpp >= '1' && **ibufpp <= '9' ) return parse_int( snump, *ibufpp, ibufpp );
if( **ibufpp == 'g' ) { ++(*ibufpp); *gflagsp = GSG; return 1; }
return 1;
}
开发者ID:ystk,项目名称:debian-ed,代码行数:15,代码来源:regex.c
示例17: parse_int_mask
int parse_int_mask(uint32_t *val, uint32_t *mask, const char *str2)
{
char str[MAX_STR_LEN_PROC];
char *mask_str;
if (parse_vars(str, sizeof(str), str2))
return -1;
mask_str = strchr(str, '&');
if (mask_str == NULL) {
set_errf("Missing '&' when parsing mask");
return -2;
}
*mask_str = 0;
if (parse_int(val, str))
return -1;
if (parse_int(mask, mask_str + 1))
return -1;
return 0;
}
开发者ID:nvf-crucio,项目名称:PROX,代码行数:24,代码来源:parse_utils.c
示例18: read
/**
* Reads the NMEA sentence into the specified structure.
*
* @param[out] nmea Structure to hold the parsed data.
* @param[in] s Start of the string to parse (inclusive).
* @param[in] e End of the string to parse (exclusive).
* @retval -1 Parameter failure, parsing error.
* @retval 0 Success
*/
static int read(struct nmea_t * nmea, const char * s, const char * e)
{
struct nmea_rte_t * v;
int state = 0;
const char * p;
if (nmea == NULL || s == NULL || e == NULL) return -1;
nmea->type = NMEA_RTE;
v = &nmea->sentence.rte;
p = find_token_end(s);
for (state = -1; state < 13 && s < e; ++state) {
switch (state) {
case 0: if (parse_int(s, p, &v->n_messages) != p) return -1; break;
case 1: if (parse_int(s, p, &v->message_number) != p) return -1; break;
case 2: v->message_mode = (s == p) ? NMEA_COMPLETE_ROUTE : *s; break;
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
case 10:
case 11:
case 12:
if ((unsigned int)(p-s+1) < sizeof(v->waypoint_id[state-3])
&& parse_str(s, p, v->waypoint_id[state-3]) != p)
return -1;
break;
default: break;
}
s = p + 1;
p = find_token_end(s);
}
return 0;
}
开发者ID:mariokonrad,项目名称:navd,代码行数:45,代码来源:nmea_sentence_gprte.c
示例19: authBasicParse
static void
authBasicParse(authScheme * scheme, int n_configured, char *param_str)
{
if (scheme->scheme_data == NULL) {
assert(basicConfig == NULL);
/* this is the first param to be found */
scheme->scheme_data = xmalloc(sizeof(auth_basic_config));
memset(scheme->scheme_data, 0, sizeof(auth_basic_config));
basicConfig = scheme->scheme_data;
basicConfig->basicAuthRealm = xstrdup("Squid proxy-caching web server");
basicConfig->authenticateChildren = 5;
basicConfig->credentialsTTL = 2 * 60 * 60; /* two hours */
}
basicConfig = scheme->scheme_data;
if (strcasecmp(param_str, "program") == 0) {
if (basicConfig->authenticate)
wordlistDestroy(&basicConfig->authenticate);
parse_wordlist(&basicConfig->authenticate);
} else if (strcasecmp(param_str, "children") == 0) {
parse_int(&basicConfig->authenticateChildren);
} else if (strcasecmp(param_str, "concurrency") == 0) {
parse_int(&basicConfig->authenticateConcurrency);
} else if (strcasecmp(param_str, "realm") == 0) {
parse_eol(&basicConfig->basicAuthRealm);
} else if (strcasecmp(param_str, "credentialsttl") == 0) {
parse_time_t(&basicConfig->credentialsTTL);
} else if (strcasecmp(param_str, "casesensitive") == 0) {
parse_onoff(&basicConfig->casesensitive);
} else if (strcasecmp(param_str, "blankpassword") == 0) {
parse_onoff(&basicConfig->blankpassword);
} else if (strcasecmp(param_str, "utf8") == 0) {
parse_onoff(&basicConfig->utf8);
} else {
debug(29, 0) ("unrecognised basic auth scheme parameter '%s'\n", param_str);
}
}
开发者ID:CoolerVoid,项目名称:squid,代码行数:36,代码来源:auth_basic.c
示例20: application_function_i2c_read
irom static app_action_t application_function_i2c_read(const string_t *src, string_t *dst)
{
int size, current;
i2c_error_t error;
uint8_t bytes[32];
uint32_t start, stop, clocks, spent;
if(parse_int(1, src, &size, 0) != parse_ok)
{
string_cat(dst, "i2c-read: missing byte count\n");
return(app_action_error);
}
if(size > (int)sizeof(bytes))
{
string_format(dst, "i2c-read: read max %d bytes\n", sizeof(bytes));
return(app_action_error);
}
start = system_get_time();
if((error = i2c_receive(i2c_address, size, bytes)) != i2c_error_ok)
{
string_cat(dst, "i2c_read");
i2c_error_format_string(dst, error);
string_cat(dst, "\n");
i2c_reset();
return(app_action_error);
}
stop = system_get_time();
string_format(dst, "> i2c_read: read %d bytes from %02x:", size, i2c_address);
for(current = 0; current < size; current++)
string_format(dst, " %02x", bytes[current]);
string_cat(dst, "\n");
clocks = (size + 1) * 20U;
spent = (stop - start) * 1000U;
string_format(dst, "> transferred %u bytes in %u scl clocks\n", size + 1U, clocks);
string_format(dst, "> time spent: %u microseconds, makes %u kHz i2c bus\n",
spent / 1000U, 1000000U / (spent / clocks));
return(app_action_normal);
}
开发者ID:chendong,项目名称:esp8266-universal-io-bridge,代码行数:48,代码来源:application.c
注:本文中的parse_int函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论