Example #1
0
File: Uri.cpp Project: 191919/folly
fbstring Uri::authority() const {
  fbstring result;

  // Port is 5 characters max and we have up to 3 delimiters.
  result.reserve(host().size() + username().size() + password().size() + 8);

  if (!username().empty() || !password().empty()) {
    result.append(username());

    if (!password().empty()) {
      result.push_back(':');
      result.append(password());
    }

    result.push_back('@');
  }

  result.append(host());

  if (port() != 0) {
    result.push_back(':');
    toAppend(port(), &result);
  }

  return result;
}
Example #2
0
	void CircleGauge::updateFillingView()
	{
		std::size_t indicatorIndex = 0;
		const float SEPARATION = maxValue_ / static_cast<float>(SEPARATOR);
		while(currentValue_ > SEPARATION * (indicatorIndex+1))
		{
			++indicatorIndex;
		}
		sf::Color color = INDICATORS.at(indicatorIndex);

		fillingView_.clear();
		sf::Vertex toAppend (Vector2f(0.f,0.f), color);
		fillingView_.append(toAppend);
		
		const float PI = 3.1415926535f;
		const float ANGLE_OFFSET = - PI / 2.f;
		const float COUNTER_CLOCKWISE = -1.f;
		float radius = backgroundView_.getRadius() + 0.1f;
		float maxAngle = 2 * PI * (currentValue_ / maxValue_);
		float angleIncrement = maxAngle / FILLING_N_POINT;
		for(unsigned int i=0; i<FILLING_N_POINT+1; ++i)
		{
			float angle = COUNTER_CLOCKWISE * angleIncrement * static_cast<float>(i) + ANGLE_OFFSET;
			toAppend = sf::Vertex(Vector2f(radius * std::cos(angle),
			                               radius * std::sin(angle)),
			                      color);
			fillingView_.append(toAppend);
		}
	}
Example #3
0
QString RpmBuildPlugin::replaceVariables(const QString &str, const Hash &variables) const
{
    const int size = str.size();
    QString result;

    for (int i = 0; i < size; i++)
    {
        QString toAppend(str[i]);

        if ( i < (size - static_cast<int>(sizeof("__a__"))) )  // enought chars to create shortest variable?
        {
            if (str[i] == '_' && str[i + 1] == '_')  //prefix matches? (__)
            {
                const int j = i + 2;
                i = j;                               //jump over prefix
                toAppend += '_';

                while ( (i + 1) < size && (str[i] != '_' || str[i + 1] != '_') )  //wait for suffix (__)
                    toAppend += str[i++];

                if (i + 1 < size && str[i] == '_' && str[i + 1] == '_')
                {
                    toAppend += "__";
                    i++;

                    //we got it!
                    const int k = i - 2;  //name without suffix

                    const QString varName = str.mid(j, k - j + 1);

                    if (variables.contains(varName))
                    {
                        toAppend = variables[varName];
                        debug(DebugLevel::Info) << "Variable \"" << varName << "\" used in spec file. (value = \"" << variables[varName] << "\")";
                    }
                    else
                        debug(DebugLevel::Warning) << "Unknown variable \"" << varName << "\" used in spec file.";
                }
            }
        }

        result.append(toAppend);
    }

    return result;
}