Mercurial > minori
comparison src/core/anime.cc @ 211:7cf53145de11
strings: use templates for ToInt, std::to_string -> Strings::ToUtf8String
| author | Paper <mrpapersonic@gmail.com> |
|---|---|
| date | Sun, 07 Jan 2024 09:54:17 -0500 |
| parents | 975a3f0965e2 |
| children | 862d0d8619f6 |
comparison
equal
deleted
inserted
replaced
| 200:da91af31ae73 | 211:7cf53145de11 |
|---|---|
| 3 * datatypes & variables | 3 * datatypes & variables |
| 4 */ | 4 */ |
| 5 #include "core/anime.h" | 5 #include "core/anime.h" |
| 6 #include "core/date.h" | 6 #include "core/date.h" |
| 7 #include "core/session.h" | 7 #include "core/session.h" |
| 8 #include "core/strings.h" | |
| 8 | 9 |
| 9 #include <algorithm> | 10 #include <algorithm> |
| 10 #include <string> | 11 #include <string> |
| 11 #include <vector> | 12 #include <vector> |
| 12 | 13 |
| 48 if (score == 0) | 49 if (score == 0) |
| 49 return ""; | 50 return ""; |
| 50 | 51 |
| 51 switch (session.config.anime_list.score_format) { | 52 switch (session.config.anime_list.score_format) { |
| 52 case ScoreFormat::POINT_10_DECIMAL: | 53 case ScoreFormat::POINT_10_DECIMAL: |
| 53 return std::to_string(score / 10) + "." + std::to_string(score % 10); | 54 return Strings::ToUtf8String(score / 10) + "." + Strings::ToUtf8String(score % 10); |
| 54 case ScoreFormat::POINT_10: | 55 case ScoreFormat::POINT_10: |
| 55 return std::to_string(score / 10); | 56 return Strings::ToUtf8String(score / 10); |
| 56 case ScoreFormat::POINT_5: { | 57 case ScoreFormat::POINT_5: { |
| 57 std::string stars = ""; | 58 std::string stars = ""; |
| 58 | 59 |
| 59 for (int i = 0; i < 100; i += 20) | 60 for (int i = 0; i < 100; i += 20) |
| 60 stars.append((i <= score) ? "★" : "☆"); | 61 stars.append((i <= score) ? "★" : "☆"); |
| 71 else | 72 else |
| 72 return ""; | 73 return ""; |
| 73 } | 74 } |
| 74 default: | 75 default: |
| 75 case ScoreFormat::POINT_100: | 76 case ScoreFormat::POINT_100: |
| 76 return std::to_string(score); | 77 return Strings::ToUtf8String(score); |
| 77 } | 78 } |
| 78 } | 79 } |
| 79 | 80 |
| 80 Date Anime::GetUserDateStarted() const { | 81 Date Anime::GetUserDateStarted() const { |
| 81 assert(list_info_.get()); | 82 assert(list_info_.get()); |
| 241 return info_.poster_url; | 242 return info_.poster_url; |
| 242 } | 243 } |
| 243 | 244 |
| 244 std::string Anime::GetServiceUrl() const { | 245 std::string Anime::GetServiceUrl() const { |
| 245 /* todo: add support for other services... */ | 246 /* todo: add support for other services... */ |
| 246 return "https://anilist.co/anime/" + std::to_string(GetId()); | 247 return "https://anilist.co/anime/" + Strings::ToUtf8String(GetId()); |
| 247 } | 248 } |
| 248 | 249 |
| 249 void Anime::SetId(int id) { | 250 void Anime::SetId(int id) { |
| 250 info_.id = id; | 251 info_.id = id; |
| 251 } | 252 } |
