annotate src/gui/translate/anime.cc @ 209:517d558ca160

CI/macos: add osxcross dependencies
author Paper <paper@paper.us.eu.org>
date Tue, 02 Jan 2024 07:20:16 -0500
parents 71832ffe425a
children 862d0d8619f6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
1 #include "core/anime.h"
65
26721c28bf22 *: avoid usage of (to|from)StdString
Paper <mrpapersonic@gmail.com>
parents: 51
diff changeset
2 #include "core/strings.h"
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 10
diff changeset
3 #include "gui/translate/anime.h"
202
71832ffe425a animia: re-add kvm fd source
Paper <paper@paper.us.eu.org>
parents: 187
diff changeset
4
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
5 #include <QCoreApplication>
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
6
202
71832ffe425a animia: re-add kvm fd source
Paper <paper@paper.us.eu.org>
parents: 187
diff changeset
7 #include <unordered_map>
71832ffe425a animia: re-add kvm fd source
Paper <paper@paper.us.eu.org>
parents: 187
diff changeset
8
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
9 namespace Translate {
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
10
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 10
diff changeset
11 std::string ToString(const Anime::ListStatus status) {
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
12 switch (status) {
174
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
13 case Anime::ListStatus::CURRENT: return "Currently watching";
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
14 case Anime::ListStatus::PLANNING: return "Plan to watch";
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
15 case Anime::ListStatus::COMPLETED: return "Completed";
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
16 case Anime::ListStatus::DROPPED: return "Dropped";
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
17 case Anime::ListStatus::PAUSED: return "On hold";
90
c4bb49c2f6eb config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
18 default:
174
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
19 case Anime::ListStatus::NOT_IN_LIST: return "Not in list";
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
20 }
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
21 }
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
22
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 10
diff changeset
23 std::string ToString(const Anime::SeriesFormat format) {
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
24 switch (format) {
174
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
25 case Anime::SeriesFormat::TV: return "TV";
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
26 case Anime::SeriesFormat::TV_SHORT: return "TV short";
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
27 case Anime::SeriesFormat::OVA: return "OVA";
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
28 case Anime::SeriesFormat::MOVIE: return "Movie";
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
29 case Anime::SeriesFormat::SPECIAL: return "Special";
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
30 case Anime::SeriesFormat::ONA: return "ONA";
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
31 case Anime::SeriesFormat::MUSIC: return "Music";
90
c4bb49c2f6eb config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
32 default:
174
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
33 case Anime::SeriesFormat::UNKNOWN: return "Unknown";
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
34 }
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
35 }
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
36
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 10
diff changeset
37 std::string ToString(const Anime::SeriesSeason season) {
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
38 switch (season) {
174
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
39 case Anime::SeriesSeason::WINTER: return "Winter";
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
40 case Anime::SeriesSeason::SUMMER: return "Summer";
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
41 case Anime::SeriesSeason::FALL: return "Fall";
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
42 case Anime::SeriesSeason::SPRING: return "Spring";
90
c4bb49c2f6eb config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
43 default:
174
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
44 case Anime::SeriesSeason::UNKNOWN: return "Unknown";
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
45 }
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
46 }
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
47
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 10
diff changeset
48 std::string ToString(const Anime::SeriesStatus status) {
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
49 switch (status) {
174
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
50 case Anime::SeriesStatus::RELEASING: return "Currently airing";
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
51 case Anime::SeriesStatus::FINISHED: return "Finished airing";
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
52 case Anime::SeriesStatus::NOT_YET_RELEASED: return "Not yet aired";
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
53 case Anime::SeriesStatus::CANCELLED: return "Cancelled";
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
54 case Anime::SeriesStatus::HIATUS: return "On hiatus";
90
c4bb49c2f6eb config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
55 default:
175
9b10175be389 dep/json: update to v3.11.3
Paper <mrpapersonic@gmail.com>
parents: 174
diff changeset
56 case Anime::SeriesStatus::UNKNOWN: return "Unknown";
9b10175be389 dep/json: update to v3.11.3
Paper <mrpapersonic@gmail.com>
parents: 174
diff changeset
57 }
9b10175be389 dep/json: update to v3.11.3
Paper <mrpapersonic@gmail.com>
parents: 174
diff changeset
58 }
9b10175be389 dep/json: update to v3.11.3
Paper <mrpapersonic@gmail.com>
parents: 174
diff changeset
59
9b10175be389 dep/json: update to v3.11.3
Paper <mrpapersonic@gmail.com>
parents: 174
diff changeset
60 std::string ToString(const Anime::Services service) {
9b10175be389 dep/json: update to v3.11.3
Paper <mrpapersonic@gmail.com>
parents: 174
diff changeset
61 switch (service) {
9b10175be389 dep/json: update to v3.11.3
Paper <mrpapersonic@gmail.com>
parents: 174
diff changeset
62 case Anime::Services::ANILIST: return "AniList";
9b10175be389 dep/json: update to v3.11.3
Paper <mrpapersonic@gmail.com>
parents: 174
diff changeset
63 default:
9b10175be389 dep/json: update to v3.11.3
Paper <mrpapersonic@gmail.com>
parents: 174
diff changeset
64 case Anime::Services::NONE: return "None";
90
c4bb49c2f6eb config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
65 }
c4bb49c2f6eb config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
66 }
c4bb49c2f6eb config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
67
175
9b10175be389 dep/json: update to v3.11.3
Paper <mrpapersonic@gmail.com>
parents: 174
diff changeset
68 std::string ToString(const Anime::TitleLanguage language) {
9b10175be389 dep/json: update to v3.11.3
Paper <mrpapersonic@gmail.com>
parents: 174
diff changeset
69 switch (language) {
9b10175be389 dep/json: update to v3.11.3
Paper <mrpapersonic@gmail.com>
parents: 174
diff changeset
70 case Anime::TitleLanguage::NATIVE: return "Native";
9b10175be389 dep/json: update to v3.11.3
Paper <mrpapersonic@gmail.com>
parents: 174
diff changeset
71 case Anime::TitleLanguage::ENGLISH: return "English";
9b10175be389 dep/json: update to v3.11.3
Paper <mrpapersonic@gmail.com>
parents: 174
diff changeset
72 default:
9b10175be389 dep/json: update to v3.11.3
Paper <mrpapersonic@gmail.com>
parents: 174
diff changeset
73 case Anime::TitleLanguage::ROMAJI: return "Romaji";
9b10175be389 dep/json: update to v3.11.3
Paper <mrpapersonic@gmail.com>
parents: 174
diff changeset
74 }
9b10175be389 dep/json: update to v3.11.3
Paper <mrpapersonic@gmail.com>
parents: 174
diff changeset
75 }
9b10175be389 dep/json: update to v3.11.3
Paper <mrpapersonic@gmail.com>
parents: 174
diff changeset
76
185
62e336597bb7 anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents: 175
diff changeset
77 std::string ToString(const Anime::ScoreFormat format) {
62e336597bb7 anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents: 175
diff changeset
78 switch (format) {
62e336597bb7 anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents: 175
diff changeset
79 case Anime::ScoreFormat::POINT_3: return "POINT_3";
62e336597bb7 anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents: 175
diff changeset
80 case Anime::ScoreFormat::POINT_5: return "POINT_5";
62e336597bb7 anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents: 175
diff changeset
81 case Anime::ScoreFormat::POINT_10: return "POINT_10";
62e336597bb7 anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents: 175
diff changeset
82 case Anime::ScoreFormat::POINT_10_DECIMAL: return "POINT_10_DECIMAL";
62e336597bb7 anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents: 175
diff changeset
83 default:
62e336597bb7 anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents: 175
diff changeset
84 case Anime::ScoreFormat::POINT_100: return "POINT_100";
62e336597bb7 anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents: 175
diff changeset
85 }
62e336597bb7 anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents: 175
diff changeset
86 }
62e336597bb7 anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents: 175
diff changeset
87
175
9b10175be389 dep/json: update to v3.11.3
Paper <mrpapersonic@gmail.com>
parents: 174
diff changeset
88 Anime::ListStatus ToListStatus(const std::string& str) {
187
9613d72b097e *: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents: 185
diff changeset
89 static const std::unordered_map<std::string, Anime::ListStatus> map = {
175
9b10175be389 dep/json: update to v3.11.3
Paper <mrpapersonic@gmail.com>
parents: 174
diff changeset
90 {"Currently watching", Anime::ListStatus::CURRENT},
9b10175be389 dep/json: update to v3.11.3
Paper <mrpapersonic@gmail.com>
parents: 174
diff changeset
91 {"Plan to watch", Anime::ListStatus::PLANNING},
9b10175be389 dep/json: update to v3.11.3
Paper <mrpapersonic@gmail.com>
parents: 174
diff changeset
92 {"Completed", Anime::ListStatus::COMPLETED},
9b10175be389 dep/json: update to v3.11.3
Paper <mrpapersonic@gmail.com>
parents: 174
diff changeset
93 {"Dropped", Anime::ListStatus::DROPPED},
9b10175be389 dep/json: update to v3.11.3
Paper <mrpapersonic@gmail.com>
parents: 174
diff changeset
94 {"On hold", Anime::ListStatus::PAUSED}
174
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
95 };
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
96
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
97 if (map.find(str) == map.end())
175
9b10175be389 dep/json: update to v3.11.3
Paper <mrpapersonic@gmail.com>
parents: 174
diff changeset
98 return Anime::ListStatus::NOT_IN_LIST;
174
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
99 return map.at(str);
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
100 }
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
101
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
102 Anime::SeriesStatus ToSeriesStatus(const std::string& str) {
187
9613d72b097e *: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents: 185
diff changeset
103 static const std::unordered_map<std::string, Anime::SeriesStatus> map = {
175
9b10175be389 dep/json: update to v3.11.3
Paper <mrpapersonic@gmail.com>
parents: 174
diff changeset
104 {"Currently airing", Anime::SeriesStatus::RELEASING},
9b10175be389 dep/json: update to v3.11.3
Paper <mrpapersonic@gmail.com>
parents: 174
diff changeset
105 {"Finished airing", Anime::SeriesStatus::FINISHED},
9b10175be389 dep/json: update to v3.11.3
Paper <mrpapersonic@gmail.com>
parents: 174
diff changeset
106 {"Not yet aired", Anime::SeriesStatus::NOT_YET_RELEASED},
9b10175be389 dep/json: update to v3.11.3
Paper <mrpapersonic@gmail.com>
parents: 174
diff changeset
107 {"Cancelled", Anime::SeriesStatus::CANCELLED},
9b10175be389 dep/json: update to v3.11.3
Paper <mrpapersonic@gmail.com>
parents: 174
diff changeset
108 {"On hiatus", Anime::SeriesStatus::HIATUS}
174
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
109 };
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
110
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
111 if (map.find(str) == map.end())
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
112 return Anime::SeriesStatus::UNKNOWN;
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
113 return map.at(str);
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
114 }
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
115
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
116 Anime::SeriesSeason ToSeriesSeason(const std::string& str) {
187
9613d72b097e *: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents: 185
diff changeset
117 static const std::unordered_map<std::string, Anime::SeriesSeason> map = {
174
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
118 {"Winter", Anime::SeriesSeason::WINTER},
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
119 {"Summer", Anime::SeriesSeason::SUMMER},
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
120 {"Fall", Anime::SeriesSeason::FALL},
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
121 {"Spring", Anime::SeriesSeason::SPRING}
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
122 };
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
123
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
124 if (map.find(str) == map.end())
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
125 return Anime::SeriesSeason::UNKNOWN;
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
126 return map.at(str);
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
127 }
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
128
175
9b10175be389 dep/json: update to v3.11.3
Paper <mrpapersonic@gmail.com>
parents: 174
diff changeset
129 Anime::SeriesFormat ToSeriesFormat(const std::string& str) {
187
9613d72b097e *: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents: 185
diff changeset
130 static const std::unordered_map<std::string, Anime::SeriesFormat> map = {
175
9b10175be389 dep/json: update to v3.11.3
Paper <mrpapersonic@gmail.com>
parents: 174
diff changeset
131 {"TV", Anime::SeriesFormat::TV},
9b10175be389 dep/json: update to v3.11.3
Paper <mrpapersonic@gmail.com>
parents: 174
diff changeset
132 {"TV short", Anime::SeriesFormat::TV_SHORT},
9b10175be389 dep/json: update to v3.11.3
Paper <mrpapersonic@gmail.com>
parents: 174
diff changeset
133 {"OVA", Anime::SeriesFormat::OVA},
9b10175be389 dep/json: update to v3.11.3
Paper <mrpapersonic@gmail.com>
parents: 174
diff changeset
134 {"Movie", Anime::SeriesFormat::MOVIE},
9b10175be389 dep/json: update to v3.11.3
Paper <mrpapersonic@gmail.com>
parents: 174
diff changeset
135 {"Special", Anime::SeriesFormat::SPECIAL},
9b10175be389 dep/json: update to v3.11.3
Paper <mrpapersonic@gmail.com>
parents: 174
diff changeset
136 {"ONA", Anime::SeriesFormat::ONA},
9b10175be389 dep/json: update to v3.11.3
Paper <mrpapersonic@gmail.com>
parents: 174
diff changeset
137 {"Music", Anime::SeriesFormat::MUSIC}
9b10175be389 dep/json: update to v3.11.3
Paper <mrpapersonic@gmail.com>
parents: 174
diff changeset
138 };
9b10175be389 dep/json: update to v3.11.3
Paper <mrpapersonic@gmail.com>
parents: 174
diff changeset
139
9b10175be389 dep/json: update to v3.11.3
Paper <mrpapersonic@gmail.com>
parents: 174
diff changeset
140 if (map.find(str) == map.end())
9b10175be389 dep/json: update to v3.11.3
Paper <mrpapersonic@gmail.com>
parents: 174
diff changeset
141 return Anime::SeriesFormat::UNKNOWN;
9b10175be389 dep/json: update to v3.11.3
Paper <mrpapersonic@gmail.com>
parents: 174
diff changeset
142 return map.at(str);
9b10175be389 dep/json: update to v3.11.3
Paper <mrpapersonic@gmail.com>
parents: 174
diff changeset
143 }
9b10175be389 dep/json: update to v3.11.3
Paper <mrpapersonic@gmail.com>
parents: 174
diff changeset
144
90
c4bb49c2f6eb config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
145 Anime::Services ToService(const std::string& str) {
187
9613d72b097e *: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents: 185
diff changeset
146 static const std::unordered_map<std::string, Anime::Services> map = {
90
c4bb49c2f6eb config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
147 {"AniList", Anime::Services::ANILIST}
c4bb49c2f6eb config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
148 };
c4bb49c2f6eb config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
149
c4bb49c2f6eb config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
150 if (map.find(str) == map.end())
c4bb49c2f6eb config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
151 return Anime::Services::NONE;
c4bb49c2f6eb config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
152 return map.at(str);
c4bb49c2f6eb config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
153 }
c4bb49c2f6eb config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
154
c4bb49c2f6eb config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
155 Anime::TitleLanguage ToLanguage(const std::string& str) {
187
9613d72b097e *: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents: 185
diff changeset
156 static const std::unordered_map<std::string, Anime::TitleLanguage> map = {
90
c4bb49c2f6eb config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
157 {"Romaji", Anime::TitleLanguage::ROMAJI},
c4bb49c2f6eb config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
158 {"Native", Anime::TitleLanguage::NATIVE},
c4bb49c2f6eb config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
159 {"English", Anime::TitleLanguage::ENGLISH}
c4bb49c2f6eb config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
160 };
c4bb49c2f6eb config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
161
c4bb49c2f6eb config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
162 if (map.find(str) == map.end())
c4bb49c2f6eb config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
163 return Anime::TitleLanguage::ROMAJI;
c4bb49c2f6eb config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
164 return map.at(str);
c4bb49c2f6eb config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
165 }
c4bb49c2f6eb config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
166
185
62e336597bb7 anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents: 175
diff changeset
167 Anime::ScoreFormat ToScoreFormat(const std::string& str) {
187
9613d72b097e *: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents: 185
diff changeset
168 static const std::unordered_map<std::string, Anime::ScoreFormat> map = {
185
62e336597bb7 anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents: 175
diff changeset
169 {"POINT_3", Anime::ScoreFormat::POINT_3},
62e336597bb7 anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents: 175
diff changeset
170 {"POINT_5", Anime::ScoreFormat::POINT_5},
62e336597bb7 anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents: 175
diff changeset
171 {"POINT_10", Anime::ScoreFormat::POINT_10},
62e336597bb7 anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents: 175
diff changeset
172 {"POINT_10_DECIMAL", Anime::ScoreFormat::POINT_10_DECIMAL},
62e336597bb7 anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents: 175
diff changeset
173 {"POINT_100", Anime::ScoreFormat::POINT_100}
62e336597bb7 anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents: 175
diff changeset
174 };
62e336597bb7 anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents: 175
diff changeset
175
62e336597bb7 anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents: 175
diff changeset
176 if (map.find(str) == map.end())
62e336597bb7 anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents: 175
diff changeset
177 return Anime::ScoreFormat::POINT_100;
62e336597bb7 anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents: 175
diff changeset
178 return map.at(str);
62e336597bb7 anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents: 175
diff changeset
179 }
62e336597bb7 anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents: 175
diff changeset
180
187
9613d72b097e *: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents: 185
diff changeset
181 /* Localized versions of ToString() functions. Meant for display to the user. */
174
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
182
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
183 std::string ToLocalString(const Anime::ListStatus status) {
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
184 switch (status) {
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
185 case Anime::ListStatus::CURRENT: return Strings::ToUtf8String(QCoreApplication::tr("Currently watching"));
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
186 case Anime::ListStatus::PLANNING: return Strings::ToUtf8String(QCoreApplication::tr("Plan to watch"));
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
187 case Anime::ListStatus::COMPLETED: return Strings::ToUtf8String(QCoreApplication::tr("Completed"));
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
188 case Anime::ListStatus::DROPPED: return Strings::ToUtf8String(QCoreApplication::tr("Dropped"));
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
189 case Anime::ListStatus::PAUSED: return Strings::ToUtf8String(QCoreApplication::tr("On hold"));
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
190 default:
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
191 case Anime::ListStatus::NOT_IN_LIST: return Strings::ToUtf8String(QCoreApplication::tr("Not in list"));
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
192 }
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
193 }
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
194
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
195 std::string ToLocalString(const Anime::SeriesFormat format) {
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
196 switch (format) {
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
197 case Anime::SeriesFormat::TV: return Strings::ToUtf8String(QCoreApplication::tr("TV"));
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
198 case Anime::SeriesFormat::TV_SHORT: return Strings::ToUtf8String(QCoreApplication::tr("TV short"));
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
199 case Anime::SeriesFormat::OVA: return Strings::ToUtf8String(QCoreApplication::tr("OVA"));
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
200 case Anime::SeriesFormat::MOVIE: return Strings::ToUtf8String(QCoreApplication::tr("Movie"));
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
201 case Anime::SeriesFormat::SPECIAL: return Strings::ToUtf8String(QCoreApplication::tr("Special"));
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
202 case Anime::SeriesFormat::ONA: return Strings::ToUtf8String(QCoreApplication::tr("ONA"));
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
203 case Anime::SeriesFormat::MUSIC: return Strings::ToUtf8String(QCoreApplication::tr("Music"));
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
204 default:
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
205 case Anime::SeriesFormat::UNKNOWN: return Strings::ToUtf8String(QCoreApplication::tr("Unknown"));
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
206 }
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
207 }
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
208
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
209 std::string ToLocalString(const Anime::SeriesSeason season) {
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
210 switch (season) {
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
211 case Anime::SeriesSeason::WINTER: return Strings::ToUtf8String(QCoreApplication::tr("Winter"));
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
212 case Anime::SeriesSeason::SUMMER: return Strings::ToUtf8String(QCoreApplication::tr("Summer"));
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
213 case Anime::SeriesSeason::FALL: return Strings::ToUtf8String(QCoreApplication::tr("Fall"));
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
214 case Anime::SeriesSeason::SPRING: return Strings::ToUtf8String(QCoreApplication::tr("Spring"));
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
215 default:
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
216 case Anime::SeriesSeason::UNKNOWN: return Strings::ToUtf8String(QCoreApplication::tr("Unknown"));
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
217 }
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
218 }
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
219
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
220 std::string ToLocalString(const Anime::SeriesStatus status) {
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
221 switch (status) {
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
222 case Anime::SeriesStatus::RELEASING: return Strings::ToUtf8String(QCoreApplication::tr("Currently airing"));
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
223 case Anime::SeriesStatus::FINISHED: return Strings::ToUtf8String(QCoreApplication::tr("Finished airing"));
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
224 case Anime::SeriesStatus::NOT_YET_RELEASED: return Strings::ToUtf8String(QCoreApplication::tr("Not yet aired"));
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
225 case Anime::SeriesStatus::CANCELLED: return Strings::ToUtf8String(QCoreApplication::tr("Cancelled"));
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
226 case Anime::SeriesStatus::HIATUS: return Strings::ToUtf8String(QCoreApplication::tr("On hiatus"));
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
227 default:
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
228 case Anime::SeriesStatus::UNKNOWN: return Strings::ToUtf8String(QCoreApplication::tr("Unknown"));
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
229 }
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
230 }
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
231
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
232 std::string ToLocalString(const Anime::Services service) {
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
233 switch (service) {
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
234 case Anime::Services::ANILIST: return Strings::ToUtf8String(QCoreApplication::tr("AniList"));
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
235 default:
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
236 case Anime::Services::NONE: return Strings::ToUtf8String(QCoreApplication::tr("None"));
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
237 }
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
238 }
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
239
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
240 std::string ToLocalString(const Anime::TitleLanguage language) {
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
241 switch (language) {
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
242 case Anime::TitleLanguage::NATIVE: return Strings::ToUtf8String(QCoreApplication::tr("Native"));
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
243 case Anime::TitleLanguage::ENGLISH: return Strings::ToUtf8String(QCoreApplication::tr("English"));
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
244 default:
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
245 case Anime::TitleLanguage::ROMAJI: return Strings::ToUtf8String(QCoreApplication::tr("Romaji"));
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
246 }
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
247 }
f88eda79c60a anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
248
187
9613d72b097e *: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents: 185
diff changeset
249 std::string ToLocalString(const Anime::ScoreFormat format) {
9613d72b097e *: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents: 185
diff changeset
250 switch (format) {
9613d72b097e *: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents: 185
diff changeset
251 case Anime::ScoreFormat::POINT_3: return Strings::ToUtf8String(QCoreApplication::tr("3-point"));
9613d72b097e *: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents: 185
diff changeset
252 case Anime::ScoreFormat::POINT_5: return Strings::ToUtf8String(QCoreApplication::tr("5-point"));
9613d72b097e *: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents: 185
diff changeset
253 case Anime::ScoreFormat::POINT_10: return Strings::ToUtf8String(QCoreApplication::tr("10-point"));
9613d72b097e *: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents: 185
diff changeset
254 case Anime::ScoreFormat::POINT_10_DECIMAL: return Strings::ToUtf8String(QCoreApplication::tr("10-point (Decimal)"));
9613d72b097e *: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents: 185
diff changeset
255 default:
9613d72b097e *: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents: 185
diff changeset
256 case Anime::ScoreFormat::POINT_100: return Strings::ToUtf8String(QCoreApplication::tr("100-point"));
9613d72b097e *: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents: 185
diff changeset
257 }
9613d72b097e *: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents: 185
diff changeset
258 }
9613d72b097e *: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents: 185
diff changeset
259
46
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents: 15
diff changeset
260 } // namespace Translate