mirror of
https://codeberg.org/comaps/comaps
synced 2026-01-04 03:43:46 +00:00
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
This commit is contained in:
121
storage/storage_defines.cpp
Normal file
121
storage/storage_defines.cpp
Normal file
@@ -0,0 +1,121 @@
|
||||
#include "storage/storage_defines.hpp"
|
||||
|
||||
#include "base/assert.hpp"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
using namespace std;
|
||||
using namespace string_literals;
|
||||
|
||||
namespace storage
|
||||
{
|
||||
storage::CountryId const kInvalidCountryId;
|
||||
|
||||
bool IsCountryIdValid(CountryId const & countryId) { return countryId != kInvalidCountryId; }
|
||||
|
||||
string DebugPrint(Status status)
|
||||
{
|
||||
switch (status)
|
||||
{
|
||||
case Status::Undefined:
|
||||
return "EUndefined"s;
|
||||
case Status::OnDisk:
|
||||
return "OnDisk"s;
|
||||
case Status::NotDownloaded:
|
||||
return "NotDownloaded"s;
|
||||
case Status::DownloadFailed:
|
||||
return "DownloadFailed"s;
|
||||
case Status::Downloading:
|
||||
return "Downloading"s;
|
||||
case Status::Applying:
|
||||
return "Applying"s;
|
||||
case Status::InQueue:
|
||||
return "InQueue"s;
|
||||
case Status::UnknownError:
|
||||
return "Unknown"s;
|
||||
case Status::OnDiskOutOfDate:
|
||||
return "OnDiskOutOfDate"s;
|
||||
case Status::OutOfMemFailed:
|
||||
return "OutOfMemFailed"s;
|
||||
}
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
string DebugPrint(NodeStatus status)
|
||||
{
|
||||
switch (status)
|
||||
{
|
||||
case NodeStatus::Undefined:
|
||||
return "Undefined"s;
|
||||
case NodeStatus::Error:
|
||||
return "Error"s;
|
||||
case NodeStatus::OnDisk:
|
||||
return "OnDisk"s;
|
||||
case NodeStatus::NotDownloaded:
|
||||
return "NotDownloaded"s;
|
||||
case NodeStatus::Downloading:
|
||||
return "Downloading"s;
|
||||
case NodeStatus::Applying:
|
||||
return "Applying"s;
|
||||
case NodeStatus::InQueue:
|
||||
return "InQueue"s;
|
||||
case NodeStatus::OnDiskOutOfDate:
|
||||
return "OnDiskOutOfDate"s;
|
||||
case NodeStatus::Partly:
|
||||
return "Partly"s;
|
||||
}
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
string DebugPrint(NodeErrorCode status)
|
||||
{
|
||||
switch (status)
|
||||
{
|
||||
case NodeErrorCode::NoError:
|
||||
return "NoError"s;
|
||||
case NodeErrorCode::UnknownError:
|
||||
return "UnknownError"s;
|
||||
case NodeErrorCode::OutOfMemFailed:
|
||||
return "OutOfMemFailed"s;
|
||||
case NodeErrorCode::NoInetConnection:
|
||||
return "NoInetConnection"s;
|
||||
}
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
StatusAndError ParseStatus(Status innerStatus)
|
||||
{
|
||||
switch (innerStatus)
|
||||
{
|
||||
case Status::Undefined:
|
||||
return StatusAndError(NodeStatus::Undefined, NodeErrorCode::NoError);
|
||||
case Status::OnDisk:
|
||||
return StatusAndError(NodeStatus::OnDisk, NodeErrorCode::NoError);
|
||||
case Status::NotDownloaded:
|
||||
return StatusAndError(NodeStatus::NotDownloaded, NodeErrorCode::NoError);
|
||||
case Status::DownloadFailed:
|
||||
return StatusAndError(NodeStatus::Error, NodeErrorCode::NoInetConnection);
|
||||
case Status::Downloading:
|
||||
return StatusAndError(NodeStatus::Downloading, NodeErrorCode::NoError);
|
||||
case Status::Applying:
|
||||
return StatusAndError(NodeStatus::Applying, NodeErrorCode::NoError);
|
||||
case Status::InQueue:
|
||||
return StatusAndError(NodeStatus::InQueue, NodeErrorCode::NoError);
|
||||
case Status::UnknownError:
|
||||
return StatusAndError(NodeStatus::Error, NodeErrorCode::UnknownError);
|
||||
case Status::OnDiskOutOfDate:
|
||||
return StatusAndError(NodeStatus::OnDiskOutOfDate, NodeErrorCode::NoError);
|
||||
case Status::OutOfMemFailed:
|
||||
return StatusAndError(NodeStatus::Error, NodeErrorCode::OutOfMemFailed);
|
||||
}
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
string DebugPrint(StatusAndError statusAndError)
|
||||
{
|
||||
ostringstream out;
|
||||
out << "StatusAndError[" << DebugPrint(statusAndError.status)
|
||||
<< ", " << DebugPrint(statusAndError.error) << "]";
|
||||
return out.str();
|
||||
}
|
||||
} // namespace storage
|
||||
Reference in New Issue
Block a user