• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ parseNumber函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了parseNumber函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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) );
}
开发者ID:1107979819,项目名称:OculusVRStudy,代码行数:48,代码来源:OVR_JSON.cpp


示例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);
}
开发者ID:cantona,项目名称:iphonelinux,代码行数:45,代码来源:fs.c


示例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);
}
开发者ID:tritenour01,项目名称:raytracer,代码行数:18,代码来源:sceneParser.cpp


示例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;
	}
}
开发者ID:xaberus,项目名称:spreadsheet,代码行数:18,代码来源:Formula.c


示例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);
}
开发者ID:baliking,项目名称:iphonelinux,代码行数:18,代码来源:commands.c


示例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");
}
开发者ID:ajgappmark,项目名称:GeexOS,代码行数:49,代码来源:demangle.cpp


示例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);
}
开发者ID:simtr,项目名称:The-Powder-Toy,代码行数:44,代码来源:TPTScriptInterface.cpp


示例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");
}
开发者ID:RcRonco,项目名称:folly,代码行数:19,代码来源:json.cpp


示例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;
}
开发者ID:serghei,项目名称:kde3-kdepim,代码行数:42,代码来源:parser.cpp


示例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.
}
开发者ID:kkowar,项目名称:aJson,代码行数:42,代码来源:aJSON.cpp


示例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 { };
}
开发者ID:ollie314,项目名称:webkit,代码行数:21,代码来源:SVGLengthValue.cpp


示例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);
}
开发者ID:Ebola-chan,项目名称:The-Powder-Toy,代码行数:40,代码来源:TPTScriptInterface.cpp


示例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;
    }
开发者ID:micro-os-plus,项目名称:micro-os-plus-i,代码行数:39,代码来源:Parser.cpp


示例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);
    }
}
开发者ID:PeiLinCN,项目名称:CEUSBKWrapper,代码行数:22,代码来源:ceusbkwrappertest.cpp


示例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;

}
开发者ID:emfol,项目名称:tests,代码行数:22,代码来源:whatfloat.c


示例16: StringView

ExceptionOr<void> SVGAngleValue::setValueAsString(const String& value)
{
    if (value.isEmpty()) {
        m_unitType = SVG_ANGLETYPE_UNSPECIFIED;
        return { };
    }

    auto upconvertedCharacters = StringView(value).upconvertedCharacters();
    const UChar* ptr = upconvertedCharacters;
    const UChar* end = ptr + value.length();

    float valueInSpecifiedUnits = 0;
    if (!parseNumber(ptr, end, valueInSpecifiedUnits, false))
        return Exception { SYNTAX_ERR };

    auto unitType = parseAngleType(ptr, end);
    if (unitType == SVG_ANGLETYPE_UNKNOWN)
        return Exception { SYNTAX_ERR };

    m_unitType = unitType;
    m_valueInSpecifiedUnits = valueInSpecifiedUnits;
    return { };
}
开发者ID:caiolima,项目名称:webkit,代码行数:23,代码来源:SVGAngleValue.cpp


示例17: assert

void json_value::deserialize(std::stringstream &input, memory_pool &pool)
{
  assert(m_type == JSON_UNINIT);

  input >> std::ws;
  char c = input.peek();

  switch(c)
  {
    case '{':
      m_type = JSON_OBJECT;
      parseObject(input, pool);
      break;
    case '[':
      m_type = JSON_ARRAY;
      parseArray(input, pool);
      break; 
    case '"':
      m_type = JSON_STRING;
      parseString(input, pool);
      break;
    case 't':
    case 'f':
      m_type = JSON_BOOL;
      parseBool(input);
      break;
    case 'n':
      m_type = JSON_NULL;
      parseNull(input);
      break;
    default:
      m_type = JSON_NUMBER;
      parseNumber(input);
      break;
  }
}
开发者ID:alvalea,项目名称:alm,代码行数:36,代码来源:json.cpp


示例18: setValueAsString

void SVGLength::setValueAsString(const String& string, ExceptionCode& ec)
{
    if (string.isEmpty())
        return;

    float convertedNumber = 0;
    const UChar* ptr = string.characters();
    const UChar* end = ptr + string.length();

    if (!parseNumber(ptr, end, convertedNumber, false)) {
        ec = SYNTAX_ERR;
        return;
    }

    SVGLengthType type = stringToLengthType(ptr, end);
    ASSERT(ptr <= end);
    if (type == LengthTypeUnknown) {
        ec = SYNTAX_ERR;
        return;
    }

    m_unit = storeUnit(extractMode(m_unit), type);
    m_valueInSpecifiedUnits = convertedNumber;
}
开发者ID:dslab-epfl,项目名称:warr,代码行数:24,代码来源:SVGLength.cpp


示例19: strKey

void RenJS::parseParam(const CString& strParam, RenJS::Node& node)
{
	int index = strParam.Find("=");

	CString strKey(strParam.Left(index));
	CString strValue(strParam.Right(strParam.GetLength() - 1 - index));

	if (strKey == "i")
	{
		parseId(strValue, node);
	}
	else if (strKey == "p")
	{
		parseCoordinate(strValue, node);
	}
	else if (strKey == "m")
	{
		parseNumber(strValue, node);
	}
	else if (strKey == "f")
	{
		parseParent(strValue, node);
	}
	else if (strKey == "c")
	{
		parseChildren(strValue, node);
	}
	else if (strKey == "co")
	{
		parseComment(strValue, node);
	}
	else if (strKey == "k")
	{
		parseBoardText(strValue, node);
	}
}
开发者ID:gomoku,项目名称:RenLib,代码行数:36,代码来源:RenJS.cpp


示例20: parseFloatPoint3

bool parseFloatPoint3(const CharType*& current, const CharType* end, FloatPoint& point1, FloatPoint& point2, FloatPoint& point3)
{
    float x1;
    float y1;
    float x2;
    float y2;
    float x3;
    float y3;
    if (!parseNumber(current, end, x1)
        || !parseNumber(current, end, y1)
        || !parseNumber(current, end, x2)
        || !parseNumber(current, end, y2)
        || !parseNumber(current, end, x3)
        || !parseNumber(current, end, y3))
        return false;
    point1 = FloatPoint(x1, y1);
    point2 = FloatPoint(x2, y2);
    point3 = FloatPoint(x3, y3);
    return true;
}
开发者ID:kublaj,项目名称:blink,代码行数:20,代码来源:SVGParserUtilities.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ parseObject函数代码示例发布时间:2022-05-30
下一篇:
C++ parseNs函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap