Mercurial > minori
comparison src/gui/translate/anilist.cc @ 279:657fda1b9cac
*: clean up enums
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Fri, 19 Apr 2024 13:24:06 -0400 |
parents | 9613d72b097e |
children | b1f625b0227c |
comparison
equal
deleted
inserted
replaced
274:f6a756c19bfb | 279:657fda1b9cac |
---|---|
2 #include <unordered_map> | 2 #include <unordered_map> |
3 | 3 |
4 namespace Translate { | 4 namespace Translate { |
5 namespace AniList { | 5 namespace AniList { |
6 | 6 |
7 Anime::SeriesStatus ToSeriesStatus(std::string status) { | 7 Anime::SeriesStatus ToSeriesStatus(const std::string& status) { |
8 static const std::unordered_map<std::string, Anime::SeriesStatus> map = { | 8 static const std::unordered_map<std::string, Anime::SeriesStatus> map = { |
9 {"FINISHED", Anime::SeriesStatus::FINISHED }, | 9 {"FINISHED", Anime::SeriesStatus::Finished }, |
10 {"RELEASING", Anime::SeriesStatus::RELEASING }, | 10 {"RELEASING", Anime::SeriesStatus::Releasing }, |
11 {"NOT_YET_RELEASED", Anime::SeriesStatus::NOT_YET_RELEASED}, | 11 {"NOT_YET_RELEASED", Anime::SeriesStatus::NotYetReleased}, |
12 {"CANCELLED", Anime::SeriesStatus::CANCELLED }, | 12 {"CANCELLED", Anime::SeriesStatus::Cancelled }, |
13 {"HIATUS", Anime::SeriesStatus::HIATUS } | 13 {"HIATUS", Anime::SeriesStatus::Hiatus } |
14 }; | 14 }; |
15 | 15 |
16 if (map.find(status) == map.end()) | 16 if (map.find(status) == map.end()) |
17 return Anime::SeriesStatus::UNKNOWN; | 17 return Anime::SeriesStatus::Unknown; |
18 return map.at(status); | 18 return map.at(status); |
19 } | 19 } |
20 | 20 |
21 Anime::SeriesSeason ToSeriesSeason(std::string season) { | 21 Anime::SeriesSeason ToSeriesSeason(const std::string& season) { |
22 static const std::unordered_map<std::string, Anime::SeriesSeason> map = { | 22 static const std::unordered_map<std::string, Anime::SeriesSeason> map = { |
23 {"WINTER", Anime::SeriesSeason::WINTER}, | 23 {"WINTER", Anime::SeriesSeason::Winter}, |
24 {"SPRING", Anime::SeriesSeason::SPRING}, | 24 {"SPRING", Anime::SeriesSeason::Spring}, |
25 {"SUMMER", Anime::SeriesSeason::SUMMER}, | 25 {"SUMMER", Anime::SeriesSeason::Summer}, |
26 {"FALL", Anime::SeriesSeason::FALL } | 26 {"FALL", Anime::SeriesSeason::Fall } |
27 }; | 27 }; |
28 | 28 |
29 if (map.find(season) == map.end()) | 29 if (map.find(season) == map.end()) |
30 return Anime::SeriesSeason::UNKNOWN; | 30 return Anime::SeriesSeason::Unknown; |
31 return map.at(season); | 31 return map.at(season); |
32 } | 32 } |
33 | 33 |
34 Anime::SeriesFormat ToSeriesFormat(std::string format) { | 34 Anime::SeriesFormat ToSeriesFormat(const std::string& format) { |
35 static const std::unordered_map<std::string, enum Anime::SeriesFormat> map = { | 35 static const std::unordered_map<std::string, enum Anime::SeriesFormat> map = { |
36 {"TV", Anime::SeriesFormat::TV }, | 36 {"TV", Anime::SeriesFormat::Tv }, |
37 {"TV_SHORT", Anime::SeriesFormat::TV_SHORT}, | 37 {"TV_SHORT", Anime::SeriesFormat::TvShort}, |
38 {"MOVIE", Anime::SeriesFormat::MOVIE }, | 38 {"MOVIE", Anime::SeriesFormat::Movie }, |
39 {"SPECIAL", Anime::SeriesFormat::SPECIAL }, | 39 {"SPECIAL", Anime::SeriesFormat::Special }, |
40 {"OVA", Anime::SeriesFormat::OVA }, | 40 {"OVA", Anime::SeriesFormat::Ova }, |
41 {"ONA", Anime::SeriesFormat::ONA }, | 41 {"ONA", Anime::SeriesFormat::Ona }, |
42 {"MUSIC", Anime::SeriesFormat::MUSIC }, | 42 {"MUSIC", Anime::SeriesFormat::Music } |
43 {"MANGA", Anime::SeriesFormat::MANGA }, | |
44 {"NOVEL", Anime::SeriesFormat::NOVEL }, | |
45 {"ONE_SHOT", Anime::SeriesFormat::ONE_SHOT} | |
46 }; | 43 }; |
47 | 44 |
48 if (map.find(format) == map.end()) | 45 if (map.find(format) == map.end()) |
49 return Anime::SeriesFormat::UNKNOWN; | 46 return Anime::SeriesFormat::Unknown; |
50 return map.at(format); | 47 return map.at(format); |
51 } | 48 } |
52 | 49 |
53 } // namespace AniList | 50 } // namespace AniList |
54 } // namespace Translate | 51 } // namespace Translate |