diff src/core/anime.cc @ 369:47c9f8502269

*: clang-format all the things I've edited the formatting a bit. Now pointer asterisks (and reference ampersands) are on the variable instead of the type, as well as having newlines for function braces (but nothing else)
author Paper <paper@tflc.us>
date Fri, 25 Jul 2025 10:16:02 -0400
parents b5d6c27c308f
children
line wrap: on
line diff
--- a/src/core/anime.cc	Fri Jul 25 10:05:23 2025 -0400
+++ b/src/core/anime.cc	Fri Jul 25 10:16:02 2025 -0400
@@ -9,51 +9,59 @@
 #include "core/strings.h"
 
 #include <algorithm>
+#include <cassert>
 #include <string>
 #include <vector>
-#include <cassert>
 
 #include <iostream>
 
 namespace Anime {
 
 /* User list data */
-bool Anime::IsInUserList() const {
+bool Anime::IsInUserList() const
+{
 	if (list_info_.has_value())
 		return true;
 	return false;
 }
 
-void Anime::AddToUserList() {
+void Anime::AddToUserList()
+{
 	ListInformation list;
 	list_info_.emplace(list);
 }
 
-void Anime::RemoveFromUserList() {
+void Anime::RemoveFromUserList()
+{
 	list_info_.reset();
 }
 
-std::string Anime::GetUserId() const {
+std::string Anime::GetUserId() const
+{
 	assert(list_info_.has_value());
 	return list_info_->id;
 }
 
-ListStatus Anime::GetUserStatus() const {
+ListStatus Anime::GetUserStatus() const
+{
 	assert(list_info_.has_value());
 	return list_info_->status;
 }
 
-int Anime::GetUserProgress() const {
+int Anime::GetUserProgress() const
+{
 	assert(list_info_.has_value());
 	return list_info_->progress;
 }
 
-int Anime::GetUserScore() const {
+int Anime::GetUserScore() const
+{
 	assert(list_info_.has_value());
 	return list_info_->score;
 }
 
-std::string Anime::GetUserPresentableScore() const {
+std::string Anime::GetUserPresentableScore() const
+{
 	assert(list_info_.has_value());
 
 	const int score = list_info_->score;
@@ -87,102 +95,122 @@
 	}
 }
 
-Date Anime::GetUserDateStarted() const {
+Date Anime::GetUserDateStarted() const
+{
 	assert(list_info_.has_value());
 	return list_info_->started;
 }
 
-Date Anime::GetUserDateCompleted() const {
+Date Anime::GetUserDateCompleted() const
+{
 	assert(list_info_.has_value());
 	return list_info_->completed;
 }
 
-bool Anime::GetUserIsPrivate() const {
+bool Anime::GetUserIsPrivate() const
+{
 	assert(list_info_.has_value());
 	return list_info_->is_private;
 }
 
-unsigned int Anime::GetUserRewatchedTimes() const {
+unsigned int Anime::GetUserRewatchedTimes() const
+{
 	assert(list_info_.has_value());
 	return list_info_->rewatched_times;
 }
 
-bool Anime::GetUserIsRewatching() const {
+bool Anime::GetUserIsRewatching() const
+{
 	assert(list_info_.has_value());
 	return list_info_->rewatching;
 }
 
-uint64_t Anime::GetUserTimeUpdated() const {
+uint64_t Anime::GetUserTimeUpdated() const
+{
 	assert(list_info_.has_value());
 	return list_info_->updated;
 }
 
-std::string Anime::GetUserNotes() const {
+std::string Anime::GetUserNotes() const
+{
 	assert(list_info_.has_value());
 	return list_info_->notes;
 }
 
-void Anime::SetUserId(const std::string& id) {
+void Anime::SetUserId(const std::string &id)
+{
 	assert(list_info_.has_value());
 	list_info_->id = id;
 }
 
-void Anime::SetUserStatus(ListStatus status) {
+void Anime::SetUserStatus(ListStatus status)
+{
 	assert(list_info_.has_value());
 	list_info_->status = status;
 }
 
-void Anime::SetUserScore(int score) {
+void Anime::SetUserScore(int score)
+{
 	assert(list_info_.has_value());
 	list_info_->score = score;
 }
 
-void Anime::SetUserProgress(int progress) {
+void Anime::SetUserProgress(int progress)
+{
 	assert(list_info_.has_value());
 	list_info_->progress = progress;
 }
 
-void Anime::SetUserDateStarted(const Date& started) {
+void Anime::SetUserDateStarted(const Date &started)
+{
 	assert(list_info_.has_value());
 	list_info_->started = started;
 }
 
-void Anime::SetUserDateCompleted(const Date& completed) {
+void Anime::SetUserDateCompleted(const Date &completed)
+{
 	assert(list_info_.has_value());
 	list_info_->completed = completed;
 }
 
-void Anime::SetUserIsPrivate(bool is_private) {
+void Anime::SetUserIsPrivate(bool is_private)
+{
 	assert(list_info_.has_value());
 	list_info_->is_private = is_private;
 }
 
-void Anime::SetUserRewatchedTimes(int rewatched) {
+void Anime::SetUserRewatchedTimes(int rewatched)
+{
 	assert(list_info_.has_value());
 	list_info_->rewatched_times = rewatched;
 }
 
-void Anime::SetUserIsRewatching(bool rewatching) {
+void Anime::SetUserIsRewatching(bool rewatching)
+{
 	assert(list_info_.has_value());
 	list_info_->rewatching = rewatching;
 }
 
-void Anime::SetUserTimeUpdated(uint64_t updated) {
+void Anime::SetUserTimeUpdated(uint64_t updated)
+{
 	assert(list_info_.has_value());
 	list_info_->updated = updated;
 }
 
-void Anime::SetUserNotes(const std::string& notes) {
+void Anime::SetUserNotes(const std::string &notes)
+{
 	assert(list_info_.has_value());
 	list_info_->notes = notes;
 }
 
 /* Series data */
-int Anime::GetId() const {
+int Anime::GetId() const
+{
 	return info_.id;
 }
 
-std::optional<std::string> Anime::GetServiceId(Service service) const {
+std::optional<std::string> Anime::GetServiceId(Service service) const
+{
 	if (info_.ids.find(service) == info_.ids.end())
 		return std::nullopt;
 
@@ -190,161 +218,192 @@
 }
 
 /* note: this should use std::optional */
-std::optional<std::string> Anime::GetTitle(TitleLanguage language) const {
+std::optional<std::string> Anime::GetTitle(TitleLanguage language) const
+{
 	if (info_.titles.find(language) == info_.titles.end())
 		return std::nullopt;
 
 	return info_.titles.at(language);
 }
 
-std::vector<std::string> Anime::GetTitleSynonyms() const {
+std::vector<std::string> Anime::GetTitleSynonyms() const
+{
 	/* mainly for the GUI */
 	std::vector<std::string> result;
 
-	auto add_to_synonyms = [this](std::vector<std::string>& vec, std::string key) {
+	auto add_to_synonyms = [this](std::vector<std::string> &vec, std::string key) {
 		if (!key.empty() && !std::count(vec.begin(), vec.end(), key) && key != GetUserPreferredTitle())
 			vec.push_back(key);
 	};
 
-	for (const auto& lang : TitleLanguages)
+	for (const auto &lang : TitleLanguages)
 		if (info_.titles.find(lang) != info_.titles.end())
 			add_to_synonyms(result, info_.titles.at(lang));
 
-	for (auto& synonym : info_.synonyms)
+	for (auto &synonym : info_.synonyms)
 		add_to_synonyms(result, synonym);
 
 	return result;
 }
 
-int Anime::GetEpisodes() const {
+int Anime::GetEpisodes() const
+{
 	return info_.episodes;
 }
 
-SeriesStatus Anime::GetAiringStatus() const {
+SeriesStatus Anime::GetAiringStatus() const
+{
 	return info_.status;
 }
 
-Date Anime::GetStartedDate() const {
+Date Anime::GetStartedDate() const
+{
 	return info_.started;
 }
 
-Date Anime::GetCompletedDate() const {
+Date Anime::GetCompletedDate() const
+{
 	return info_.completed;
 }
 
-std::vector<std::string> Anime::GetGenres() const {
+std::vector<std::string> Anime::GetGenres() const
+{
 	return info_.genres;
 }
 
-std::vector<std::string> Anime::GetProducers() const {
+std::vector<std::string> Anime::GetProducers() const
+{
 	return info_.producers;
 }
 
-SeriesFormat Anime::GetFormat() const {
+SeriesFormat Anime::GetFormat() const
+{
 	return info_.format;
 }
 
-Season Anime::GetSeason() const {
+Season Anime::GetSeason() const
+{
 	return Season(info_.started);
 }
 
-double Anime::GetAudienceScore() const {
+double Anime::GetAudienceScore() const
+{
 	return info_.audience_score;
 }
 
-std::string Anime::GetSynopsis() const {
+std::string Anime::GetSynopsis() const
+{
 	return info_.synopsis;
 }
 
-int Anime::GetDuration() const {
+int Anime::GetDuration() const
+{
 	return info_.duration;
 }
 
-std::string Anime::GetPosterUrl() const {
+std::string Anime::GetPosterUrl() const
+{
 	/* this isn't really service-specific. this could use
 	 * kitsu, MAL, or anilist, and would achieve basically
 	 * the same effect. */
 	return info_.poster_url;
 }
 
-std::optional<std::string> Anime::GetServiceUrl(Service service) const {
+std::optional<std::string> Anime::GetServiceUrl(Service service) const
+{
 	/* todo: add support for other services... */
 	std::optional<std::string> id = GetServiceId(service);
 	if (!id.has_value())
 		return std::nullopt;
 
 	switch (service) {
-		case Service::AniList:
-			return "https://anilist.co/anime/" + id.value();
+		case Service::AniList: return "https://anilist.co/anime/" + id.value();
 		default: return "";
 	}
 }
 
-void Anime::SetId(int id) {
+void Anime::SetId(int id)
+{
 	info_.id = id;
 }
 
-void Anime::SetServiceId(Service service, const std::string& id) {
+void Anime::SetServiceId(Service service, const std::string &id)
+{
 	info_.ids[service] = id;
 }
 
-void Anime::SetTitle(TitleLanguage language, const std::string& title) {
+void Anime::SetTitle(TitleLanguage language, const std::string &title)
+{
 	info_.titles[language] = title;
 }
 
-void Anime::SetTitleSynonyms(const std::vector<std::string>& synonyms) {
+void Anime::SetTitleSynonyms(const std::vector<std::string> &synonyms)
+{
 	info_.synonyms = synonyms;
 }
 
-void Anime::AddTitleSynonym(const std::string& synonym) {
+void Anime::AddTitleSynonym(const std::string &synonym)
+{
 	info_.synonyms.push_back(synonym);
 }
 
-void Anime::SetEpisodes(int episodes) {
+void Anime::SetEpisodes(int episodes)
+{
 	info_.episodes = episodes;
 }
 
-void Anime::SetAiringStatus(SeriesStatus status) {
+void Anime::SetAiringStatus(SeriesStatus status)
+{
 	info_.status = status;
 }
 
-void Anime::SetStartedDate(const Date& date) {
+void Anime::SetStartedDate(const Date &date)
+{
 	info_.started = date;
 }
 
-void Anime::SetCompletedDate(const Date& date) {
+void Anime::SetCompletedDate(const Date &date)
+{
 	info_.completed = date;
 }
 
-void Anime::SetGenres(const std::vector<std::string>& genres) {
+void Anime::SetGenres(const std::vector<std::string> &genres)
+{
 	info_.genres = genres;
 }
 
-void Anime::SetProducers(const std::vector<std::string>& producers) {
+void Anime::SetProducers(const std::vector<std::string> &producers)
+{
 	info_.producers = producers;
 }
 
-void Anime::SetFormat(SeriesFormat format) {
+void Anime::SetFormat(SeriesFormat format)
+{
 	info_.format = format;
 }
 
-void Anime::SetAudienceScore(double audience_score) {
+void Anime::SetAudienceScore(double audience_score)
+{
 	info_.audience_score = audience_score;
 }
 
-void Anime::SetSynopsis(std::string synopsis) {
+void Anime::SetSynopsis(std::string synopsis)
+{
 	info_.synopsis = synopsis;
 }
 
-void Anime::SetDuration(int duration) {
+void Anime::SetDuration(int duration)
+{
 	info_.duration = duration;
 }
 
-void Anime::SetPosterUrl(std::string url) {
+void Anime::SetPosterUrl(std::string url)
+{
 	info_.poster_url = url;
 }
 
-std::string Anime::GetUserPreferredTitle() const {
+std::string Anime::GetUserPreferredTitle() const
+{
 	std::optional<std::string> title = GetTitle(session.config.anime_list.language);
 	if (title.has_value())
 		return title.value();