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;
      }
    };
  }
Example #2
0
  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;
  }
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;
}
Example #4
0
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);
}
inline core::vector2df getVector2DFromString( const wchar_t* c )
{
    core::vector2df vec;
    vec.X = parseFloat(c);
    vec.Y = parseFloat(c);
    return vec;
}
Example #6
0
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);
	}
}
static inline void parseFloat2(
  float& x, float& y,
  const char*& token)
{
  x = parseFloat(token);
  y = parseFloat(token);
}
inline void parseFloat3(
    float& x, float& y, float& z,
    const char*& token)
{
    x = parseFloat(token);
    y = parseFloat(token);
    z = parseFloat(token);
}
Example #9
0
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]));
}
Example #10
0
Arc::Circle Arc::parseCircle( const string& value )
{
    ArrayList<string> parts = strSplit(value, ',', 3);

    if (parts.size() < 3)
        return Circle::ZERO;

    return Circle(parseFloat(parts[0]), parseFloat(parts[1]), parseFloat(parts[2]));
}
Example #11
0
Arc::Vector2 Arc::parseVector2( const string& value )
{
    ArrayList<string> parts = strSplit(value, ',', 2);

    if (parts.size() < 2)
        return Vector2::ZERO;

    return Vector2(parseFloat(parts[0]), parseFloat(parts[1]));
}
Example #12
0
glm::vec2 FileExplorer::OBJFileExplorer::parse2dVector()
{
	glm::vec2 vec;
	it++;
	vec.x = parseFloat(takeDigit().data());
	it++;
	vec.y = parseFloat(takeDigit().data());
	return vec;
}
void KAbstractObjParserPrivate::parseNormal()
{
  ++m_normalCount;
  parseFloat(m_float4[0]);
  parseFloat(m_float4[1]);
  parseFloat(m_float4[2]);

  m_parser->onNormal(m_float4);
}
void KAbstractObjParserPrivate::parseTexture()
{
  ++m_textureCount;
  parseFloat(m_float4[0]);
  parseFloat(m_float4[1]);
  if (!parseFloat(m_float4[2]))
    m_float4[2] = 1.0f;

  m_parser->onTexture(m_float4);
}
void KAbstractObjParserPrivate::parseParameter()
{
  ++m_parameterCount;
  parseFloat(m_float4[0]);
  if (!parseFloat(m_float4[1]))
    m_float4[1] = 0.0f;
  else if (!parseFloat(m_float4[2]))
    m_float4[2] = 0.0f;

  m_parser->onParameter(m_float4);
}
void KAbstractObjParserPrivate::parseVertex()
{
  ++m_vertexCount;
  parseFloat(m_float4[0]);
  parseFloat(m_float4[1]);
  parseFloat(m_float4[2]);
  if (!parseFloat(m_float4[3]))
    m_float4[3] = 1.0f;

  m_parser->onVertex(m_float4);
}
	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;
	}
Example #18
0
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");
}
Example #19
0
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;
}
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;
}
Example #21
0
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;
}
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;
    }
}
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;
}
Example #24
0
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
Example #25
0
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 ) );
    }
}
void AnalyzeTask::parseProperty(const QString &value, const MI_propertyId_t propertyIdx, AudioFileModel &audioFile, QString &coverMimeType)
{
#if MUTILS_DEBUG
	qDebug("Property #%d = \"%s\"", propertyIdx, MUTILS_UTF8(value.left(24)));
#endif
	switch (propertyIdx)
	{
		case propertyId_container:         audioFile.techInfo().setContainerType(value);                                                                  return;
		case propertyId_container_profile: audioFile.techInfo().setContainerProfile(value);                                                               return;
		case propertyId_duration:          SET_OPTIONAL(double, parseFloat(value, _tmp), audioFile.techInfo().setDuration(qRound(_tmp)));                 return;
		case propertyId_title:             audioFile.metaInfo().setTitle(value);                                                                          return;
		case propertyId_artist:            audioFile.metaInfo().setArtist(value);                                                                         return;
		case propertyId_album:             audioFile.metaInfo().setAlbum(value);                                                                          return;
		case propertyId_genre:             audioFile.metaInfo().setGenre(value);                                                                          return;
		case propertyId_released_date:     SET_OPTIONAL(quint32, parseYear(value, _tmp), audioFile.metaInfo().setYear(_tmp));                             return;
		case propertyId_track_position:    SET_OPTIONAL(quint32, parseUnsigned(value, _tmp), audioFile.metaInfo().setPosition(_tmp));                     return;
		case propertyId_comment:           audioFile.metaInfo().setComment(value);                                                                        return;
		case propertyId_format:            audioFile.techInfo().setAudioType(value);                                                                      return;
		case propertyId_format_version:    audioFile.techInfo().setAudioVersion(value);                                                                   return;
		case propertyId_format_profile:    audioFile.techInfo().setAudioProfile(value);                                                                   return;
		case propertyId_channel_s_:        SET_OPTIONAL(quint32, parseUnsigned(value, _tmp), audioFile.techInfo().setAudioChannels(_tmp));                return;
		case propertyId_samplingrate:      SET_OPTIONAL(quint32, parseUnsigned(value, _tmp), audioFile.techInfo().setAudioSamplerate(_tmp));              return;
		case propertyId_bitdepth:          SET_OPTIONAL(quint32, parseUnsigned(value, _tmp), audioFile.techInfo().setAudioBitdepth(_tmp));                return;
		case propertyId_bitrate:           SET_OPTIONAL(quint32, parseUnsigned(value, _tmp), audioFile.techInfo().setAudioBitrate(DIV_RND(_tmp, 1000U))); return;
		case propertyId_bitrate_mode:      SET_OPTIONAL(quint32, parseRCMode(value, _tmp), audioFile.techInfo().setAudioBitrateMode(_tmp));               return;
		case propertyId_encoded_library:   audioFile.techInfo().setAudioEncodeLib(cleanAsciiStr(value));                                                  return;
		case propertyId_cover_mime:        coverMimeType = value;                                                                                         return;
		case propertyId_cover_data:        retrieveCover(audioFile, coverMimeType, value);                                                                return;
		default: MUTILS_THROW_FMT("Invalid property ID: %d", propertyIdx);
	}
}
Example #27
0
void Packed::poll(bool can_read)
{
    if (!can_read) return;

    m_socket.peek();

    std::streamsize count;

    while ((count = m_socket.rdbuf()->in_avail()) > 0) {

        for (int i = 0; i < count; ++i) {

	    int next = m_socket.rdbuf()->sbumpc();

	    switch (m_state.top())
	    {
	        case PARSE_STREAM:	    parseStream(next); break;
	        case PARSE_MAP:		    parseMap(next); break;
	        case PARSE_LIST:	    parseList(next); break;
	        case PARSE_MAP_BEGIN:	    parseMapBegin(next); break;
	        case PARSE_LIST_BEGIN:	    parseListBegin(next); break;
	        case PARSE_INT:		    parseInt(next); break;
	        case PARSE_FLOAT:	    parseFloat(next); break;
	        case PARSE_STRING:	    parseString(next); break;
	        case PARSE_NAME:	    parseName(next); break;
	    }
        }
    }
}
Example #28
0
bool StyleParam::parseFontSize(const std::string& _str, float& _pxSize) {
    if (_str.empty()) {
        return false;
    }

    double num;
    int index = parseFloat(_str, num);
    if (index < 0) { return false; }

    _pxSize = static_cast<float>(num);

    if (size_t(index) == _str.length() && (_str.find('.') == std::string::npos)) {
        return true;
    }

    size_t end = _str.length() - 1;

    if (_str.compare(index, end, "px") == 0) {
        return true;
    } else if (_str.compare(index, end, "em") == 0) {
        _pxSize *= 16.f;
    } else if (_str.compare(index, end, "pt") == 0) {
        _pxSize /= 0.75f;
    } else if (_str.compare(index, end, "%") == 0) {
        _pxSize /= 6.25f;
    } else {
        return false;
    }

    return true;
}
Example #29
0
 bool JsonSingleValue::value(float& value) const
 {
     auto parsedValue = parseFloat(m_StringRef.begin(),
                                   m_StringRef.end());
     if (parsedValue.second)
         value = parsedValue.first;
     return parsedValue.second;
 }
Example #30
0
glm::vec3 FileExplorer::OBJFileExplorer::parse3dVector()
{
	glm::vec3 vec;
	vec = glm::vec3(parse2dVector(),0);
	it++;
	vec.z = parseFloat(takeDigit().data());
	return vec;
}