Mercurial > minori
annotate include/core/strings.h @ 117:2c1b6782e1d0
pages/torrents: work around conversion error on Linux
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Tue, 07 Nov 2023 16:06:17 -0500 |
parents | 254b1d2b7096 |
children | 39521c47c7a3 |
rev | line source |
---|---|
9 | 1 #ifndef __core__strings_h |
2 #define __core__strings_h | |
15 | 3 |
9 | 4 #include <string> |
5 #include <vector> | |
105
6d8da6e64d61
theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents:
102
diff
changeset
|
6 #include <array> |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
105
diff
changeset
|
7 #include <cstdint> |
15 | 8 |
64 | 9 class QString; |
116
254b1d2b7096
settings: add torrents page, make rss feed configurable
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
10 class QByteArray; |
64 | 11 |
10 | 12 namespace Strings { |
15 | 13 |
9 | 14 /* Implode function: takes a vector of strings and turns it |
15 into a string, separated by delimiters. */ | |
16 std::string Implode(const std::vector<std::string>& vector, const std::string& delimiter); | |
17 | |
18 /* Substring removal functions */ | |
98
582b2fca1561
strings: parse HTML entities when reading synopsis, make the
Paper <mrpapersonic@gmail.com>
parents:
85
diff
changeset
|
19 std::string ReplaceAll(std::string string, const std::string& find, const std::string& replace); |
9 | 20 std::string SanitizeLineEndings(const std::string& string); |
100
f5940a575d83
track/constants: add many more video formats
Paper <mrpapersonic@gmail.com>
parents:
98
diff
changeset
|
21 std::string RemoveHtmlTags(std::string string); |
f5940a575d83
track/constants: add many more video formats
Paper <mrpapersonic@gmail.com>
parents:
98
diff
changeset
|
22 std::string ParseHtmlEntities(std::string string); |
9 | 23 |
24 /* stupid HTML bullshit */ | |
25 std::string TextifySynopsis(const std::string& string); | |
15 | 26 |
27 std::string ToUpper(const std::string& string); | |
28 std::string ToLower(const std::string& string); | |
29 | |
98
582b2fca1561
strings: parse HTML entities when reading synopsis, make the
Paper <mrpapersonic@gmail.com>
parents:
85
diff
changeset
|
30 /* functions that make the way we convert from and to |
582b2fca1561
strings: parse HTML entities when reading synopsis, make the
Paper <mrpapersonic@gmail.com>
parents:
85
diff
changeset
|
31 different string formats universal */ |
62 | 32 std::wstring ToWstring(const std::string& string); |
64 | 33 std::wstring ToWstring(const QString& string); |
62 | 34 std::string ToUtf8String(const std::wstring& wstring); |
64 | 35 std::string ToUtf8String(const QString& string); |
116
254b1d2b7096
settings: add torrents page, make rss feed configurable
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
36 std::string ToUtf8String(const QByteArray& ba); |
64 | 37 QString ToQString(const std::string& string); |
38 QString ToQString(const std::wstring& wstring); | |
62 | 39 |
101
c537996cf67b
*: multitude of config changes
Paper <mrpapersonic@gmail.com>
parents:
100
diff
changeset
|
40 /* arithmetic :) */ |
c537996cf67b
*: multitude of config changes
Paper <mrpapersonic@gmail.com>
parents:
100
diff
changeset
|
41 int ToInt(const std::string& str, int def = 0); |
c537996cf67b
*: multitude of config changes
Paper <mrpapersonic@gmail.com>
parents:
100
diff
changeset
|
42 |
116
254b1d2b7096
settings: add torrents page, make rss feed configurable
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
43 bool ToBool(const std::string& s, const bool def = false); |
254b1d2b7096
settings: add torrents page, make rss feed configurable
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
44 std::string ToUtf8String(const bool b); |
254b1d2b7096
settings: add torrents page, make rss feed configurable
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
45 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
105
diff
changeset
|
46 uint64_t HumanReadableSizeToBytes(const std::string& str); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
105
diff
changeset
|
47 |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
105
diff
changeset
|
48 std::string RemoveLeadingChars(std::string s, const char c); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
105
diff
changeset
|
49 std::string RemoveTrailingChars(std::string s, const char c); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
105
diff
changeset
|
50 |
102 | 51 bool BeginningMatchesSubstring(const std::string& str, const std::string& sub); |
52 | |
85 | 53 }; // namespace Strings |
54 | |
9 | 55 #endif // __core__strings_h |