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

C++ parseFloat函数代码示例

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

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



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

示例1: executeElevatorServices

  void executeElevatorServices(char input[])
  {
    std::string inputStr(input);

    switch (input[0]) {
    case 'o':
      open_close_elev_doors_client.call(openElevDoorsCall);
      break;
    case 'c':
      open_close_elev_doors_client.call(closeElevDoorsCall);
      break;
    case 's':
      setElevPropsCall.request.velocity = parseFloat(inputStr.substr(1));
      set_elev_props_client.call(setElevPropsCall);
      break;
    case 'f':
      setElevPropsCall.request.force = parseFloat(inputStr.substr(1));
      set_elev_props_client.call(setElevPropsCall);
      break;
    default:
      try {
        targetFloorCall.request.target_floor = std::stoi(inputStr);
        target_floor_elev_client.call(targetFloorCall);
      } catch (std::exception const & e) {
        std::cout << "Unknown command" << std::endl;
      }
    };
  }
开发者ID:clearpathrobotics,项目名称:dynamic_gazebo_models,代码行数:28,代码来源:keyboard_op.cpp


示例2: parseVector3f

  sf::Vector3f parseVector3f(const std::string theValue, const sf::Vector3f theDefault)
  {
    sf::Vector3f anResult = theDefault;

    // Try to find the first comma
    size_t anComma1Offset = theValue.find_first_of(',', 0);
    if(anComma1Offset != std::string::npos)
    {
      float anX = parseFloat(theValue.substr(0, anComma1Offset), theDefault.x);

      // Try to find the next comma
      size_t anComma2Offset = theValue.find_first_of(',',anComma1Offset+1);
      if(anComma2Offset != std::string::npos)
      {
        float anY = parseFloat(theValue.substr(anComma1Offset+1, anComma2Offset), theDefault.y);
        float anZ = parseFloat(theValue.substr(anComma2Offset+1), theDefault.z);
        
        // Now that all 3 values have been parsed, return the Vector3f found
        anResult.x = anX;
        anResult.y = anY;
        anResult.z = anZ;
      }
    }

    // Return the result found or theDefault assigned above
    return anResult;
  }
开发者ID:Jose-Luis,项目名称:age,代码行数:27,代码来源:StringUtil.cpp


示例3: parseVector3f

sf::Vector3f parseVector3f(const std::string theValue, const sf::Vector3f theDefault)
{
	sf::Vector3f anResult = theDefault;

	// Buscamos la primera coma
	size_t anComma1Offset = theValue.find_first_of(',', 0);
	if (anComma1Offset != std::string::npos)
	{
		float anX = parseFloat(theValue.substr(0, anComma1Offset), theDefault.x);

		// Buscamos la siguiente coma
		size_t anComma2Offset = theValue.find_first_of(',', anComma1Offset + 1);
		if (anComma2Offset != std::string::npos)
		{
			float anY = parseFloat(theValue.substr(anComma1Offset + 1, anComma2Offset), theDefault.y);
			float anZ = parseFloat(theValue.substr(anComma2Offset + 1), theDefault.z);

			// Ahora que los 3 valores han sido parseados, devolvemos el vector encontrado
			anResult.x = anX;
			anResult.y = anY;
			anResult.z = anZ;
		}
	}

	// Devolvemos el resultado que hemos encontrado o el valor theDefault que se nos ha proporcionado
	return anResult;
}
开发者ID:InExtremaRes,项目名称:Genbeta-Dev-Engine,代码行数:27,代码来源:StringUtil.cpp


示例4: svgParseLine

static void svgParseLine(struct SVGParser* p, const char** attr)
{
	float x1 = 0.0;
	float y1 = 0.0;
	float x2 = 0.0;
	float y2 = 0.0;
	int i;

	for (i = 0; attr[i]; i += 2)
	{
		if (!svgParseAttr(p, attr[i], attr[i + 1]))
		{
			if (strcmp(attr[i], "x1") == 0) x1 = parseFloat(attr[i + 1]);
			if (strcmp(attr[i], "y1") == 0) y1 = parseFloat(attr[i + 1]);
			if (strcmp(attr[i], "x2") == 0) x2 = parseFloat(attr[i + 1]);
			if (strcmp(attr[i], "y2") == 0) y2 = parseFloat(attr[i + 1]);
		}
	}

	svgResetPath(p);

	svgPathPoint(p, x1, y1);
	svgPathPoint(p, x2, y2);

	svgCreatePath(p, 0);
}
开发者ID:DINKIN,项目名称:omim,代码行数:26,代码来源:nanosvg.c


示例5: getVector2DFromString

inline core::vector2df getVector2DFromString( const wchar_t* c )
{
    core::vector2df vec;
    vec.X = parseFloat(c);
    vec.Y = parseFloat(c);
    return vec;
}
开发者ID:3di,项目名称:3di-viewer-rei-libs,代码行数:7,代码来源:CTreeGenerator.cpp


示例6: svgParseRect

static void svgParseRect(struct SVGParser* p, const char** attr)
{
	float x = 0.0f;
	float y = 0.0f;
	float w = 0.0f;
	float h = 0.0f;
	int i;

	for (i = 0; attr[i]; i += 2)
	{
		if (!svgParseAttr(p, attr[i], attr[i + 1]))
		{
			if (strcmp(attr[i], "x") == 0) x = parseFloat(attr[i+1]);
			if (strcmp(attr[i], "y") == 0) y = parseFloat(attr[i+1]);
			if (strcmp(attr[i], "width") == 0) w = parseFloat(attr[i+1]);
			if (strcmp(attr[i], "height") == 0) h = parseFloat(attr[i+1]);
		}
	}

	if (w != 0.0f && h != 0.0f)
	{
		svgResetPath(p);

		svgPathPoint(p, x, y);
		svgPathPoint(p, x+w, y);
		svgPathPoint(p, x+w, y+h);
		svgPathPoint(p, x, y+h);

		svgCreatePath(p, 1);
	}
}
开发者ID:DINKIN,项目名称:omim,代码行数:31,代码来源:nanosvg.c


示例7: parseFloat2

static inline void parseFloat2(
  float& x, float& y,
  const char*& token)
{
  x = parseFloat(token);
  y = parseFloat(token);
}
开发者ID:AssociationSirius,项目名称:requiem,代码行数:7,代码来源:tiny_obj_loader.cpp


示例8: parseFloat3

inline void parseFloat3(
    float& x, float& y, float& z,
    const char*& token)
{
    x = parseFloat(token);
    y = parseFloat(token);
    z = parseFloat(token);
}
开发者ID:DaidaYamamoto,项目名称:GraphicsResearch,代码行数:8,代码来源:MyObjPawn.cpp


示例9: strSplit

Arc::Rect Arc::parseRect( const string& value )
{
    ArrayList<string> parts = strSplit(value, ',', 4);

    if (parts.size() < 4)
        return Rect::ZERO;

    return Rect(parseFloat(parts[0]), parseFloat(parts[1]), parseFloat(parts[2]), parseFloat(parts[3]));
}
开发者ID:RyanHuggins,项目名称:ProjectFall,代码行数:9,代码来源:ParseFunc.cpp


示例10: parseFloat

glm::vec2 FileExplorer::OBJFileExplorer::parse2dVector()
{
	glm::vec2 vec;
	it++;
	vec.x = parseFloat(takeDigit().data());
	it++;
	vec.y = parseFloat(takeDigit().data());
	return vec;
}
开发者ID:k0ntre201,项目名称:game-engine,代码行数:9,代码来源:OBJFileExporter.cpp


示例11: parseFloat

void KAbstractObjParserPrivate::parseNormal()
{
  ++m_normalCount;
  parseFloat(m_float4[0]);
  parseFloat(m_float4[1]);
  parseFloat(m_float4[2]);

  m_parser->onNormal(m_float4);
}
开发者ID:kyunghoWon,项目名称:QtOpenGL,代码行数:9,代码来源:kabstractobjparser.cpp


示例12: iss

	Zarantas::Vector2 StringConvertor::parseVector2(std::string string)
	{
		Zarantas::Vector2 tempVector;
		std::istringstream iss(string);

		std::string sub;
		iss >> sub;
		tempVector.x = parseFloat(sub);

		iss >> sub;
		tempVector.y = parseFloat(sub);

		return tempVector;
	}
开发者ID:dtbinh,项目名称:mbapengine,代码行数:14,代码来源:ArgonStringConvertor.cpp


示例13: if

void MTLFileReader::parseLine(const char*& current, const char* endOfLine)
{
	if(matchCommand(current, "newmtl"))
	{
		WavefrontMaterial mat;
		mat.name = current;
		materials.push_back(mat);

		current = endOfLine;
	}
	else if(matchCommand(current, "Ka")) // ambient color
		curMaterial().ambient = parseColor(current);
	else if(matchCommand(current, "Kd")) // diffuse color
		curMaterial().diffuse = parseColor(current);
	else if(matchCommand(current, "Ks")) // specular color
		curMaterial().specular = parseColor(current);
	else if(matchCommand(current, "Ns")) // specular exponent
		curMaterial().specularExp = parseFloat(current);
	else if(matchCommand(current, "Km")) // no idea what this is
		parseFloat(current);
	else if(matchCommand(current, "Ni")) // optical density
		curMaterial().refractiveInd = parseFloat(current);
  else if(matchCommand(current, "illum")) // illumination model
    curMaterial().illuminationModel = parseInt(current);
	else if(matchCommand(current, "d")) // dissolve
	{
		if(matchCommand(current, "-halo"))
			diagnostic(true, current, "dissolve halo not supported");

		curMaterial().opacity = parseFloat(current);
	}
	else if(matchCommand(current, "map_Kd")) // diffuse texture
	{
		curMaterial().diffuseTex = current;
		current = endOfLine;
	}
	else if(matchCommand(current, "map_Bump")) // bump texture
	{
		curMaterial().bumpTex = current;
		current = endOfLine;
	}
	else if(matchCommand(current, "map_d") || matchCommand(current, "map_D")) // opacity texture
	{
		curMaterial().opacityTex = current;
		current = endOfLine;
	}
	else
		diagnostic(false, current, "unknown command");
}
开发者ID:Ambrevar,项目名称:fr_public,代码行数:49,代码来源:_wavefront.cpp


示例14: x

bool BeParser::parseVector3( std::string& string, btVector3& value )
{
	float x(0),y(0),z(0);
	if( parseFloat(string, x) )
	{
		if( parseFloat(string, y) )
		{
			if( parseFloat(string, z) )
			{
				value = btVector3(x,y,z);
				return true;
			}
		}
	}
	return false;
}
开发者ID:ethicalfive,项目名称:critterding,代码行数:16,代码来源:be_parser.cpp


示例15: parseFloat

float ConfigReader::getFloat(const std::string theSection,
    const std::string theName, const float theDefault) const
{
    float anResult = theDefault;

    // Comprueba si la sección existe
    std::map<const std::string, typeNameValue*>::const_iterator iter;
    iter = this->sections.find(theSection);
    if (iter != this->sections.end())
    {
        // Intenta obtener el par <clave, valor>
        typeNameValue* anMap = iter->second;
        if (NULL != anMap)
        {
            typeNameValueIter iterNameValue;
            iterNameValue = anMap->find(theName);
            if (iterNameValue != anMap->end())
            {
                anResult = parseFloat(iterNameValue->second, theDefault);
            }
        }
    }

    // Devuelve el resultado encontrado o el valor de theDefault
    return anResult;
}
开发者ID:Gotchamoh,项目名称:Genbeta-Dev-Engine,代码行数:26,代码来源:ConfigReader.cpp


示例16: start

PyObject* VRPyAnimation::start(VRPyAnimation* self, PyObject* args) {
    if (self->obj == 0) { PyErr_SetString(err, "VRPyAnimation::start - Object is invalid"); return NULL; }
    float offset = 0;
    if (pySize(args) == 1) offset = parseFloat(args);
    self->obj->start(offset);
    Py_RETURN_TRUE;
}
开发者ID:uagmw,项目名称:polyvr,代码行数:7,代码来源:VRPyAnimation.cpp


示例17: parseOptionValue

static void
parseOptionValue(const char *        const optarg, 
                 struct optionDesc * const optionP,
                 const char **       const errorP) {
    
    switch (optionP->type) {
    case OPTTYPE_FLAG:
        *errorP = NULL;
        break;
    case OPTTYPE_INT:
    case OPTTYPE_UINT: 
        parseInt(optionP->type, optarg, &optionP->value.u, &optionP->value.i,
                 errorP);
        break;
    case OPTTYPE_STRING:
        if (optarg == NULL)
            casprintf(errorP, "Option requires a value");
        else {
            *errorP = NULL;
            optionP->value.s = strdup(optarg);
        }
        break;
    case OPTTYPE_BINUINT:
        parseBinUint(optarg, &optionP->value.llu, errorP);
        break;
    case OPTTYPE_FLOAT:
        parseFloat(optarg, &optionP->value.d, errorP);
        break;
    }
}
开发者ID:BehnamEmamian,项目名称:openholdembot,代码行数:30,代码来源:cmdline_parser.c


示例18: parseFloat

float ConfigReader::getFloat(const std::string theSection,
	const std::string theName, const float theDefault) const
{
	float anResult = theDefault;

	// Check if theSection really exists
	std::map<const std::string, typeNameValue*>::const_iterator iter;
	iter = mSections.find(theSection);
	if (iter != mSections.end())
	{
		// Try to obtain the name, value pair
		typeNameValue* anMap = iter->second;
		if (NULL != anMap)
		{
			typeNameValueIter iterNameValue;
			iterNameValue = anMap->find(theName);
			if (iterNameValue != anMap->end())
			{
				anResult = parseFloat(iterNameValue->second, theDefault);
			}
		}
	}

	// Return the result found or theDefault assigned above
	return anResult;
}
开发者ID:Noogic,项目名称:Genbeta-Dev-Engine,代码行数:26,代码来源:ConfigReader.cpp


示例19: NMEAGPS_INVALIDATE

bool ubloxNMEA::parseVelocityDown( char chr )
{
  #ifdef GPS_FIX_VELNED
    if (chrCount == 0)
      NMEAGPS_INVALIDATE( velned );

    // Checks for alias size.
    char test[ (int)sizeof(m_fix.velocity_down) - (int)sizeof(gps_fix::whole_frac) ];

    gps_fix::whole_frac *temp = (gps_fix::whole_frac *) &m_fix.velocity_down; // an alias for parsing

    if (parseFloat( *temp, chr, 3 )) { // 0.001 m/s

      if (chr == ',') {
        // convert the temporary whole_frac values in place
        m_fix.valid.velned = (chrCount > 0);
        if (m_fix.valid.velned) {
          m_fix.velocity_down = (temp->int32_000() + 5) / 10L; // mm/s to cm/s
        }
      }
    }
  #endif
  
  return true;

} // parseVelocityDown
开发者ID:ericbarch,项目名称:arduino-libraries,代码行数:26,代码来源:ubxNMEA.cpp


示例20: raiseError

void ObjParser::processVertexTexCoord( const std::vector<std::string>& tokens )
{
    if ( tokens.size() != 3 )
    {
        raiseError("vt command requires three arguments");
        return;
    }

    float u = parseFloat( tokens[1] );
    float v = parseFloat( tokens[2] );

    if (! hasErrors() )
    {
        m_objdata->texcoords.push_back( Vec2( u, v ) );
    }
}
开发者ID:smacdo,项目名称:scottsandbox,代码行数:16,代码来源:objparser.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ parseHeader函数代码示例发布时间:2022-05-30
下一篇:
C++ parseFile函数代码示例发布时间: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