Exemplo n.º 1
0
boost::optional<int> Info::GetRawApproximatePricing() const
{
  if (!IsSponsored())
    return {};

  int pricing;
  if (strings::to_int(GetMetadata().Get(feature::Metadata::FMD_PRICE_RATE), pricing))
    return pricing;

  return {};
}
Exemplo n.º 2
0
string Info::GetApproximatePricing() const
{
  if (!IsSponsored())
    return string();

  int pricing;
  strings::to_int(GetMetadata().Get(feature::Metadata::FMD_PRICE_RATE), pricing);
  string result;
  for (auto i = 0; i < pricing; i++)
    result.append(kPricingSymbol);

  return result;
}
Exemplo n.º 3
0
float Info::GetRatingRawValue() const
{
  if (!IsSponsored() && !ShouldShowUGC())
    return kIncorrectRating;

  // Only sponsored rating is stored in metadata. UGC rating will be stored in special section and will be ready soon.
  auto const rating = GetMetadata().Get(feature::Metadata::FMD_RATING);
  float raw;
  if (!strings::to_float(rating, raw))
    return kIncorrectRating;

  return raw;
}
Exemplo n.º 4
0
string Info::GetRatingFormatted() const
{
  if (!IsSponsored())
    return string();

  auto const r = GetMetadata().Get(feature::Metadata::FMD_RATING);
  char const * rating = r.empty() ? kEmptyRatingSymbol : r.c_str();
  int const size = snprintf(nullptr, 0, m_localizedRatingString.c_str(), rating);
  if (size < 0)
  {
    LOG(LERROR, ("Incorrect size for string:", m_localizedRatingString, ", rating:", rating));
    return string();
  }

  vector<char> buf(size + 1);
  snprintf(buf.data(), buf.size(), m_localizedRatingString.c_str(), rating);
  return string(buf.begin(), buf.end());
}