Repository: xbmc/xbmc
File: xbmc/NfoFile.cpp (C++)

Code before:
      return details.GetOverride() ? OVERRIDE : FULL;
  }
  return NONE;
}

bool CNfoFile::seekToMovieIndex(int index)
{
  // Find nth <movie> tag (index is 1 based)
  m_headPos = m_doc.find("<movies>");
  while (index-- > 0)
  {
    m_headPos = m_doc.find("<movie", m_headPos + 1);
    if (m_headPos == std::string::npos)
      break;
  }
  return m_headPos != std::string::npos;
}

CInfoScanner::InfoType CNfoFile::TryParsing(const CURL& nfoPath,
                                            ADDON::ContentType contentType,
                                            int index /* =1 */)
{
  if (Load(nfoPath) != 0) // Setup m_doc and m_headPos
    return CInfoScanner::InfoType::ERROR_NFO;

  auto addonType = ScraperTypeFromContent(contentType);

  if (addonType == ADDON::AddonType::SCRAPER_MOVIES && !seekToMovieIndex(index))
    return CInfoScanner::InfoType::NONE;

  return TryParsing(addonType);
}

CInfoScanner::InfoType CNfoFile::Create(const std::string& nfoPath,
                                        const ScraperPtr& info,
                                        int index)
{
  /* `TryParsing` creates a close approximation to the desired result.
   * The desired result would be knowing if any valid URLs have been
   * found in the NFO which could be interpreted by a scraper.
   * Determining if any valid URLs exist in the NFO file is an expensive
   * operation so should only be called if necessary. If the approximate
   * result from `TryParsing` is sufficient then use that result.
   *
   * Below is a table to show the result from `TryParsing` and the
   * potential desired results.
   *
   * | result   | Could be converted to:     |
   * | -------- | -------------------------- |
   * | NONE     | URL NONE                   |
   * | OVERRIDE | COMBINED OVERRIDE          |

Review comment (suggestion):
`const auto` or even better, because increased readability, use the real type instead of `auto`.

Code after:
      return details.GetOverride() ? OVERRIDE : FULL;
  }
  return NONE;
}

bool CNfoFile::SeekToMovieIndex(int index)
{
  // Find nth <movie> tag (index is 1 based)
  m_headPos = m_doc.find("<movies>");
  while (index-- > 0)
  {
    m_headPos = m_doc.find("<movie", m_headPos + 1);
    if (m_headPos == std::string::npos)
      break;
  }
  return m_headPos != std::string::npos;
}

CInfoScanner::InfoType CNfoFile::TryParsing(const CURL& nfoPath,
                                            ADDON::ContentType contentType,
                                            int index /* =1 */)
{
  if (Load(nfoPath) != 0) // Setup m_doc and m_headPos
    return CInfoScanner::InfoType::ERROR_NFO;

  const AddonType addonType = ScraperTypeFromContent(contentType);

  if (addonType == ADDON::AddonType::SCRAPER_MOVIES && !SeekToMovieIndex(index))
    return CInfoScanner::InfoType::NONE;

  return TryParsing(addonType);
}

CInfoScanner::InfoType CNfoFile::Create(const std::string& nfoPath,
                                        const ScraperPtr& info,
                                        int index)
{
  /* `TryParsing` creates a close approximation to the desired result.
   * The desired result would be knowing if any valid URLs have been
   * found in the NFO which could be interpreted by a scraper.
   * Determining if any valid URLs exist in the NFO file is an expensive
   * operation so should only be called if necessary. If the approximate
   * result from `TryParsing` is sufficient then use that result.
   *
   * Below is a table to show the result from `TryParsing` and the
   * potential desired results.
   *
   * | result   | Could be converted to:     |
   * | -------- | -------------------------- |
   * | NONE     | URL NONE                   |
   * | OVERRIDE | COMBINED OVERRIDE          |