diff include/core/strings.h @ 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 6b0768158dcd
children
line wrap: on
line diff
--- a/include/core/strings.h	Fri Jul 25 10:05:23 2025 -0400
+++ b/include/core/strings.h	Fri Jul 25 10:16:02 2025 -0400
@@ -16,63 +16,65 @@
 /* Implode function: takes a vector of strings and turns it
  * into a string, separated by delimiters.
  */
-std::string Implode(const std::vector<std::string>& vector, const std::string& delimiter);
-std::vector<std::string> Split(const std::string& text, const std::string& delimiter);
+std::string Implode(const std::vector<std::string> &vector, const std::string &delimiter);
+std::vector<std::string> Split(const std::string &text, const std::string &delimiter);
 
 /* Substring removal functions */
-void ReplaceAll(std::string& string, std::string_view find, std::string_view replace);
-void NormalizeUnicode(std::string& string);
-void NormalizeAnimeTitle(std::string& string);
+void ReplaceAll(std::string &string, std::string_view find, std::string_view replace);
+void NormalizeUnicode(std::string &string);
+void NormalizeAnimeTitle(std::string &string);
 
 /* stupid HTML bullshit */
-void TextifySynopsis(std::string& string);
+void TextifySynopsis(std::string &string);
 
-std::string ToUpper(const std::string& string);
-std::string ToLower(const std::string& string);
+std::string ToUpper(const std::string &string);
+std::string ToLower(const std::string &string);
 
 /* functions that make the way we convert from and to
  * different string formats universal (and these functions
  * typically do things the right way so we avoid retarded
  * code)
  */
-std::wstring ToWstring(const std::string& string);
-std::wstring ToWstring(const QString& string);
-std::string ToUtf8String(const std::wstring& wstring);
-std::string ToUtf8String(const QString& string);
-std::string ToUtf8String(const QByteArray& ba);
-std::string ToUtf8String(const std::u32string& u32string);
-std::u32string ToUcs4String(const std::string& string);
-QString ToQString(const std::string& string);
-QString ToQString(const std::wstring& wstring);
+std::wstring ToWstring(const std::string &string);
+std::wstring ToWstring(const QString &string);
+std::string ToUtf8String(const std::wstring &wstring);
+std::string ToUtf8String(const QString &string);
+std::string ToUtf8String(const QByteArray &ba);
+std::string ToUtf8String(const std::u32string &u32string);
+std::u32string ToUcs4String(const std::string &string);
+QString ToQString(const std::string &string);
+QString ToQString(const std::wstring &wstring);
 
 /* not really an "int"... but who cares? */
 template<typename T = int, std::enable_if_t<std::is_arithmetic<T>::value, bool> = true>
-T ToInt(const std::string& str, T def = 0) {
+T ToInt(const std::string &str, T def = 0)
+{
 	std::istringstream s(str);
 	s >> std::noboolalpha >> def;
 	return def;
 }
 
 template<typename T, std::enable_if_t<std::is_arithmetic<T>::value && !std::is_same<T, bool>::value, bool> = true>
-std::string ToUtf8String(T i) {
+std::string ToUtf8String(T i)
+{
 	std::ostringstream s;
 	s << std::noboolalpha << i;
 	return s.str();
 }
 
-bool ToBool(const std::string& s, bool def);
+bool ToBool(const std::string &s, bool def);
 
 std::string ToUtf8String(bool b);
 
-uint64_t HumanReadableSizeToBytes(const std::string& str);
+uint64_t HumanReadableSizeToBytes(const std::string &str);
 std::string BytesToHumanReadableSize(uint64_t bytes, int precision = 2);
 
-void RemoveLeadingChars(std::string& s,  const char c);
-void RemoveTrailingChars(std::string& s, const char c);
+void RemoveLeadingChars(std::string &s, const char c);
+void RemoveTrailingChars(std::string &s, const char c);
 
-bool BeginningMatchesSubstring(const std::string& str, const std::string& sub);
+bool BeginningMatchesSubstring(const std::string &str, const std::string &sub);
 
-std::string Translate(const char* str);
+std::string Translate(const char *str);
 
 }; // namespace Strings