Mercurial > minori
comparison src/services/anilist.cpp @ 70:64e5f427c6a2
services/anilist: remove unordered_map usage for enum classes
for some reason in C++11 unordered_maps don't work on enumerations.
so instead we'll just use a switch statement :P
| author | Paper <mrpapersonic@gmail.com> | 
|---|---|
| date | Tue, 03 Oct 2023 04:45:05 -0400 | 
| parents | 6481c5aed3e1 | 
| children | 5ccb99bfa605 | 
   comparison
  equal
  deleted
  inserted
  replaced
| 69:27a19dd6cba1 | 70:64e5f427c6a2 | 
|---|---|
| 96 | 96 | 
| 97 anime.SetUserStatus(map[status]); | 97 anime.SetUserStatus(map[status]); | 
| 98 } | 98 } | 
| 99 | 99 | 
| 100 std::string ListStatusToString(const Anime::Anime& anime) { | 100 std::string ListStatusToString(const Anime::Anime& anime) { | 
| 101 std::unordered_map<Anime::ListStatus, std::string> map = { | |
| 102 {Anime::ListStatus::CURRENT, "CURRENT" }, | |
| 103 {Anime::ListStatus::PLANNING, "PLANNING" }, | |
| 104 {Anime::ListStatus::COMPLETED, "COMPLETED"}, | |
| 105 {Anime::ListStatus::DROPPED, "DROPPED" }, | |
| 106 {Anime::ListStatus::PAUSED, "PAUSED" } | |
| 107 }; | |
| 108 | |
| 109 if (anime.GetUserIsRewatching()) | 101 if (anime.GetUserIsRewatching()) | 
| 110 return "REWATCHING"; | 102 return "REWATCHING"; | 
| 111 | 103 | 
| 112 if (map.find(anime.GetUserStatus()) == map.end()) | 104 switch (anime.GetUserStatus()) { | 
| 113 return "CURRENT"; | 105 case Anime::ListStatus::PLANNING: | 
| 114 return map[anime.GetUserStatus()]; | 106 return "PLANNING"; | 
| 107 case Anime::ListStatus::COMPLETED: | |
| 108 return "COMPLETED"; | |
| 109 case Anime::ListStatus::DROPPED: | |
| 110 return "DROPPED"; | |
| 111 case Anime::ListStatus::PAUSED: | |
| 112 return "PAUSED"; | |
| 113 default: | |
| 114 break; | |
| 115 } | |
| 116 return "CURRENT"; | |
| 115 } | 117 } | 
| 116 | 118 | 
| 117 Date ParseDate(const nlohmann::json& json) { | 119 Date ParseDate(const nlohmann::json& json) { | 
| 118 Date date; | 120 Date date; | 
| 119 /* JSON for Modern C++ warns here. I'm not too sure why, this code works when I set the | 121 /* JSON for Modern C++ warns here. I'm not too sure why, this code works when I set the | 
