diff include/core/anime.h @ 279:657fda1b9cac

*: clean up enums
author Paper <paper@paper.us.eu.org>
date Fri, 19 Apr 2024 13:24:06 -0400
parents 9a04802848c0
children e66ffc338d82
line wrap: on
line diff
--- a/include/core/anime.h	Thu Apr 18 17:24:42 2024 -0400
+++ b/include/core/anime.h	Fri Apr 19 13:24:06 2024 -0400
@@ -10,81 +10,103 @@
 namespace Anime {
 
 enum class ListStatus {
-	NOT_IN_LIST,
-	CURRENT,
-	COMPLETED,
-	PAUSED,
-	DROPPED,
-	PLANNING
+	NotInList = 0,
+	Current,
+	Completed,
+	Paused,
+	Dropped,
+	Planning
+};
+
+constexpr std::array<ListStatus, 5> ListStatuses{
+	ListStatus::Current, ListStatus::Completed, ListStatus::Paused,
+    ListStatus::Dropped, ListStatus::Planning
 };
 
-constexpr std::array<ListStatus, 5> ListStatuses{ListStatus::CURRENT, ListStatus::COMPLETED, ListStatus::PAUSED,
-                                                 ListStatus::DROPPED, ListStatus::PLANNING};
+enum class SeriesStatus {
+	Unknown = 0,
+	Finished,
+	Releasing,
+	NotYetReleased,
+	Cancelled,
+	Hiatus
+};
 
-enum class SeriesStatus {
-	UNKNOWN,
-	FINISHED,
-	RELEASING,
-	NOT_YET_RELEASED,
-	CANCELLED,
-	HIATUS
+constexpr std::array<SeriesStatus, 6> SeriesStatuses{
+	SeriesStatus::Unknown,
+	SeriesStatus::Finished,
+	SeriesStatus::Releasing,
+	SeriesStatus::NotYetReleased,
+	SeriesStatus::Cancelled,
+	SeriesStatus::Hiatus
 };
 
 enum class SeriesFormat {
-	UNKNOWN,
-	TV,
-	TV_SHORT,
-	MOVIE,
-	SPECIAL,
-	OVA,
-	ONA,
-	MUSIC,
-	MANGA,
-	NOVEL,
-	ONE_SHOT
+	Unknown = 0,
+	Tv,
+	TvShort,
+	Movie,
+	Special,
+	Ova,
+	Ona,
+	Music
+};
+
+constexpr std::array<SeriesFormat, 8> SeriesFormats{
+	SeriesFormat::Unknown,
+	SeriesFormat::Tv,
+	SeriesFormat::TvShort,
+	SeriesFormat::Movie,
+	SeriesFormat::Special,
+	SeriesFormat::Ova,
+	SeriesFormat::Ona,
+	SeriesFormat::Music
 };
 
 enum class SeriesSeason {
-	UNKNOWN,
-	WINTER,
-	SPRING,
-	SUMMER,
-	FALL
+	Unknown = 0,
+	Winter,
+	Spring,
+	Summer,
+	Fall
 };
 
 constexpr std::array<SeriesSeason, 4> SeriesSeasons{
-	SeriesSeason::WINTER, SeriesSeason::SPRING,
-	SeriesSeason::SUMMER, SeriesSeason::FALL
+	SeriesSeason::Winter, SeriesSeason::Spring,
+	SeriesSeason::Summer, SeriesSeason::Fall
 };
 
 enum class TitleLanguage {
-	ROMAJI,
-	NATIVE,
-	ENGLISH
+	Romaji,
+	Native,
+	English
 };
 
-enum class Services {
-	NONE,
-	ANILIST,
-	NB_SERVICES
+constexpr std::array<TitleLanguage, 3> TitleLanguages{TitleLanguage::Romaji, TitleLanguage::Native, TitleLanguage::English};
+
+enum class Service {
+	None,
+	AniList
 };
 
+constexpr std::array<Service, 1> Services{Service::AniList};
+
 enum class ScoreFormat {
-	POINT_100,        // 0-100
-	POINT_10_DECIMAL, // 0.0-10.0
-	POINT_10,         // 0-10
-	POINT_5,          // 0-5, should be represented in stars
-	POINT_3           // 1-3, should be represented in smileys
+	Point100,       // 0-100
+	Point10Decimal, // 0.0-10.0
+	Point10,        // 0-10
+	Point5,         // 0-5, should be represented in stars
+	Point3          // 1-3, should be represented in smileys
 };
 
-constexpr std::array<ScoreFormat, 5> ScoreFormats{ScoreFormat::POINT_100, ScoreFormat::POINT_10_DECIMAL,
-                                                  ScoreFormat::POINT_10, ScoreFormat::POINT_5, ScoreFormat::POINT_3};
+constexpr std::array<ScoreFormat, 5> ScoreFormats{ScoreFormat::Point100, ScoreFormat::Point10Decimal,
+                                                  ScoreFormat::Point10, ScoreFormat::Point5, ScoreFormat::Point3};
 
 struct ListInformation {
 	int id = 0;
 	int progress = 0;
-	int score = 0; // note that this will ALWAYS be in POINT_100 format and must be converted
-	ListStatus status = ListStatus::NOT_IN_LIST;
+	int score = 0; // this will ALWAYS be in POINT_100 format internally
+	ListStatus status = ListStatus::NotInList;
 	Date started;
 	Date completed;
 	bool is_private = false;
@@ -103,12 +125,11 @@
 	} title;
 	std::vector<std::string> synonyms;
 	int episodes = 0;
-	SeriesStatus status = SeriesStatus::UNKNOWN;
+	SeriesStatus status = SeriesStatus::Unknown;
 	Date air_date;
 	std::vector<std::string> genres;
 	std::vector<std::string> producers;
-	SeriesFormat format = SeriesFormat::UNKNOWN;
-	SeriesSeason season = SeriesSeason::UNKNOWN;
+	SeriesFormat format = SeriesFormat::Unknown;
 	int audience_score = 0;
 	std::string synopsis;
 	int duration = 0;
@@ -172,7 +193,6 @@
 	void SetGenres(std::vector<std::string> const& genres);
 	void SetProducers(std::vector<std::string> const& producers);
 	void SetFormat(SeriesFormat format);
-	void SetSeason(SeriesSeason season);
 	void SetAudienceScore(int audience_score);
 	void SetSynopsis(std::string synopsis);
 	void SetDuration(int duration);