Files
comaps/platform/downloader_defines.hpp
Konstantin Pastbin e3e4a1985a Organic Maps sources as of 02.04.2025 (fad26bbf22ac3da75e01e62aa01e5c8e11861005)
To expand with full Organic Maps and Maps.ME commits history run:
  git remote add om-historic [om-historic.git repo url]
  git fetch --tags om-historic
  git replace squashed-history historic-commits
2025-05-08 21:10:51 +07:00

60 lines
1.2 KiB
C++

#pragma once
#include "base/assert.hpp"
#include <cstdint>
#include <string>
#include <utility>
namespace downloader
{
enum class DownloadStatus
{
InProgress,
Completed,
Failed,
FileNotFound,
FailedSHA,
};
inline std::string DebugPrint(DownloadStatus status)
{
switch (status)
{
case DownloadStatus::InProgress: return "In progress";
case DownloadStatus::Completed: return "Completed";
case DownloadStatus::Failed: return "Failed";
case DownloadStatus::FileNotFound: return "File not found";
case DownloadStatus::FailedSHA: return "Failed SHA check";
}
UNREACHABLE();
}
struct Progress
{
static int64_t constexpr kUnknownTotalSize = -1;
static Progress constexpr Unknown()
{
return {0, kUnknownTotalSize};
}
bool IsUnknown() const
{
return m_bytesTotal == kUnknownTotalSize;
}
int64_t m_bytesDownloaded = 0;
/// Total can be kUnknownTotalSize if size is unknown.
int64_t m_bytesTotal = 0;
};
inline std::string DebugPrint(Progress const & progress)
{
std::ostringstream out;
out << "(downloaded " << progress.m_bytesDownloaded << " bytes out of " << progress.m_bytesTotal
<< " bytes)";
return out.str();
}
} // namespace downloader