Welcome to mirror list, hosted at ThFree Co, Russian Federation.

storage_defines.cpp « storage - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 17e359bb5cb50d7799936cf34e1b7d7df3d90214 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#include "storage/storage_defines.hpp"

#include <sstream>

using namespace std;
using namespace string_literals;

namespace storage
{
string DebugPrint(Status status)
{
  switch (status)
  {
  case Status::EUndefined:
    return "EUndefined"s;
  case Status::EOnDisk:
    return "OnDisk"s;
  case Status::ENotDownloaded:
    return "NotDownloaded"s;
  case Status::EDownloadFailed:
    return "DownloadFailed"s;
  case Status::EDownloading:
    return "Downloading"s;
  case Status::EApplying:
    return "Applying"s;
  case Status::EInQueue:
    return "InQueue"s;
  case Status::EUnknown:
    return "Unknown"s;
  case Status::EOnDiskOutOfDate:
    return "OnDiskOutOfDate"s;
  case Status::EOutOfMemFailed:
    return "OutOfMemFailed"s;
  }
}

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;
  }
}

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;
  }
}

StatusAndError ParseStatus(Status innerStatus)
{
  switch (innerStatus)
  {
  case Status::EUndefined:
    return StatusAndError(NodeStatus::Undefined, NodeErrorCode::NoError);
  case Status::EOnDisk:
    return StatusAndError(NodeStatus::OnDisk, NodeErrorCode::NoError);
  case Status::ENotDownloaded:
    return StatusAndError(NodeStatus::NotDownloaded, NodeErrorCode::NoError);
  case Status::EDownloadFailed:
    return StatusAndError(NodeStatus::Error, NodeErrorCode::NoInetConnection);
  case Status::EDownloading:
    return StatusAndError(NodeStatus::Downloading, NodeErrorCode::NoError);
  case Status::EApplying:
    return StatusAndError(NodeStatus::Applying, NodeErrorCode::NoError);
  case Status::EInQueue:
    return StatusAndError(NodeStatus::InQueue, NodeErrorCode::NoError);
  case Status::EUnknown:
    return StatusAndError(NodeStatus::Error, NodeErrorCode::UnknownError);
  case Status::EOnDiskOutOfDate:
    return StatusAndError(NodeStatus::OnDiskOutOfDate, NodeErrorCode::NoError);
  case Status::EOutOfMemFailed:
    return StatusAndError(NodeStatus::Error, NodeErrorCode::OutOfMemFailed);
  }
}

string DebugPrint(StatusAndError statusAndError)
{
  ostringstream out;
  out << "StatusAndError[" << DebugPrint(statusAndError.status)
      << ", " << DebugPrint(statusAndError.error) << "]";
  return out.str();
}
}  // namespace storage