当前位置: 首页>>代码示例>>C++>>正文


C++ parseFloat函数代码示例

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


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


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