summaryrefslogtreecommitdiff
path: root/src/utils/stringutils.h
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-02-05 17:19:22 +0100
committerThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-02-05 17:22:25 +0100
commit2f2274e959f3452e847800d7496458360f21c341 (patch)
treee263a33f85bb95bbb56f1f661adf14228305bafb /src/utils/stringutils.h
parent3405b046701e9c08972c1e622259164fc88ac487 (diff)
downloadMana-2f2274e959f3452e847800d7496458360f21c341.tar.gz
Mana-2f2274e959f3452e847800d7496458360f21c341.tar.bz2
Mana-2f2274e959f3452e847800d7496458360f21c341.tar.xz
Mana-2f2274e959f3452e847800d7496458360f21c341.zip
Updated C++ standard to C++17
C++17 should be universal enough by now. This raises the minimum CMake to 3.8, which should also pose no problem since Ubuntu 18.04 already shipped with CMake 3.10. C++17's 'if' initialization statement is now used in an efficient implementation of 'join' for vector<string>, found on StackOverflow.
Diffstat (limited to 'src/utils/stringutils.h')
-rw-r--r--src/utils/stringutils.h12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/utils/stringutils.h b/src/utils/stringutils.h
index b83bc580..cd80b60f 100644
--- a/src/utils/stringutils.h
+++ b/src/utils/stringutils.h
@@ -141,7 +141,7 @@ bool getBoolFromString(const std::string &text, bool def = false);
/**
* Returns the most approaching string of base from candidates.
*/
-std::string autocomplete(std::vector<std::string> &candidates,
+std::string autocomplete(const std::vector<std::string> &candidates,
std::string base);
/**
@@ -152,12 +152,18 @@ std::string normalize(const std::string &name);
/**
* Remove a potential trailing symbol from a string.
*/
-std::string removeTrailingSymbol(const std::string& s, const char c);
+std::string removeTrailingSymbol(const std::string &s, const char c);
/**
* Gets the hostname out of the given URL.
* i.e.: http://www.manasource.org:9601 -> www.manasource.org
*/
-std::string getHostNameFromURL(const std::string& url);
+std::string getHostNameFromURL(const std::string &url);
+
+/**
+ * Joins a vector of strings into one string, separated by the given
+ * separator.
+ */
+std::string join(const std::vector<std::string> &strings, const char *separator);
#endif // UTILS_STRINGUTILS_H