diff src/core/anime.cc @ 264:9a04802848c0

*: improve multiple things e.g. making some strings.cc functions modify strings in-place, improving m4_ax_have_qt.m4 code, making anime_db.cc rely on std::optional rather than std::shared_ptr (which was stupid anyway)
author Paper <paper@paper.us.eu.org>
date Thu, 11 Apr 2024 10:15:57 -0400
parents 862d0d8619f6
children ff0b2052b234
line wrap: on
line diff
--- a/src/core/anime.cc	Wed Apr 03 20:46:40 2024 -0400
+++ b/src/core/anime.cc	Thu Apr 11 10:15:57 2024 -0400
@@ -15,13 +15,14 @@
 
 /* User list data */
 bool Anime::IsInUserList() const {
-	if (list_info_.get())
+	if (list_info_.has_value())
 		return true;
 	return false;
 }
 
 void Anime::AddToUserList() {
-	list_info_.reset(new ListInformation);
+	ListInformation list = {0};
+	list_info_.emplace(list);
 }
 
 void Anime::RemoveFromUserList() {
@@ -29,22 +30,22 @@
 }
 
 ListStatus Anime::GetUserStatus() const {
-	assert(list_info_.get());
+	assert(list_info_.has_value());
 	return list_info_->status;
 }
 
 int Anime::GetUserProgress() const {
-	assert(list_info_.get());
+	assert(list_info_.has_value());
 	return list_info_->progress;
 }
 
 int Anime::GetUserScore() const {
-	assert(list_info_.get());
+	assert(list_info_.has_value());
 	return list_info_->score;
 }
 
 std::string Anime::GetUserPresentableScore() const {
-	assert(list_info_.get());
+	assert(list_info_.has_value());
 	const int score = list_info_->score;
 	if (score == 0)
 		return "";
@@ -77,87 +78,87 @@
 }
 
 Date Anime::GetUserDateStarted() const {
-	assert(list_info_.get());
+	assert(list_info_.has_value());
 	return list_info_->started;
 }
 
 Date Anime::GetUserDateCompleted() const {
-	assert(list_info_.get());
+	assert(list_info_.has_value());
 	return list_info_->completed;
 }
 
 bool Anime::GetUserIsPrivate() const {
-	assert(list_info_.get());
+	assert(list_info_.has_value());
 	return list_info_->is_private;
 }
 
 unsigned int Anime::GetUserRewatchedTimes() const {
-	assert(list_info_.get());
+	assert(list_info_.has_value());
 	return list_info_->rewatched_times;
 }
 
 bool Anime::GetUserIsRewatching() const {
-	assert(list_info_.get());
+	assert(list_info_.has_value());
 	return list_info_->rewatching;
 }
 
 uint64_t Anime::GetUserTimeUpdated() const {
-	assert(list_info_.get());
+	assert(list_info_.has_value());
 	return list_info_->updated;
 }
 
 std::string Anime::GetUserNotes() const {
-	assert(list_info_.get());
+	assert(list_info_.has_value());
 	return list_info_->notes;
 }
 
 void Anime::SetUserStatus(ListStatus status) {
-	assert(list_info_.get());
+	assert(list_info_.has_value());
 	list_info_->status = status;
 }
 
 void Anime::SetUserScore(int score) {
-	assert(list_info_.get());
+	assert(list_info_.has_value());
 	list_info_->score = score;
 }
 
 void Anime::SetUserProgress(int progress) {
-	assert(list_info_.get());
+	assert(list_info_.has_value());
 	list_info_->progress = progress;
 }
 
 void Anime::SetUserDateStarted(Date const& started) {
-	assert(list_info_.get());
+	assert(list_info_.has_value());
 	list_info_->started = started;
 }
 
 void Anime::SetUserDateCompleted(Date const& completed) {
-	assert(list_info_.get());
+	assert(list_info_.has_value());
 	list_info_->completed = completed;
 }
 
 void Anime::SetUserIsPrivate(bool is_private) {
-	assert(list_info_.get());
+	assert(list_info_.has_value());
 	list_info_->is_private = is_private;
 }
 
 void Anime::SetUserRewatchedTimes(int rewatched) {
-	assert(list_info_.get());
+	assert(list_info_.has_value());
 	list_info_->rewatched_times = rewatched;
 }
 
 void Anime::SetUserIsRewatching(bool rewatching) {
-	assert(list_info_.get());
+	assert(list_info_.has_value());
 	list_info_->rewatching = rewatching;
 }
 
 void Anime::SetUserTimeUpdated(uint64_t updated) {
-	assert(list_info_.get());
+	assert(list_info_.has_value());
 	list_info_->updated = updated;
 }
 
 void Anime::SetUserNotes(std::string const& notes) {
-	assert(list_info_.get());
+	assert(list_info_.has_value());
 	list_info_->notes = notes;
 }