annotate src/gui/translate/anilist.cc @ 284:e66ffc338d82

anime: refactor title structure to a map
author Paper <paper@paper.us.eu.org>
date Wed, 08 May 2024 16:21:05 -0400
parents 657fda1b9cac
children b1f625b0227c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
1 #include "gui/translate/anilist.h"
187
9613d72b097e *: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
2 #include <unordered_map>
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
3
63
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 47
diff changeset
4 namespace Translate {
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 47
diff changeset
5 namespace AniList {
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
6
279
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 187
diff changeset
7 Anime::SeriesStatus ToSeriesStatus(const std::string& status) {
187
9613d72b097e *: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
8 static const std::unordered_map<std::string, Anime::SeriesStatus> map = {
279
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 187
diff changeset
9 {"FINISHED", Anime::SeriesStatus::Finished },
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 187
diff changeset
10 {"RELEASING", Anime::SeriesStatus::Releasing },
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 187
diff changeset
11 {"NOT_YET_RELEASED", Anime::SeriesStatus::NotYetReleased},
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 187
diff changeset
12 {"CANCELLED", Anime::SeriesStatus::Cancelled },
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 187
diff changeset
13 {"HIATUS", Anime::SeriesStatus::Hiatus }
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
14 };
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
15
47
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
16 if (map.find(status) == map.end())
279
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 187
diff changeset
17 return Anime::SeriesStatus::Unknown;
47
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
18 return map.at(status);
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
19 }
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
20
279
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 187
diff changeset
21 Anime::SeriesSeason ToSeriesSeason(const std::string& season) {
187
9613d72b097e *: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
22 static const std::unordered_map<std::string, Anime::SeriesSeason> map = {
279
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 187
diff changeset
23 {"WINTER", Anime::SeriesSeason::Winter},
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 187
diff changeset
24 {"SPRING", Anime::SeriesSeason::Spring},
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 187
diff changeset
25 {"SUMMER", Anime::SeriesSeason::Summer},
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 187
diff changeset
26 {"FALL", Anime::SeriesSeason::Fall }
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
27 };
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
28
47
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
29 if (map.find(season) == map.end())
279
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 187
diff changeset
30 return Anime::SeriesSeason::Unknown;
47
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
31 return map.at(season);
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
32 }
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
33
279
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 187
diff changeset
34 Anime::SeriesFormat ToSeriesFormat(const std::string& format) {
187
9613d72b097e *: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
35 static const std::unordered_map<std::string, enum Anime::SeriesFormat> map = {
279
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 187
diff changeset
36 {"TV", Anime::SeriesFormat::Tv },
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 187
diff changeset
37 {"TV_SHORT", Anime::SeriesFormat::TvShort},
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 187
diff changeset
38 {"MOVIE", Anime::SeriesFormat::Movie },
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 187
diff changeset
39 {"SPECIAL", Anime::SeriesFormat::Special },
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 187
diff changeset
40 {"OVA", Anime::SeriesFormat::Ova },
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 187
diff changeset
41 {"ONA", Anime::SeriesFormat::Ona },
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 187
diff changeset
42 {"MUSIC", Anime::SeriesFormat::Music }
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
43 };
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
44
47
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
45 if (map.find(format) == map.end())
279
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 187
diff changeset
46 return Anime::SeriesFormat::Unknown;
47
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
47 return map.at(format);
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
48 }
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
49
63
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 47
diff changeset
50 } // namespace AniList
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 47
diff changeset
51 } // namespace Translate