本文整理汇总了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;
}
};
}
示例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;
}
示例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;
}
示例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);
}
示例5: getVector2DFromString
inline core::vector2df getVector2DFromString( const wchar_t* c )
{
core::vector2df vec;
vec.X = parseFloat(c);
vec.Y = parseFloat(c);
return vec;
}
示例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);
}
}
示例7: parseFloat2
static inline void parseFloat2(
float& x, float& y,
const char*& token)
{
x = parseFloat(token);
y = parseFloat(token);
}
示例8: parseFloat3
inline void parseFloat3(
float& x, float& y, float& z,
const char*& token)
{
x = parseFloat(token);
y = parseFloat(token);
z = parseFloat(token);
}
示例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]));
}
示例10: parseFloat
glm::vec2 FileExplorer::OBJFileExplorer::parse2dVector()
{
glm::vec2 vec;
it++;
vec.x = parseFloat(takeDigit().data());
it++;
vec.y = parseFloat(takeDigit().data());
return vec;
}
示例11: parseFloat
void KAbstractObjParserPrivate::parseNormal()
{
++m_normalCount;
parseFloat(m_float4[0]);
parseFloat(m_float4[1]);
parseFloat(m_float4[2]);
m_parser->onNormal(m_float4);
}
示例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;
}
示例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");
}
示例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;
}
示例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;
}