Repository: xbmc/xbmc
File: xbmc/utils/URIUtils.h (C/C++)

Code before:

class CURL;
class CAdvancedSettings;
class CFileItem;

/*! \brief Defines the methodology to find hosts on a given subnet 
    \sa IsHostOnLAN
*/
enum class LanCheckMode
{
  /*! \brief Only match if the host is on the same subnet as the kodi host */
  ONLY_LOCAL_SUBNET,
  /*! \brief Match the host if it belongs to any private subnet */
  ANY_PRIVATE_SUBNET
};

class URIUtils
{
public:
  // Don't URL encode "-_.!()" according to RFC1738
  //! @todo Update it to "-_.~" after Gotham according to RFC3986
  static constexpr std::string_view RFC1738{"-._!()"};
  static constexpr std::string_view RFC3986{"-_.~"};

  static std::string URLEncode(std::string_view strURLData,
                               const std::string_view& URLSpec = RFC1738);
  static std::string URLDecode(std::string_view strURLData);

  static void RegisterAdvancedSettings(const CAdvancedSettings& advancedSettings);
  static void UnregisterAdvancedSettings();

  static std::string GetDirectory(const std::string &strFilePath);

  static std::string GetFileName(const CURL& url);
  static std::string GetFileName(const std::string& strFileNameAndPath);
  static std::string GetFileOrFolderName(const std::string& path);

  static std::string GetExtension(const CURL& url);
  static std::string GetExtension(const std::string& strFileName);


  /*! \brief Check if the CFileItem has a plugin path.
   \param item The CFileItem.
   \return true if there is a plugin path, false otherwise.
  */
  static bool HasPluginPath(const CFileItem& item);

  /*!
   \brief Check if there is a file extension
   \param strFileName Path or URL to check
   \return \e true if strFileName have an extension.

Review comment (suggestion):
There is basically never a situation where passing a `std::string_view` by const reference is better than passing by value.
```suggestion
  static std::string URLEncode(std::string_view strURLData, std::string_view URLSpec = RFC1738);
```

Code after:

class CURL;
class CAdvancedSettings;
class CFileItem;

/*! \brief Defines the methodology to find hosts on a given subnet 
    \sa IsHostOnLAN
*/
enum class LanCheckMode
{
  /*! \brief Only match if the host is on the same subnet as the kodi host */
  ONLY_LOCAL_SUBNET,
  /*! \brief Match the host if it belongs to any private subnet */
  ANY_PRIVATE_SUBNET
};

class URIUtils
{
public:
  // Don't URL encode "-_.!()" according to RFC1738
  //! @todo Update it to "-_.~" after Gotham according to RFC3986
  static constexpr std::string_view RFC1738{"-._!()"};
  static constexpr std::string_view RFC3986{"-_.~"};

  static std::string URLEncode(std::string_view strURLData, std::string_view URLSpec = RFC1738);
  static std::string URLDecode(std::string_view strURLData);

  static void RegisterAdvancedSettings(const CAdvancedSettings& advancedSettings);
  static void UnregisterAdvancedSettings();

  static std::string GetDirectory(const std::string &strFilePath);

  static std::string GetFileName(const CURL& url);
  static std::string GetFileName(const std::string& strFileNameAndPath);
  static std::string GetFileOrFolderName(const std::string& path);

  static std::string GetExtension(const CURL& url);
  static std::string GetExtension(const std::string& strFileName);


  /*! \brief Check if the CFileItem has a plugin path.
   \param item The CFileItem.
   \return true if there is a plugin path, false otherwise.
  */
  static bool HasPluginPath(const CFileItem& item);

  /*!
   \brief Check if there is a file extension
   \param strFileName Path or URL to check
   \return \e true if strFileName have an extension.
   \note Returns false when strFileName is empty.