本文整理汇总了C++中parseNumber函数的典型用法代码示例。如果您正苦于以下问题:C++ parseNumber函数的具体用法?C++ parseNumber怎么用?C++ parseNumber使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parseNumber函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseString
//-----------------------------------------------------------------------------
// Parser core - when encountering text, process appropriately.
const char* JSON::parseValue(const char* buff, const char** perror)
{
if (perror)
*perror = 0;
if (!buff)
return NULL; // Fail on null.
if (!strncmp(buff,"null",4))
{
Type = JSON_Null;
return buff+4;
}
if (!strncmp(buff,"false",5))
{
Type = JSON_Bool;
Value = "false";
dValue = 0;
return buff+5;
}
if (!strncmp(buff,"true",4))
{
Type = JSON_Bool;
Value = "true";
dValue = 1;
return buff+4;
}
if (*buff=='\"')
{
return parseString(buff, perror);
}
if (*buff=='-' || (*buff>='0' && *buff<='9'))
{
return parseNumber(buff);
}
if (*buff=='[')
{
return parseArray(buff, perror);
}
if (*buff=='{')
{
return parseObject(buff, perror);
}
return AssignError(perror, StringUtils::Va( "Syntax Error: Invalid syntax: '%s'", buff) );
}
示例2: fs_cmd_cat
void fs_cmd_cat(int argc, char** argv) {
Volume* volume;
io_func* io;
if(argc < 3) {
bufferPrintf("usage: %s <partition> <file>\r\n", argv[0]);
return;
}
io = bdev_open(parseNumber(argv[1]));
if(io == NULL) {
bufferPrintf("fs: cannot read partition!\r\n");
return;
}
volume = openVolume(io);
if(volume == NULL) {
bufferPrintf("fs: cannot openHFS volume!\r\n");
return;
}
HFSPlusCatalogRecord* record;
record = getRecordFromPath(argv[2], volume, NULL, NULL);
if(record != NULL) {
if(record->recordType == kHFSPlusFileRecord) {
uint8_t* buffer;
uint32_t size = readHFSFile((HFSPlusCatalogFile*)record, &buffer, volume);
buffer = realloc(buffer, size + 1);
buffer[size] = '\0';
bufferPrintf("%s\r\n", buffer);
free(buffer);
} else {
bufferPrintf("Not a file, record type: %x\r\n", record->recordType);
}
} else {
bufferPrintf("No such file or directory\r\n");
}
free(record);
closeVolume(volume);
CLOSE(io);
}
示例3: parseToken
void SceneParser::parseDirectionalLight(void)
{
parseToken(Scanner::LeftCurly);
Vector3 dir;
parseVector(dir);
Vector3 color;
parseVector(color);
float intensity;
parseNumber(intensity);
Light* l = new DirectionalLight(raytracer, dir, color, intensity);
raytracer->addLight(l);
parseToken(Scanner::RightCurly);
}
示例4: parseValue
Object * parseValue(Collector * c, Tokenizer * tt) {
TokenType t = tokenizerNext(tt);
switch (t) {
case TOK_CELLID:
return parseReferenceOrRange(c, tt);
case TOK_NUMBER:
return parseNumber(c, tt);
case TOK_STRING:
return parseString(c, tt);
case TOK_ID:
return parseCall(c, tt);
case TOK_LBRACKET:
return parsePattern(c, tt);
default:
return NULL;
}
}
示例5: cmd_go
void cmd_go(int argc, char** argv) {
uint32_t address;
if(argc < 2) {
address = 0x09000000;
} else {
address = parseNumber(argv[1]);
}
bufferPrintf("Jumping to 0x%x (interrupts disabled)\r\n", address);
// make as if iBoot was called from ROM
pmu_set_iboot_stage(0x1F);
udelay(100000);
chainload(address);
}
示例6: literal
/*
<expr-primary> ::= L <type> <value number> E # integer literal
::= L <type> <value float> E # floating literal (ignored)
::= L <mangled-name> E # external name
*/
static int parseExprPrimary(LargeStaticString &src, LargeStaticString &dest, demangle_t &data)
{
START("ExprPrimary");
// We should be looking at an 'L'.
if (src[0] != 'L')
END_FAIL("ExprPrimary");
src.stripFirst(1);
// HACK:: We don't want the full "unsigned int" nonsense, if it's a builtin type we use our
// own handlers. Else we fall back on parseType.
const char *cookie = 0;
switch(src[0])
{
case 'i': src.stripFirst(1);
break;
case 'j': cookie = "u"; src.stripFirst(1);
break;
case 'l': cookie = "l"; src.stripFirst(1);
break;
case 'm': cookie = "ul"; src.stripFirst(1);
break;
default:
{
dest += '(';
if (parseType(src, dest, data) == FAIL)
END_FAIL("ExprPrimary");
dest += ')';
}
}
int n;
if (parseNumber(src, dest, data, n) == FAIL)
END_FAIL("ExprPrimary");
dest += static_cast<ssize_t>(n);
dest += cookie;
if (src[0] != 'E')
END_FAIL("ExprPrimary");
src.stripFirst(1);
/// \todo implement external mangled names.
END_SUCCESS("ExprPrimary");
}
示例7: AnyType
AnyType TPTScriptInterface::eval(std::deque<String> * words)
{
if(words->size() < 1)
return AnyType(TypeNull, ValueValue());
String word = words->front(); words->pop_front();
ValueType wordType = testType(word);
switch(wordType)
{
case TypeFunction:
if(word == "set")
return tptS_set(words);
else if(word == "create")
return tptS_create(words);
else if(word == "delete" || word == "kill")
return tptS_delete(words);
else if(word == "load")
return tptS_load(words);
else if(word == "reset")
return tptS_reset(words);
else if(word == "bubble")
return tptS_bubble(words);
else if(word == "quit")
return tptS_quit(words);
break;
case TypeNumber:
return NumberType(parseNumber(word));
case TypeFloat:
return FloatType(atof(word.ToUtf8().c_str()));
case TypePoint:
{
int x, y;
if(String::Split comma = word.SplitNumber(x))
if(comma.After().BeginsWith(","))
if(comma.After().Substr(1).SplitNumber(y))
return PointType(x, y);
return PointType(0, 0);
}
case TypeString:
return StringType(word);
default:
break;
}
return StringType(word);
}
示例8: parseValue
dynamic parseValue(Input& in) {
RecursionGuard guard(in);
in.skipWhitespace();
return *in == '[' ? parseArray(in) :
*in == '{' ? parseObject(in) :
*in == '\"' ? parseString(in) :
(*in == '-' || (*in >= '0' && *in <= '9')) ? parseNumber(in) :
in.consume("true") ? true :
in.consume("false") ? false :
in.consume("null") ? nullptr :
in.consume("Infinity") ?
(in.getOpts().parse_numbers_as_strings ? (dynamic)"Infinity" :
(dynamic)std::numeric_limits<double>::infinity()) :
in.consume("NaN") ?
(in.getOpts().parse_numbers_as_strings ? (dynamic)"NaN" :
(dynamic)std::numeric_limits<double>::quiet_NaN()) :
in.error("expected json value");
}
示例9: if
bool Parser::Impl::parseArgument()
{
// argument := string-list / number / tag
if(!obtainToken() || atEnd())
return false;
if(token() == Lexer::Number)
{
if(!parseNumber())
{
assert(error());
return false;
}
return true;
}
else if(token() == Lexer::Tag)
{
if(scriptBuilder())
scriptBuilder()->taggedArgument(tokenValue());
consumeToken();
return true;
}
else if(isStringToken())
{
if(scriptBuilder())
scriptBuilder()->stringArgument(tokenValue(), token() == Lexer::MultiLineString, QString::null);
consumeToken();
return true;
}
else if(token() == Lexer::Special && tokenValue() == "[")
{
if(!parseStringList())
{
assert(error());
return false;
}
return true;
}
return false;
}
示例10: parseString
// Parser core - when encountering text, process appropriately.
const char*
aJsonClass::parseValue(aJsonObject *item, const char *value)
{
if (!value)
return NULL; // Fail on null.
if (!strncmp(value, "null", 4))
{
item->type = aJson_NULL;
return value + 4;
}
if (!strncmp(value, "false", 5))
{
item->type = aJson_False;
item->value.valuebool = 0;
return value + 5;
}
if (!strncmp(value, "true", 4))
{
item->type = aJson_True;
item->value.valuebool = 1;
return value + 4;
}
if (*value == '\"')
{
return parseString(item, value);
}
if (*value == '-' || (*value >= '0' && *value <= '9'))
{
return parseNumber(item, value);
}
if (*value == '[')
{
return parseArray(item, value);
}
if (*value == '{')
{
return parseObject(item, value);
}
return 0; // failure.
}
示例11: StringView
ExceptionOr<void> SVGLengthValue::setValueAsString(const String& string)
{
if (string.isEmpty())
return { };
float convertedNumber = 0;
auto upconvertedCharacters = StringView(string).upconvertedCharacters();
const UChar* ptr = upconvertedCharacters;
const UChar* end = ptr + string.length();
if (!parseNumber(ptr, end, convertedNumber, false))
return Exception { SYNTAX_ERR };
auto type = parseLengthType(ptr, end);
if (type == LengthTypeUnknown)
return Exception { SYNTAX_ERR };
m_unit = storeUnit(extractMode(m_unit), type);
m_valueInSpecifiedUnits = convertedNumber;
return { };
}
示例12: AnyType
AnyType TPTScriptInterface::eval(std::deque<std::string> * words)
{
if(words->size() < 1)
return AnyType(TypeNull, ValueValue());
std::string word = words->front(); words->pop_front();
char * rawWord = (char *)word.c_str();
ValueType wordType = testType(word);
switch(wordType)
{
case TypeFunction:
if(word == "set")
return tptS_set(words);
else if(word == "create")
return tptS_create(words);
else if(word == "delete" || word == "kill")
return tptS_delete(words);
else if(word == "load")
return tptS_load(words);
else if(word == "reset")
return tptS_reset(words);
else if(word == "bubble")
return tptS_bubble(words);
else if(word == "quit")
return tptS_quit(words);
break;
case TypeNumber:
return NumberType(parseNumber(rawWord));
case TypeFloat:
return FloatType(atof(rawWord));
case TypePoint:
{
int pointX, pointY;
sscanf(rawWord, "%d,%d", &pointX, &pointY);
return PointType(pointX, pointY);
}
case TypeString:
return StringType(word);
}
return StringType(word);
}
示例13: skipSpaces
OSReturn_t
Parser::parseByteArray(uint8_t* pByteArray, std::size_t size,
std::size_t *pLength)
{
OSReturn_t r;
uint32_t n_32, i;
uchar_t ch;
ch = skipSpaces();
r = skipCharacter('[');
if (r != OSReturn::OS_OK)
return r;
for (i = 0; hasMoreContent(); i++)
{
if (i == size)
return OSReturn::OS_NOT_ENOUGH_SPACE;
r = parseNumber(n_32);
if (r != OSReturn::OS_OK)
return r;
pByteArray[i] = (uint8_t) n_32;
r = skipCharacter(',');
if (r != OSReturn::OS_OK)
break;
}
r = skipCharacter(']');
if (r != OSReturn::OS_OK)
return r;
*pLength = i + 1;
return OSReturn::OS_OK;
}
示例14: resetDevice
static void resetDevice(char line[])
{
// Parse the device index
DWORD devIdx = 0;
line = parseNumber(line, devIdx);
if (!line) {
printf("Please provide a decimal device number following the command\n");
return;
}
if (devIdx >= gDeviceListSize || devIdx < 0) {
printf("Invalid device index '%d' provided\n", devIdx);
return;
}
UKW_DEVICE device = gDeviceList[devIdx];
BOOL result = UkwResetDevice(device);
if (!result) {
printf("Failed to reset device '%d': %d\n", devIdx, GetLastError());
} else {
printf("Device '%d' reset\n", devIdx);
}
}
示例15: main
int main(int argc, char *argv[]) {
int num;
if ( argc < 2 ) {
puts("Numeric argument expected...");
goto _exit;
}
num = parseNumber(argv[1]);
printf(
"Supplied integer: %d\n"
"Float interpretation: %.8f\n",
num,
*(float *)&num
);
_exit:
return EXIT_SUCCESS;
}