Mercurial > minori
comparison src/core/strings.cc @ 250:c130f47f6f48
*: many many changes
e.g. the search page is actually implemented now!
| author | Paper <paper@paper.us.eu.org> |
|---|---|
| date | Sun, 04 Feb 2024 21:17:17 -0500 |
| parents | 69f4768a820c |
| children | 862d0d8619f6 |
comparison
equal
deleted
inserted
replaced
| 249:6b2441c776dd | 250:c130f47f6f48 |
|---|---|
| 21 namespace Strings { | 21 namespace Strings { |
| 22 | 22 |
| 23 /* ew */ | 23 /* ew */ |
| 24 std::string Implode(const std::vector<std::string>& vector, const std::string& delimiter) { | 24 std::string Implode(const std::vector<std::string>& vector, const std::string& delimiter) { |
| 25 if (vector.size() < 1) | 25 if (vector.size() < 1) |
| 26 return "-"; | 26 return ""; |
| 27 | 27 |
| 28 std::string out; | 28 std::string out; |
| 29 | 29 |
| 30 for (unsigned long long i = 0; i < vector.size(); i++) { | 30 for (unsigned long long i = 0; i < vector.size(); i++) { |
| 31 out.append(vector.at(i)); | 31 out.append(vector.at(i)); |
| 36 return out; | 36 return out; |
| 37 } | 37 } |
| 38 | 38 |
| 39 std::string Implode(const std::set<std::string>& set, const std::string& delimiter) { | 39 std::string Implode(const std::set<std::string>& set, const std::string& delimiter) { |
| 40 if (set.size() < 1) | 40 if (set.size() < 1) |
| 41 return "-"; | 41 return ""; |
| 42 | 42 |
| 43 std::string out; | 43 std::string out; |
| 44 | 44 |
| 45 for (auto it = set.cbegin(); it != set.cend(); it++) { | 45 for (auto it = set.cbegin(); it != set.cend(); it++) { |
| 46 out.append(*it); | 46 out.append(*it); |
| 50 | 50 |
| 51 return out; | 51 return out; |
| 52 } | 52 } |
| 53 | 53 |
| 54 std::vector<std::string> Split(const std::string &text, const std::string& delimiter) { | 54 std::vector<std::string> Split(const std::string &text, const std::string& delimiter) { |
| 55 if (text.length() < 1) | |
| 56 return {}; | |
| 57 | |
| 55 std::vector<std::string> tokens; | 58 std::vector<std::string> tokens; |
| 56 | 59 |
| 57 std::size_t start = 0, end = 0; | 60 std::size_t start = 0, end = 0; |
| 58 while ((end = text.find(delimiter, start)) != std::string::npos) { | 61 while ((end = text.find(delimiter, start)) != std::string::npos) { |
| 59 tokens.push_back(text.substr(start, end - start)); | 62 tokens.push_back(text.substr(start, end - start)); |
| 89 "<br />", "\n"), | 92 "<br />", "\n"), |
| 90 "\n\n\n", "\n\n"); | 93 "\n\n\n", "\n\n"); |
| 91 } | 94 } |
| 92 | 95 |
| 93 /* removes dumb HTML tags because anilist is aids and | 96 /* removes dumb HTML tags because anilist is aids and |
| 94 gives us HTML for synopses :/ */ | 97 * gives us HTML for synopses :/ |
| 98 */ | |
| 95 std::string RemoveHtmlTags(std::string string) { | 99 std::string RemoveHtmlTags(std::string string) { |
| 96 while (string.find("<") != std::string::npos) { | 100 while (string.find("<") != std::string::npos) { |
| 97 auto startpos = string.find("<"); | 101 auto startpos = string.find("<"); |
| 98 auto endpos = string.find(">") + 1; | 102 auto endpos = string.find(">") + 1; |
| 99 | 103 |
