annotate src/gui/translate/anilist.cc @ 276:ec0a2b5493f8

ini: simplify INI code, use templates less less magic voodoo code
author Paper <paper@paper.us.eu.org>
date Mon, 22 Apr 2024 19:10:28 -0400
parents 9613d72b097e
children 657fda1b9cac
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
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
7 Anime::SeriesStatus ToSeriesStatus(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 = {
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
9 {"FINISHED", Anime::SeriesStatus::FINISHED },
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
10 {"RELEASING", Anime::SeriesStatus::RELEASING },
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
11 {"NOT_YET_RELEASED", Anime::SeriesStatus::NOT_YET_RELEASED},
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
12 {"CANCELLED", Anime::SeriesStatus::CANCELLED },
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
13 {"HIATUS", Anime::SeriesStatus::HIATUS }
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())
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
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
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
21 Anime::SeriesSeason ToSeriesSeason(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 = {
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
23 {"WINTER", Anime::SeriesSeason::WINTER},
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
24 {"SPRING", Anime::SeriesSeason::SPRING},
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
25 {"SUMMER", Anime::SeriesSeason::SUMMER},
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
26 {"FALL", Anime::SeriesSeason::FALL }
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())
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
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
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
34 Anime::SeriesFormat ToSeriesFormat(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 = {
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
36 {"TV", Anime::SeriesFormat::TV },
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
37 {"TV_SHORT", Anime::SeriesFormat::TV_SHORT},
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
38 {"MOVIE", Anime::SeriesFormat::MOVIE },
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
39 {"SPECIAL", Anime::SeriesFormat::SPECIAL },
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
40 {"OVA", Anime::SeriesFormat::OVA },
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
41 {"ONA", Anime::SeriesFormat::ONA },
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
42 {"MUSIC", Anime::SeriesFormat::MUSIC },
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
43 {"MANGA", Anime::SeriesFormat::MANGA },
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
44 {"NOVEL", Anime::SeriesFormat::NOVEL },
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
45 {"ONE_SHOT", Anime::SeriesFormat::ONE_SHOT}
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
46 };
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
47
47
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
48 if (map.find(format) == map.end())
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
49 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
50 return map.at(format);
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
51 }
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
52
63
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 47
diff changeset
53 } // namespace AniList
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 47
diff changeset
54 } // namespace Translate