Mercurial > minori
annotate include/core/anime.h @ 261:3ec7804abf17
include: make header guards more sane
The C++ standard[1] says:
Each identifier that contains a double underscore __ or
begins with an underscore followed by an uppercase letter
is reserved to the implementation for any use.
[1]: https://timsong-cpp.github.io/cppwp/n4659/lex.name#3.1
| author | Paper <paper@paper.us.eu.org> |
|---|---|
| date | Wed, 03 Apr 2024 20:04:28 -0400 |
| parents | dd211ff68b36 |
| children | 9a04802848c0 |
| rev | line source |
|---|---|
|
261
3ec7804abf17
include: make header guards more sane
Paper <paper@paper.us.eu.org>
parents:
260
diff
changeset
|
1 #ifndef MINORI_CORE_ANIME_H_ |
|
3ec7804abf17
include: make header guards more sane
Paper <paper@paper.us.eu.org>
parents:
260
diff
changeset
|
2 #define MINORI_CORE_ANIME_H_ |
|
3ec7804abf17
include: make header guards more sane
Paper <paper@paper.us.eu.org>
parents:
260
diff
changeset
|
3 |
| 9 | 4 #include "core/date.h" |
| 5 #include <array> | |
| 6 #include <map> | |
| 7 #include <vector> | |
| 8 | |
| 9 namespace Anime { | |
| 10 | |
| 11 enum class ListStatus { | |
| 12 NOT_IN_LIST, | |
| 13 CURRENT, | |
| 14 COMPLETED, | |
| 51 | 15 PAUSED, |
| 9 | 16 DROPPED, |
| 51 | 17 PLANNING |
| 9 | 18 }; |
| 19 | |
| 15 | 20 constexpr std::array<ListStatus, 5> ListStatuses{ListStatus::CURRENT, ListStatus::COMPLETED, ListStatus::PAUSED, |
| 21 ListStatus::DROPPED, ListStatus::PLANNING}; | |
| 9 | 22 |
| 23 enum class SeriesStatus { | |
| 24 UNKNOWN, | |
| 25 FINISHED, | |
| 26 RELEASING, | |
| 27 NOT_YET_RELEASED, | |
| 28 CANCELLED, | |
| 29 HIATUS | |
| 30 }; | |
| 31 | |
| 32 enum class SeriesFormat { | |
| 33 UNKNOWN, | |
| 34 TV, | |
| 35 TV_SHORT, | |
| 36 MOVIE, | |
| 37 SPECIAL, | |
| 38 OVA, | |
| 39 ONA, | |
| 40 MUSIC, | |
| 41 MANGA, | |
| 42 NOVEL, | |
| 43 ONE_SHOT | |
| 44 }; | |
| 45 | |
| 46 enum class SeriesSeason { | |
| 47 UNKNOWN, | |
| 48 WINTER, | |
| 49 SPRING, | |
| 50 SUMMER, | |
| 51 FALL | |
| 52 }; | |
| 53 | |
|
260
dd211ff68b36
pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
54 constexpr std::array<SeriesSeason, 4> SeriesSeasons{ |
|
dd211ff68b36
pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
55 SeriesSeason::WINTER, SeriesSeason::SPRING, |
|
dd211ff68b36
pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
56 SeriesSeason::SUMMER, SeriesSeason::FALL |
|
dd211ff68b36
pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
57 }; |
|
dd211ff68b36
pages/seasons: add initial functionality
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
58 |
| 9 | 59 enum class TitleLanguage { |
| 60 ROMAJI, | |
| 61 NATIVE, | |
| 62 ENGLISH | |
| 63 }; | |
| 64 | |
| 65 enum class Services { | |
| 66 NONE, | |
| 67 ANILIST, | |
| 68 NB_SERVICES | |
| 69 }; | |
| 70 | |
|
185
62e336597bb7
anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents:
184
diff
changeset
|
71 enum class ScoreFormat { |
| 258 | 72 POINT_100, // 0-100 |
|
185
62e336597bb7
anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents:
184
diff
changeset
|
73 POINT_10_DECIMAL, // 0.0-10.0 |
| 258 | 74 POINT_10, // 0-10 |
| 75 POINT_5, // 0-5, should be represented in stars | |
| 76 POINT_3 // 1-3, should be represented in smileys | |
|
185
62e336597bb7
anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents:
184
diff
changeset
|
77 }; |
|
62e336597bb7
anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents:
184
diff
changeset
|
78 |
| 258 | 79 constexpr std::array<ScoreFormat, 5> ScoreFormats{ScoreFormat::POINT_100, ScoreFormat::POINT_10_DECIMAL, |
| 80 ScoreFormat::POINT_10, ScoreFormat::POINT_5, ScoreFormat::POINT_3}; | |
| 189 | 81 |
| 9 | 82 struct ListInformation { |
| 258 | 83 int id = 0; |
| 84 int progress = 0; | |
| 85 int score = 0; // note that this will ALWAYS be in POINT_100 format and must be converted | |
| 86 ListStatus status = ListStatus::NOT_IN_LIST; | |
| 87 Date started; | |
| 88 Date completed; | |
| 89 bool is_private = false; | |
| 90 unsigned int rewatched_times = 0; | |
| 91 bool rewatching = false; | |
| 92 uint64_t updated = 0; | |
| 93 std::string notes; | |
| 9 | 94 }; |
| 95 | |
| 96 struct SeriesInformation { | |
| 258 | 97 int id; |
| 98 struct { | |
| 99 std::string romaji; | |
| 100 std::string english; | |
| 101 std::string native; | |
| 102 } title; | |
| 103 std::vector<std::string> synonyms; | |
| 104 int episodes = 0; | |
| 105 SeriesStatus status = SeriesStatus::UNKNOWN; | |
| 106 Date air_date; | |
| 107 std::vector<std::string> genres; | |
| 108 std::vector<std::string> producers; | |
| 109 SeriesFormat format = SeriesFormat::UNKNOWN; | |
| 110 SeriesSeason season = SeriesSeason::UNKNOWN; | |
| 111 int audience_score = 0; | |
| 112 std::string synopsis; | |
| 113 int duration = 0; | |
| 114 std::string poster_url; | |
| 9 | 115 }; |
| 116 | |
| 117 class Anime { | |
| 258 | 118 public: |
| 119 /* User list data */ | |
| 120 ListStatus GetUserStatus() const; | |
| 121 int GetUserProgress() const; | |
| 122 int GetUserScore() const; | |
| 123 std::string GetUserPresentableScore() const; | |
| 124 Date GetUserDateStarted() const; | |
| 125 Date GetUserDateCompleted() const; | |
| 126 bool GetUserIsPrivate() const; | |
| 127 unsigned int GetUserRewatchedTimes() const; | |
| 128 bool GetUserIsRewatching() const; | |
| 129 uint64_t GetUserTimeUpdated() const; | |
| 130 std::string GetUserNotes() const; | |
| 9 | 131 |
| 258 | 132 void SetUserStatus(ListStatus status); |
| 133 void SetUserScore(int score); | |
| 134 void SetUserProgress(int progress); | |
| 135 void SetUserDateStarted(Date const& started); | |
| 136 void SetUserDateCompleted(Date const& completed); | |
| 137 void SetUserIsPrivate(bool is_private); | |
| 138 void SetUserRewatchedTimes(int rewatched); | |
| 139 void SetUserIsRewatching(bool rewatching); | |
| 140 void SetUserTimeUpdated(uint64_t updated); | |
| 141 void SetUserNotes(std::string const& notes); | |
| 9 | 142 |
| 258 | 143 /* Series data */ |
| 144 int GetId() const; | |
| 145 std::string GetRomajiTitle() const; | |
| 146 std::string GetEnglishTitle() const; | |
| 147 std::string GetNativeTitle() const; | |
| 148 std::vector<std::string> GetTitleSynonyms() const; | |
| 149 int GetEpisodes() const; | |
| 150 SeriesStatus GetAiringStatus() const; | |
| 151 Date GetAirDate() const; | |
| 152 std::vector<std::string> GetGenres() const; | |
| 153 std::vector<std::string> GetProducers() const; | |
| 154 SeriesFormat GetFormat() const; | |
| 155 SeriesSeason GetSeason() const; | |
| 156 int GetAudienceScore() const; | |
| 157 std::string GetSynopsis() const; | |
| 158 int GetDuration() const; | |
| 159 std::string GetPosterUrl() const; | |
| 160 std::string GetServiceUrl() const; | |
| 9 | 161 |
| 258 | 162 void SetId(int id); |
| 163 void SetRomajiTitle(std::string const& title); | |
| 164 void SetEnglishTitle(std::string const& title); | |
| 165 void SetNativeTitle(std::string const& title); | |
| 166 void SetTitleSynonyms(std::vector<std::string> const& synonyms); | |
| 167 void AddTitleSynonym(std::string const& synonym); | |
| 168 void SetEpisodes(int episodes); | |
| 169 void SetAiringStatus(SeriesStatus status); | |
| 170 void SetAirDate(Date const& date); | |
| 171 void SetGenres(std::vector<std::string> const& genres); | |
| 172 void SetProducers(std::vector<std::string> const& producers); | |
| 173 void SetFormat(SeriesFormat format); | |
| 174 void SetSeason(SeriesSeason season); | |
| 175 void SetAudienceScore(int audience_score); | |
| 176 void SetSynopsis(std::string synopsis); | |
| 177 void SetDuration(int duration); | |
| 178 void SetPosterUrl(std::string poster); | |
| 9 | 179 |
| 258 | 180 std::string GetUserPreferredTitle() const; |
| 9 | 181 |
| 258 | 182 /* User stuff */ |
| 183 void AddToUserList(); | |
| 184 bool IsInUserList() const; | |
| 185 void RemoveFromUserList(); | |
| 9 | 186 |
| 258 | 187 private: |
| 188 SeriesInformation info_; | |
| 189 std::shared_ptr<struct ListInformation> list_info_; | |
| 9 | 190 }; |
| 191 | |
| 192 } // namespace Anime | |
| 193 | |
|
261
3ec7804abf17
include: make header guards more sane
Paper <paper@paper.us.eu.org>
parents:
260
diff
changeset
|
194 #endif // MINORI_CORE_ANIME_H_ |
