本文整理汇总了C++中parse_number函数的典型用法代码示例。如果您正苦于以下问题:C++ parse_number函数的具体用法?C++ parse_number怎么用?C++ parse_number使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parse_number函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: ppc_rtas_clock_write
/* ****************************************************************** */
static ssize_t ppc_rtas_clock_write(struct file *file,
const char __user *buf, size_t count, loff_t *ppos)
{
struct rtc_time tm;
unsigned long nowtime;
int error = parse_number(buf, count, &nowtime);
if (error)
return error;
to_tm(nowtime, &tm);
error = rtas_call(rtas_token("set-time-of-day"), 7, 1, NULL,
tm.tm_year, tm.tm_mon, tm.tm_mday,
tm.tm_hour, tm.tm_min, tm.tm_sec, 0);
if (error)
printk(KERN_WARNING "error: setting the clock returned: %s\n",
ppc_rtas_process_error(error));
return count;
}
开发者ID:Antonio-Zhou,项目名称:Linux-2.6.11,代码行数:19,代码来源:rtas-proc.c
示例2: assert
std::pair< bool, bool > parser::parse(const char* begin, const char* end)
{
assert( !state_.empty() );
for ( ; begin != end && !state_.empty(); )
{
switch ( main_state( state_.top() ) )
{
case idle_parsing:
begin = eat_white_space(begin, end);
if ( begin != end )
{
state_.top() = parse_idle(*begin);
}
break;
case start_number_parsing:
begin = parse_number(begin, end);
break;
case start_array_parsing:
begin = parse_array(begin, end);
break;
case start_object_parsing:
begin = parse_object(begin, end);
break;
case start_string_parsing:
begin = parse_string(begin, end);
break;
case start_true_parsing:
case start_false_parsing:
case start_null_parsing:
begin = parse_literal(begin, end);
break;
default:
assert(!"should not happen");
}
}
// consume trailing whitespaces
if ( state_.empty() )
begin = eat_white_space(begin, end);
return std::make_pair( begin == end, state_.empty() );
}
开发者ID:TorstenRobitzki,项目名称:Sioux,代码行数:44,代码来源:json.cpp
示例3: parse_string
/* Parser core - when encountering text, process appropriately. */
static const char *parse_value(cJSON *item, const char *value, const char **ep)
{
if (!value)
{
/* Fail on null. */
return 0;
}
/* parse the different types of values */
if (!strncmp(value, "null", 4))
{
item->type = cJSON_NULL;
return value + 4;
}
if (!strncmp(value, "false", 5))
{
item->type = cJSON_False;
return value + 5;
}
if (!strncmp(value, "true", 4))
{
item->type = cJSON_True;
item->valueint = 1;
return value + 4;
}
if (*value == '\"')
{
return parse_string(item, value, ep);
}
if ((*value == '-') || ((*value >= '0') && (*value <= '9')))
{
return parse_number(item, value);
}
if (*value == '[')
{
return parse_array(item, value, ep);
}
if (*value == '{')
{
return parse_object(item, value, ep);
}
*ep=value;return 0; /* failure. */
}
开发者ID:albong,项目名称:ominsquash_prototype,代码行数:45,代码来源:cJSON.c
示例4: CI_submit
// Note: this function returns a pointer, but for some strange
// reason we must put the asterisk after the EXPORT.
CI_Result EXPORT * CI_submit( char const* input )
{
double number;
if( !parse_number( input, number ) )
return NULL;
std::ostringstream ss;
ss << number;
std::string result = ss.str();
CI_Result* res = new CI_Result;
res->input = component( input );
res->num_outputs = 1;
res->outputs = new CI_ResultComponent[1];
res->outputs[0] = component( result.c_str() );
return res;
}
开发者ID:dpacbach,项目名称:calcterm,代码行数:21,代码来源:defcalc.cpp
示例5: ppc_rtas_tone_volume_write
/* ****************************************************************** */
static ssize_t ppc_rtas_tone_volume_write(struct file *file,
const char __user *buf, size_t count, loff_t *ppos)
{
unsigned long volume;
int error = parse_number(buf, count, &volume);
if (error)
return error;
if (volume > 100)
volume = 100;
rtas_tone_volume = volume; /* save it for later */
error = rtas_call(rtas_token("set-indicator"), 3, 1, NULL,
TONE_VOLUME, 0, volume);
if (error)
printk(KERN_WARNING "error: setting tone volume returned: %s\n",
ppc_rtas_process_error(error));
return count;
}
开发者ID:CSCLOG,项目名称:beaglebone,代码行数:20,代码来源:rtas-proc.c
示例6: valid
version_number_t::version_number_t(const std::string &s)
: valid(false)
{
memset(parts, 0, 5 * sizeof(unsigned int));
if (debugging_requested("version_check"))
mxinfo(boost::format("version check: Parsing %1%\n") % s);
// Match the following:
// 4.4.0
// 4.4.0.5 build 123
// 4.4.0-build20101201-123
// mkvmerge v4.4.0
// * Optional prefix "mkvmerge v"
// * At least three digits separated by dots
// * Optional fourth digit separated by a dot
// * Optional build number that can have two forms:
// - " build nnn"
// - "-buildYYYYMMDD-nnn" (date is ignored)
static boost::regex s_version_number_re("^ (?: mkv[a-z]+ \\s+ v)?" // Optional prefix mkv... v
"(\\d+) \\. (\\d+) \\. (\\d+)" // Three digitss separated by dots; $1 - $3
"(?: \\. (\\d+) )?" // Optional fourth digit separated by a dot; $4
"(?:" // Optional build number including its prefix
" (?: \\s* build \\s*" // Build number prefix: either " build " or...
" | - build \\d{8} - )" // ... "-buildYYYYMMDD-"
" (\\d+)" // The build number itself; $5
")?",
boost::regex::perl | boost::regex::mod_x);
boost::smatch matches;
if (!boost::regex_search(s, matches, s_version_number_re))
return;
size_t idx;
for (idx = 1; 5 >= idx; ++idx)
if (!matches[idx].str().empty())
parse_number(matches[idx].str(), parts[idx - 1]);
valid = true;
if (debugging_requested("version_check"))
mxinfo(boost::format("version check: parse OK; result: %1%\n") % to_string());
}
开发者ID:Klaudit,项目名称:mkvtoolnix,代码行数:43,代码来源:version.cpp
示例7: parse_value
/* Parser core - when encountering text, process appropriately. */
static const char *ICACHE_FLASH_ATTR
parse_value(cJSON *item, const char *value)
{
if (!value) {
return 0; /* Fail on null. */
}
if (!strncmp(value, "null", 4)) {
item->type = cJSON_NULL;
return value + 4;
}
if (!strncmp(value, "false", 5)) {
item->type = cJSON_False;
return value + 5;
}
if (!strncmp(value, "true", 4)) {
item->type = cJSON_True;
item->valueint = 1;
return value + 4;
}
if (*value == '\"') {
return parse_string(item, value);
}
if (*value == '-' || (*value >= '0' && *value <= '9')) {
return parse_number(item, value);
}
if (*value == '[') {
return parse_array(item, value);
}
if (*value == '{') {
return parse_object(item, value);
}
ep = value;
return 0; /* failure. */
}
开发者ID:Slyer74,项目名称:esp-ginx,代码行数:43,代码来源:cJson.c
示例8: parse_primary_expr
// primary_expr ::= number
// bool
// ( expr )
//
Expr*
parse_primary_expr(Parser& p, Token_stream& ts)
{
if (ts.next()) {
switch (ts.next()->kind()) {
case number_tok: return parse_number(p, ts);
case lparen_tok: return parse_paren_enclosed(p, ts);
case bool_tok: return parse_bool(p, ts);
// // negative number
// case minus_tok: return parse_neg(p, ts);
default:
print("Unable to parse primary expr beginning with: ");
print(ts.next());
print("\n");
return nullptr;
}
}
return nullptr;
}
开发者ID:thehexia,项目名称:mathmagician,代码行数:24,代码来源:parse-expr.cpp
示例9: parse_value
/* value = 'null' | 'true' | 'false' | number | string | array | object */
static int parse_value(struct frozen *f) {
int ch = cur(f);
switch (ch) {
case '"':
TRY(parse_string(f));
break;
case '{':
TRY(parse_object(f));
break;
case '[':
TRY(parse_array(f));
break;
case 'n':
TRY(expect(f, "null", 4, JSON_TYPE_NULL));
break;
case 't':
TRY(expect(f, "true", 4, JSON_TYPE_TRUE));
break;
case 'f':
TRY(expect(f, "false", 5, JSON_TYPE_FALSE));
break;
case '-':
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
TRY(parse_number(f));
break;
default:
return ch == END_OF_STRING ? JSON_STRING_INCOMPLETE : JSON_STRING_INVALID;
}
return 0;
}
开发者ID:Henk-B,项目名称:frozen,代码行数:42,代码来源:frozen.c
示例10: mxerror
void
extract_cli_parser_c::add_extraction_spec() {
if ( (options_c::em_tracks != m_options.m_extraction_mode)
&& (options_c::em_timecodes_v2 != m_options.m_extraction_mode)
&& (options_c::em_attachments != m_options.m_extraction_mode))
mxerror(boost::format(Y("Unrecognized command line option '%1%'.\n")) % m_current_arg);
boost::regex s_track_id_re("^(\\d+)(:(.+))?$", boost::regex::perl);
boost::smatch matches;
if (!boost::regex_search(m_current_arg, matches, s_track_id_re)) {
if (options_c::em_attachments == m_options.m_extraction_mode)
mxerror(boost::format(Y("Invalid attachment ID/file name specification in argument '%1%'.\n")) % m_current_arg);
else
mxerror(boost::format(Y("Invalid track ID/file name specification in argument '%1%'.\n")) % m_current_arg);
}
track_spec_t track;
parse_number(matches[1].str(), track.tid);
std::string output_file_name;
if (matches[3].matched)
output_file_name = matches[3].str();
if (output_file_name.empty()) {
if (options_c::em_attachments == m_options.m_extraction_mode)
mxinfo(Y("No output file name specified, will use attachment name.\n"));
else
mxerror(boost::format(Y("Missing output file name in argument '%1%'.\n")) % m_current_arg);
}
track.out_name = output_file_name;
track.sub_charset = m_charset;
track.extract_cuesheet = m_extract_cuesheet;
track.extract_blockadd_level = m_extract_blockadd_level;
track.target_mode = m_target_mode;
m_options.m_tracks.push_back(track);
set_default_values();
}
开发者ID:Klaudit,项目名称:mkvtoolnix,代码行数:41,代码来源:extract_cli_parser.cpp
示例11: get_local_charset
std::string
get_local_charset() {
std::string lc_charset;
setlocale(LC_CTYPE, "");
#if defined(COMP_MINGW) || defined(COMP_MSC)
lc_charset = "CP" + to_string(GetACP());
#elif defined(SYS_SOLARIS)
int i;
lc_charset = nl_langinfo(CODESET);
if (parse_number(lc_charset, i))
lc_charset = std::string("ISO") + lc_charset + std::string("-US");
#elif HAVE_NL_LANGINFO
lc_charset = nl_langinfo(CODESET);
#elif HAVE_LOCALE_CHARSET
lc_charset = locale_charset();
#endif
return lc_charset;
}
开发者ID:Klaudit,项目名称:mkvtoolnix,代码行数:21,代码来源:locale.cpp
示例12: skip_space
Variant JSONReader::parse_value()
{
skip_space();
if (at('{'))
return parse_object();
if (at('['))
return parse_array();
if (at('"'))
return parse_string();
if (at_digit() || at('-'))
return parse_number();
if (skip_string("true"))
return Variant(true);
if (skip_string("false"))
return Variant(false);
if (skip_string("null"))
return Variant();
throw Exception(position(), "invalid value");
}
开发者ID:martin-ejdestig,项目名称:rayni-staging,代码行数:21,代码来源:json_reader.cpp
示例13: ppc_rtas_poweron_write
/* ****************************************************************** */
static ssize_t ppc_rtas_poweron_write(struct file *file,
const char __user *buf, size_t count, loff_t *ppos)
{
struct rtc_time tm;
unsigned long nowtime;
int error = parse_number(buf, count, &nowtime);
if (error)
return error;
power_on_time = nowtime; /* save the time */
to_tm(nowtime, &tm);
error = rtas_call(rtas_token("set-time-for-power-on"), 7, 1, NULL,
tm.tm_year, tm.tm_mon, tm.tm_mday,
tm.tm_hour, tm.tm_min, tm.tm_sec, 0 /* nano */);
if (error)
printk(KERN_WARNING "error: setting poweron time returned: %s\n",
ppc_rtas_process_error(error));
return count;
}
开发者ID:CSCLOG,项目名称:beaglebone,代码行数:22,代码来源:rtas-proc.c
示例14: getToken
/*
* parenthesized expression or value
*/
double ExpParser::parse_level10()
{
// check if it is a parenthesized expression
if (token_type == DELIMETER)
{
if (token[0] == '(' && token[1] == '\0')
{
getToken();
double ans = parse_level2();
if (token_type != DELIMETER || token[0] != ')' || token[1] || '\0')
{
throw Error(row(), col(), 3);
}
getToken();
return ans;
}
}
// if not parenthesized then the expression is a value
return parse_number();
}
开发者ID:hcmlab,项目名称:mobileSSI,代码行数:24,代码来源:expparser.cpp
示例15: dt_parse_iso_time_basic
size_t
dt_parse_iso_time_basic(const char *str, size_t len, int *sp, int *fp) {
const unsigned char *p;
int h, m, s, f;
size_t n;
p = (const unsigned char *)str;
n = count_digits(p, 0, len);
m = s = f = 0;
switch (n) {
case 2: /* hh */
h = parse_number(p, 0, 2);
goto hms;
case 4: /* hhmm */
h = parse_number(p, 0, 2);
m = parse_number(p, 2, 2);
goto hms;
case 6: /* hhmmss */
h = parse_number(p, 0, 2);
m = parse_number(p, 2, 2);
s = parse_number(p, 4, 2);
break;
default:
return 0;
}
/* hhmmss.fffffffff */
if (n < len && (p[n] == '.' || p[n] == ',')) {
size_t r = parse_fraction_digits(p, ++n, len, &f);
if (!r)
return 0;
n += r;
}
hms:
if (h > 23 || m > 59 || s > 59) {
if (!(h == 24 && m == 0 && s == 0 && f == 0))
return 0;
}
if (sp)
*sp = h * 3600 + m * 60 + s;
if (fp)
*fp = f;
return n;
}
开发者ID:chansen,项目名称:p5-time-moment,代码行数:46,代码来源:dt_parse_iso.c
示例16: parse_value
static int parse_value(lua_State *L, parse_state *state) {
eat_whitespace(state);
char c = *state->ptr;
switch (c) {
case '"': return parse_string(L, state);
case '{': return parse_object(L, state);
case '[': return parse_array(L, state);
case 't':
case 'f': return parse_boolean(L, state);
case 'n': return parse_null(L, state);
case '-':
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9': return parse_number(L, state);
default: return push_parse_error(L, state, "unexpected character");
}
}
开发者ID:JakobssonAndre,项目名称:lotech,代码行数:24,代码来源:ltjson.cpp
示例17: prompt_number
int prompt_number(const char *prompt, uint64_t *number, unsigned int base) {
char *string = readline(prompt);
int start=0;
if(string == NULL) {return -1; };
{ /* Trim Whitespace */
int i=strlen(string);
while (isspace(string[i])) string[i] = 0;
while(isspace(string[start])) ++start;
}
if(strlen(string+start) == 0) {
free(string);
return -1;
}
if(parse_number(string+start, base, number)) {
free(string);
return -1;
};
free(string);
return 0;
}
开发者ID:lucasad,项目名称:base-conv,代码行数:24,代码来源:main.c
示例18: assert
FILE *fopen_generic(const char *path, const char *mode, int debug)
{
assert(path != NULL);
assert(mode != NULL);
FILE *file = NULL;
uint32_t port = 0;
if (strncasecmp(path, "aa:", 3) == 0) {
if (parse_number(path + 3, &port) == 0)
assert(0);
//file = fopen_aaflash(port, mode, debug);
} else if (strncasecmp(path, "rw:", 3) == 0) {
assert(0);
//file = fopen_rwflash(path + 3, mode, debug);
} else {
file = fopen(path, mode);
}
if (file == NULL)
ERRNO(errno);
return file;
}
开发者ID:open-power,项目名称:ffs,代码行数:24,代码来源:command.c
示例19: I2cWriteReadCommand
static int I2cWriteReadCommand(int argc, char const ** argv) {
if (argc < 2 || argc > 18) return -1;
uint8_t addr = (uint8_t) parse_hex(argv[0]);
++argv;
--argc;
size_t readlen = (size_t) parse_number(argv[argc - 1]);
--argc;
uint8_t buf[16];
for (int i = 0; i < argc; ++i) {
buf[i] = (uint8_t) parse_hex(argv[i]);
}
if (ERROR_NONE != I2cWriteRead(addr, buf, argc, buf, readlen)) return -3;
for (int i = 0; i < readlen; ++i) {
printf("%02x ", buf[i]);
}
printf("\r\n");
return 0;
}
开发者ID:ytai,项目名称:PixieGuitar,代码行数:24,代码来源:i2c.c
示例20: parse_date_string
static time_t
parse_date_string(const char *str_to_parse)
{
char year[5];
char month[3];
char day[3];
char hour[3];
char minute[3];
char second[3];
struct tm t;
time_t temp_time;
memset(year, 0, 5);
memset(month, 0, 3);
memset(day, 0, 3);
memset(hour, 0, 3);
memset(minute, 0, 3);
memset(second, 0, 3);
if (split_date(year, month, day, hour, minute, second, str_to_parse) == 1)
{
memset((void *)&t, 0, sizeof(struct tm));
t.tm_isdst = 0;
t.tm_mday = 1;
if (!((parse_number(year, 1900, 2037, &(t.tm_year)) == -1) ||
(parse_number(month, 1, 12, &(t.tm_mon)) == -1) ||
(parse_number(day, 1, 31, &(t.tm_mday)) == -1) ||
(parse_number(hour, 0, 9999, &(t.tm_hour)) == -1) ||
(parse_number(minute, 0, 59, &(t.tm_min)) == -1) ||
(parse_number(second, 0, 59, &(t.tm_sec)) == -1)))
{
t.tm_year -= 1900;
--(t.tm_mon);
temp_time = mktime(&t);
if (temp_time != -1)
return temp_time;
}
}
exit_error(PARAMETER_PROBLEM,
"invalid date `%s' specified, should be YYYY[:MM[:DD[:hh[:mm[:ss]]]]] format", str_to_parse);
}
开发者ID:StephenMacras,项目名称:dsl-n55u-bender,代码行数:41,代码来源:libipt_time.c
注:本文中的parse_number函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论